Work on CORS testing and fixes. Chrome and pfSense with the DNS resolution found a problem. Should be fixed now.
This commit is contained in:
@@ -11,6 +11,7 @@ const config: PlaywrightTestConfig = {
|
|||||||
reporter: 'list',
|
reporter: 'list',
|
||||||
use: {
|
use: {
|
||||||
baseURL: 'http://demo.localhost:5173',
|
baseURL: 'http://demo.localhost:5173',
|
||||||
|
// baseURL: 'https://dev-demo.oneskyit.com',
|
||||||
trace: 'on-first-retry'
|
trace: 'on-first-retry'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
|
||||||
|
|
||||||
describe('sum test', () => {
|
|
||||||
it('adds 1 + 2 to equal 3', () => {
|
|
||||||
expect(1 + 2).toBe(3);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex-none">
|
<div class="flex-none">
|
||||||
<span class="transition-transform duration-200" class:rotate-180={open_accordions[meeting.meeting_id]}>
|
<span class="transition-transform duration-200" class:rotate-180={open_accordions[meeting.meeting_id]}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
|
<svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test';
|
|||||||
|
|
||||||
test('homepage has title and link', async ({ page }) => {
|
test('homepage has title and link', async ({ page }) => {
|
||||||
await page.goto('http://scott.localhost:5173/');
|
await page.goto('http://scott.localhost:5173/');
|
||||||
|
// await page.goto('https://dev-demo.oneskyit.com/');
|
||||||
|
|
||||||
// Expect a title "to contain" a substring.
|
// Expect a title "to contain" a substring.
|
||||||
await expect(page).toHaveTitle(/SvelteKit/);
|
await expect(page).toHaveTitle(/SvelteKit/);
|
||||||
@@ -9,6 +10,7 @@ test('homepage has title and link', async ({ page }) => {
|
|||||||
|
|
||||||
test('get started link', async ({ page }) => {
|
test('get started link', async ({ page }) => {
|
||||||
await page.goto('http://scott.localhost:5173/');
|
await page.goto('http://scott.localhost:5173/');
|
||||||
|
// await page.goto('https://dev-demo.oneskyit.com/');
|
||||||
|
|
||||||
// Click the get started link.
|
// Click the get started link.
|
||||||
await page.getByRole('link', { name: 'Docs' }).click();
|
await page.getByRole('link', { name: 'Docs' }).click();
|
||||||
|
|||||||
62
tests/private_network_cdp.test.ts
Normal file
62
tests/private_network_cdp.test.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
// This test attaches to the Chrome DevTools Protocol to capture low-level
|
||||||
|
// network events (including those from service workers). Run this with the
|
||||||
|
// real Chrome binary (channel: 'chrome') to reproduce the exact browser
|
||||||
|
// behavior that shows the PNA prompt.
|
||||||
|
|
||||||
|
test('CDP: detect private/local network requests and PNA preflights', async ({ page }) => {
|
||||||
|
const privateRequests: Array<any> = [];
|
||||||
|
|
||||||
|
function isPrivateHostname(hostname: string) {
|
||||||
|
if (!hostname) return false;
|
||||||
|
if (hostname === 'localhost' || hostname.endsWith('.localhost')) return true;
|
||||||
|
if (/^(127)\.|^(10)\.|^(192\.168)\.|^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a CDP session for the page to listen to Network events
|
||||||
|
const client = await page.context().newCDPSession(page);
|
||||||
|
await client.send('Network.enable');
|
||||||
|
|
||||||
|
client.on('Network.requestWillBeSent', (params) => {
|
||||||
|
try {
|
||||||
|
const url = params.request.url;
|
||||||
|
const hostname = new URL(url).hostname;
|
||||||
|
const headers = params.request.headers || {};
|
||||||
|
const pna = headers['access-control-request-private-network'] === 'true' || headers['Access-Control-Request-Private-Network'] === 'true';
|
||||||
|
|
||||||
|
if (isPrivateHostname(hostname) || pna) {
|
||||||
|
privateRequests.push({
|
||||||
|
url,
|
||||||
|
method: params.request.method,
|
||||||
|
initiator: params.initiator?.type,
|
||||||
|
pnaPreflight: pna,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Also capture console messages to surface the same errors you see in Chrome.
|
||||||
|
const consoleMessages: string[] = [];
|
||||||
|
page.on('console', (msg) => {
|
||||||
|
consoleMessages.push(`${msg.type()}: ${msg.text()}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to the site that triggers the behavior in your environment.
|
||||||
|
await page.goto('http://demo.localhost:5173/');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
if (privateRequests.length > 0) {
|
||||||
|
console.error('CDP detected private/local requests or PNA preflights:');
|
||||||
|
for (const r of privateRequests) console.error(JSON.stringify(r, null, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consoleMessages.length) {
|
||||||
|
console.log('Captured console messages:');
|
||||||
|
consoleMessages.forEach((m) => console.log(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(privateRequests.length, 'No private/local network requests or PNA preflights should be made').toBe(0);
|
||||||
|
});
|
||||||
62
tests/private_network_detection.test.ts
Normal file
62
tests/private_network_detection.test.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
// Detect requests to private/local address space or PNA preflight headers.
|
||||||
|
test('detect private/local network requests and PNA preflights', async ({ page }) => {
|
||||||
|
const privateRequests: Array<any> = [];
|
||||||
|
|
||||||
|
function isPrivateHostname(hostname: string) {
|
||||||
|
if (!hostname) return false;
|
||||||
|
// hostnames that resolve to local addresses or explicitly localhost
|
||||||
|
if (hostname === 'localhost' || hostname.endsWith('.localhost')) return true;
|
||||||
|
// IPv4 private ranges
|
||||||
|
if (/^(127)\.|^(10)\.|^(192\.168)\.|^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
page.on('request', (request) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(request.url());
|
||||||
|
const headers = request.headers();
|
||||||
|
const hostname = url.hostname;
|
||||||
|
|
||||||
|
const pnaHeader = (headers['access-control-request-private-network'] || headers['Access-Control-Request-Private-Network']);
|
||||||
|
|
||||||
|
if (isPrivateHostname(hostname) || pnaHeader === 'true') {
|
||||||
|
privateRequests.push({
|
||||||
|
url: request.url(),
|
||||||
|
method: request.method(),
|
||||||
|
resourceType: request.resourceType(),
|
||||||
|
pnaPreflight: pnaHeader === 'true',
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// ignore parse errors
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
page.on('requestfailed', (r) => {
|
||||||
|
// capture failed requests that might be private and blocked
|
||||||
|
try {
|
||||||
|
const url = new URL(r.url());
|
||||||
|
if (isPrivateHostname(url.hostname)) {
|
||||||
|
privateRequests.push({ url: r.url(), method: r.method(), failure: r.failure() });
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to the dev site used in other tests.
|
||||||
|
await page.goto('http://demo.localhost:5173/');
|
||||||
|
|
||||||
|
// Wait for network to settle.
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
if (privateRequests.length > 0) {
|
||||||
|
console.error('Detected private/local requests or PNA preflights:');
|
||||||
|
for (const r of privateRequests) {
|
||||||
|
console.error(JSON.stringify(r, null, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(privateRequests.length, 'No private/local network requests or PNA preflights should be made').toBe(0);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user