Do not force that a connection token CLI argument is present

This commit is contained in:
Alex Dima
2022-01-24 13:59:56 +01:00
parent f1cdd2bcf4
commit 81ad1f968d
3 changed files with 6 additions and 5 deletions

View File

@@ -104,5 +104,5 @@ export function parseServerConnectionToken(args: ServerParsedArgs): ServerConnec
return new OptionalServerConnectionToken(generateUuid());
}
return new ServerConnectionTokenParseError(`Please use one of the following arguments: '--connection-token', '--connection-token-file' or '--without-connection-token'.`);
return new MandatoryServerConnectionToken(generateUuid());
}

View File

@@ -21,8 +21,10 @@ suite('parseServerConnectionToken', () => {
assert.strictEqual(isError(r), true);
}
test('no arguments results in error', () => {
assertIsError(parseServerConnectionToken({} as ServerParsedArgs));
test('no arguments generates a token that is mandatory', () => {
const result = parseServerConnectionToken({} as ServerParsedArgs);
assert.ok(!(result instanceof ServerConnectionTokenParseError));
assert.ok(result.type === ServerConnectionTokenType.Mandatory);
});
test('no arguments with --compatibility generates a token that is not mandatory', () => {

View File

@@ -14,7 +14,6 @@ import * as kill from 'tree-kill';
import { PageFunction } from 'playwright-core/types/structs';
import { Logger, measureAndLog } from './logger';
import type { LaunchOptions } from './code';
import * as crypto from 'crypto';
const width = 1200;
const height = 800;
@@ -225,7 +224,7 @@ async function launchServer(options: LaunchOptions) {
...process.env
};
const args = ['--connection-token', String(crypto.randomInt(0xffffffff)), '--disable-telemetry', '--port', `${port++}`, '--driver', 'web', '--extensions-dir', extensionsPath, '--server-data-dir', agentFolder];
const args = ['--disable-telemetry', '--port', `${port++}`, '--driver', 'web', '--extensions-dir', extensionsPath, '--server-data-dir', agentFolder];
let serverLocation: string | undefined;
if (codeServerPath) {