mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-16 04:11:29 +00:00
* Add proxy .pac file resolver chore(dependencies): update package-lock.json with new dependencies and version upgrades - Added new dependencies: ajv, git-url-parse, @opencollection/types, and storybook packages. - Updated existing dependencies to their latest versions, including eslint and babel packages. - Removed deprecated entries and cleaned up the package-lock structure for better maintainability. * tests * wip * wip * wip * wip * feat: file upload .pac * wip * wip * wip * wip * wip * wip * wip * wip * feat: Refactor proxy settings to use a new structure for PAC configuration. Introduced 'source' field to determine proxy type (manual or PAC) and updated related validation and state management. Removed deprecated 'pacUrl' field in favor of 'pac.source'. Updated preferences schema and test data accordingly. * fix: Update proxy settings to correctly reference 'source' field for PAC configuration. Adjusted state management and validation logic to align with new structure. Enhanced tests for backward compatibility and new format handling. * feat: Enhance proxy configuration by adding 'proxyModeReason' to provide context for proxy settings. Updated related functions to accommodate the new parameter and improved logging for proxy mode changes. * wip * refactor: Update proxy settings to remove 'inherit' field and replace it with 'source' for better clarity. Adjusted validation schema, default preferences, and migration logic to align with the new structure. Enhanced tests to ensure compatibility with the updated proxy configuration. * wip * wip * wip * wip * wip * chore: consistent path check * chore: consistency * tests(pac): fix unit params --------- Co-authored-by: Gianluca D'Abrosca <gianluca.dabrosca.1999@gmail.com> Co-authored-by: Sid <siddharth@usebruno.com>
69 lines
2.5 KiB
TypeScript
69 lines
2.5 KiB
TypeScript
import * as path from 'path';
|
|
import { pathToFileURL } from 'url';
|
|
import { test } from '../../../playwright';
|
|
import { setSandboxMode, runCollection, validateRunnerResults } from '../../utils/page';
|
|
import { startServers, stopServers, PAC_PORT, type TestServers } from './server';
|
|
|
|
test.describe('PAC Proxy', () => {
|
|
let servers: TestServers;
|
|
|
|
test.beforeAll(async () => {
|
|
servers = await startServers();
|
|
});
|
|
|
|
test.afterAll(async () => {
|
|
if (servers) {
|
|
await stopServers(servers);
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Verifies end-to-end PAC proxy resolution:
|
|
*
|
|
* - The PAC file routes /proxied paths to the local test proxy (port 18888).
|
|
* - The local test proxy injects `x-proxied: test-proxy` into every response.
|
|
* - /direct paths are returned DIRECT — no proxy header added.
|
|
*
|
|
* Both assertions live inside the collection's `tests {}` blocks, so
|
|
* validateRunnerResults confirms the full flow passed.
|
|
*/
|
|
test('routes requests per PAC directive (PROXY and DIRECT) via HTTP URL', async ({ launchElectronApp }) => {
|
|
const pacUrl = `http://localhost:${PAC_PORT}/test.pac`;
|
|
const initUserDataPath = path.join(__dirname, 'init-user-data');
|
|
const app = await launchElectronApp({ initUserDataPath, templateVars: { pacUrl } });
|
|
|
|
const page = await app.firstWindow();
|
|
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
|
|
|
|
await setSandboxMode(page, 'pac-proxy-test', 'developer');
|
|
await runCollection(page, 'pac-proxy-test');
|
|
await validateRunnerResults(page, {
|
|
totalRequests: 2,
|
|
passed: 2,
|
|
failed: 0,
|
|
skipped: 0
|
|
});
|
|
});
|
|
|
|
test('routes requests via file:// PAC URL', async ({ launchElectronApp }) => {
|
|
// Compute the file:// URL at runtime so it is correct on every OS:
|
|
// Mac/Linux → file:///abs/path/to/test.pac
|
|
// Windows → file:///C:/abs/path/to/test.pac
|
|
const pacUrl = pathToFileURL(path.join(__dirname, 'fixtures', 'pac-files', 'test.pac')).href;
|
|
const initUserDataPath = path.join(__dirname, 'init-user-data');
|
|
const app = await launchElectronApp({ initUserDataPath, templateVars: { pacUrl } });
|
|
|
|
const page = await app.firstWindow();
|
|
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
|
|
|
|
await setSandboxMode(page, 'pac-proxy-test', 'developer');
|
|
await runCollection(page, 'pac-proxy-test');
|
|
await validateRunnerResults(page, {
|
|
totalRequests: 2,
|
|
passed: 2,
|
|
failed: 0,
|
|
skipped: 0
|
|
});
|
|
});
|
|
});
|