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;
|
factory.name = factory.name || factoryPathOrPackageName;
|
||||||
const gridServer = new GridServer(factory as GridFactory, authToken, address);
|
const gridServer = new GridServer(factory as GridFactory, authToken, address);
|
||||||
await gridServer.start(port);
|
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 {
|
function buildBasePlaywrightCLICommand(cliTargetLang: string | undefined): string {
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,8 @@ export class GridServer {
|
||||||
return true;
|
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 params = new URL('http://localhost/' + request.url).searchParams;
|
||||||
const agentId = params.get('agentId');
|
const agentId = params.get('agentId');
|
||||||
return !!agentId && this._agents.has(agentId);
|
return !!agentId && this._agents.has(agentId);
|
||||||
|
|
@ -285,7 +286,7 @@ export class GridServer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.url?.startsWith('/registerAgent')) {
|
if (request.url?.startsWith(this._securePath('/registerAgent'))) {
|
||||||
const params = new URL('http://localhost/' + request.url).searchParams;
|
const params = new URL('http://localhost/' + request.url).searchParams;
|
||||||
if (params.get('pwVersion') !== this._pwVersion) {
|
if (params.get('pwVersion') !== this._pwVersion) {
|
||||||
ws.close(WSErrors.AGENT_PLAYWRIGHT_VERSION_MISMATCH.code, WSErrors.AGENT_PLAYWRIGHT_VERSION_MISMATCH.reason);
|
ws.close(WSErrors.AGENT_PLAYWRIGHT_VERSION_MISMATCH.code, WSErrors.AGENT_PLAYWRIGHT_VERSION_MISMATCH.reason);
|
||||||
|
|
@ -302,7 +303,7 @@ export class GridServer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.url?.startsWith('/registerWorker')) {
|
if (request.url?.startsWith(this._securePath('/registerWorker'))) {
|
||||||
const params = new URL('http://localhost/' + request.url).searchParams;
|
const params = new URL('http://localhost/' + request.url).searchParams;
|
||||||
const agentId = params.get('agentId')!;
|
const agentId = params.get('agentId')!;
|
||||||
const workerId = params.get('workerId')!;
|
const workerId = params.get('workerId')!;
|
||||||
|
|
@ -332,7 +333,7 @@ export class GridServer {
|
||||||
const initPromise = Promise.resolve()
|
const initPromise = Promise.resolve()
|
||||||
.then(() => this._factory.launch({
|
.then(() => this._factory.launch({
|
||||||
agentId: agent.agentId,
|
agentId: agent.agentId,
|
||||||
gridURL: this.urlPrefix(),
|
gridURL: this.gridURL(),
|
||||||
playwrightVersion: getPlaywrightVersion(),
|
playwrightVersion: getPlaywrightVersion(),
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
this._log('created');
|
this._log('created');
|
||||||
|
|
@ -386,8 +387,8 @@ export class GridServer {
|
||||||
await this._server.start(port);
|
await this._server.start(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
urlPrefix(): string {
|
gridURL(): string {
|
||||||
return this._server.urlPrefix() + this._securePath('/');
|
return this._server.urlPrefix() + this._securePath('');
|
||||||
}
|
}
|
||||||
|
|
||||||
async stop() {
|
async stop() {
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ async function launchDockerContainer(): Promise<() => Promise<void>> {
|
||||||
const { error } = await gridServer.createAgent();
|
const { error } = await gridServer.createAgent();
|
||||||
if (error)
|
if (error)
|
||||||
throw 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();
|
return async () => await gridServer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue