mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
fix: match against secure path (#13442)
This commit is contained in:
parent
212c665152
commit
9712b9ee08
@ -658,7 +658,7 @@ async function launchGridServer(factoryPathOrPackageName: string, port: number,
|
||||
factory.name = factory.name || factoryPathOrPackageName;
|
||||
const gridServer = new GridServer(factory as GridFactory, authToken, address);
|
||||
await gridServer.start(port);
|
||||
console.log('Grid server is running at ' + gridServer.urlPrefix());
|
||||
console.log('Grid server is running at ' + gridServer.gridURL());
|
||||
}
|
||||
|
||||
function buildBasePlaywrightCLICommand(cliTargetLang: string | undefined): string {
|
||||
|
@ -253,7 +253,8 @@ export class GridServer {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (request.url!.startsWith('/registerAgent') || request.url!.startsWith('/registerWorker')) {
|
||||
if (request.url!.startsWith(this._securePath('/registerAgent'))
|
||||
|| request.url!.startsWith(this._securePath('/registerWorker'))) {
|
||||
const params = new URL('http://localhost/' + request.url).searchParams;
|
||||
const agentId = params.get('agentId');
|
||||
return !!agentId && this._agents.has(agentId);
|
||||
@ -285,7 +286,7 @@ export class GridServer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.url?.startsWith('/registerAgent')) {
|
||||
if (request.url?.startsWith(this._securePath('/registerAgent'))) {
|
||||
const params = new URL('http://localhost/' + request.url).searchParams;
|
||||
if (params.get('pwVersion') !== this._pwVersion) {
|
||||
ws.close(WSErrors.AGENT_PLAYWRIGHT_VERSION_MISMATCH.code, WSErrors.AGENT_PLAYWRIGHT_VERSION_MISMATCH.reason);
|
||||
@ -302,7 +303,7 @@ export class GridServer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.url?.startsWith('/registerWorker')) {
|
||||
if (request.url?.startsWith(this._securePath('/registerWorker'))) {
|
||||
const params = new URL('http://localhost/' + request.url).searchParams;
|
||||
const agentId = params.get('agentId')!;
|
||||
const workerId = params.get('workerId')!;
|
||||
@ -332,7 +333,7 @@ export class GridServer {
|
||||
const initPromise = Promise.resolve()
|
||||
.then(() => this._factory.launch({
|
||||
agentId: agent.agentId,
|
||||
gridURL: this.urlPrefix(),
|
||||
gridURL: this.gridURL(),
|
||||
playwrightVersion: getPlaywrightVersion(),
|
||||
})).then(() => {
|
||||
this._log('created');
|
||||
@ -386,8 +387,8 @@ export class GridServer {
|
||||
await this._server.start(port);
|
||||
}
|
||||
|
||||
urlPrefix(): string {
|
||||
return this._server.urlPrefix() + this._securePath('/');
|
||||
gridURL(): string {
|
||||
return this._server.urlPrefix() + this._securePath('');
|
||||
}
|
||||
|
||||
async stop() {
|
||||
|
@ -242,7 +242,7 @@ async function launchDockerContainer(): Promise<() => Promise<void>> {
|
||||
const { error } = await gridServer.createAgent();
|
||||
if (error)
|
||||
throw error;
|
||||
process.env.PW_GRID = gridServer.urlPrefix().substring(0, gridServer.urlPrefix().length - 1);
|
||||
process.env.PW_GRID = gridServer.gridURL();
|
||||
return async () => await gridServer.stop();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user