115 lines
4.4 KiB
JavaScript
115 lines
4.4 KiB
JavaScript
import { chromium } from 'playwright';
|
|
|
|
const BASE = 'http://127.1.0.5';
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const context = await browser.newContext({ ignoreHTTPSErrors: true });
|
|
const page = await context.newPage();
|
|
|
|
// Step 1: Sign in
|
|
console.log('=== SIGNING IN ===');
|
|
await page.goto(BASE + '/', { waitUntil: 'networkidle', timeout: 15000 });
|
|
|
|
const signInBtn = page.locator('button:has-text("Sign In"), a:has-text("Sign In"), [routerLink*="auth"]').first();
|
|
try { await signInBtn.click({ timeout: 5000 }); } catch { await page.goto(BASE + '/auth/login', { waitUntil: 'networkidle', timeout: 10000 }); }
|
|
await page.waitForTimeout(2000);
|
|
|
|
try {
|
|
await page.locator('input[name="Username"], input[name="username"], input[type="text"]').first().fill('admin', { timeout: 5000 });
|
|
await page.locator('input[name="Password"], input[name="password"], input[type="password"]').first().fill('Admin@Stella2026!');
|
|
await page.locator('button[type="submit"], button:has-text("Log in"), button:has-text("Login"), button:has-text("Sign in")').first().click();
|
|
await page.waitForTimeout(4000);
|
|
} catch (e) {
|
|
console.log('Login error: ' + e.message);
|
|
}
|
|
|
|
console.log('After login: ' + page.url());
|
|
|
|
// Step 2: Check auth session state
|
|
const authState = await page.evaluate(() => {
|
|
// Check sessionStorage and localStorage for tokens
|
|
const keys = [];
|
|
for (let i = 0; i < sessionStorage.length; i++) keys.push('session:' + sessionStorage.key(i));
|
|
for (let i = 0; i < localStorage.length; i++) keys.push('local:' + localStorage.key(i));
|
|
return { keys, url: window.location.href };
|
|
});
|
|
console.log('Storage keys:', JSON.stringify(authState.keys));
|
|
|
|
// Step 3: Navigate to scheduler and capture FULL request details
|
|
console.log('\n=== CAPTURING SCHEDULER REQUEST ===');
|
|
|
|
page.on('request', (request) => {
|
|
const url = request.url();
|
|
if (url.includes('/scheduler/') || url.includes('/api/v1/scheduler')) {
|
|
console.log('\nREQUEST:');
|
|
console.log(' URL: ' + url);
|
|
console.log(' Method: ' + request.method());
|
|
const headers = request.headers();
|
|
console.log(' Authorization: ' + (headers['authorization'] || 'NONE'));
|
|
console.log(' DPoP: ' + (headers['dpop'] ? headers['dpop'].substring(0, 80) + '...' : 'NONE'));
|
|
console.log(' X-StellaOps-Tenant: ' + (headers['x-stellaops-tenant'] || 'NONE'));
|
|
console.log(' X-Tenant-Id: ' + (headers['x-tenant-id'] || 'NONE'));
|
|
console.log(' X-Scopes: ' + (headers['x-scopes'] || 'not set by client'));
|
|
}
|
|
});
|
|
|
|
page.on('response', async (response) => {
|
|
const url = response.url();
|
|
if (url.includes('/scheduler/') || url.includes('/api/v1/scheduler')) {
|
|
console.log('\nRESPONSE:');
|
|
console.log(' URL: ' + url);
|
|
console.log(' Status: ' + response.status());
|
|
try {
|
|
const body = await response.text();
|
|
console.log(' Body: ' + body.substring(0, 300));
|
|
} catch {}
|
|
}
|
|
});
|
|
|
|
// Also capture token endpoint requests
|
|
page.on('request', (request) => {
|
|
const url = request.url();
|
|
if (url.includes('/connect/token') || url.includes('/authority/connect/token')) {
|
|
console.log('\nTOKEN REQUEST: ' + url);
|
|
console.log(' Method: ' + request.method());
|
|
}
|
|
});
|
|
page.on('response', async (response) => {
|
|
const url = response.url();
|
|
if (url.includes('/connect/token') || url.includes('/authority/connect/token')) {
|
|
console.log('TOKEN RESPONSE: ' + response.status());
|
|
}
|
|
});
|
|
|
|
await page.evaluate((r) => {
|
|
window.history.pushState({}, '', r);
|
|
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
}, '/operations/scheduler');
|
|
|
|
await page.waitForTimeout(5000);
|
|
|
|
// Step 4: Also check what the Angular app thinks its auth state is
|
|
const appAuthState = await page.evaluate(() => {
|
|
try {
|
|
// Try to access Angular's injector
|
|
const appRef = window.ng?.getComponent(document.querySelector('app-root'));
|
|
return { hasAppRef: !!appRef };
|
|
} catch {
|
|
return { hasAppRef: false };
|
|
}
|
|
});
|
|
console.log('\nApp auth state:', JSON.stringify(appAuthState));
|
|
|
|
// Check console errors
|
|
page.on('console', (msg) => {
|
|
if (msg.type() === 'error' || msg.type() === 'warn') {
|
|
console.log('CONSOLE [' + msg.type() + ']: ' + msg.text().substring(0, 200));
|
|
}
|
|
});
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
await browser.close();
|
|
})();
|