Add allowClientError to Scenario interface for expected client failures (#123)
* Add allowClientError to Scenario interface for expected client failures * Apply suggestion from @pcarleton Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com> --------- Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
This commit is contained in:
parent
c2f3fdaf78
commit
0064ea0c95
5 changed files with 19 additions and 5 deletions
|
|
@ -207,7 +207,8 @@ program
|
||||||
const { overallFailure } = printClientResults(
|
const { overallFailure } = printClientResults(
|
||||||
result.checks,
|
result.checks,
|
||||||
verbose,
|
verbose,
|
||||||
result.clientOutput
|
result.clientOutput,
|
||||||
|
result.allowClientError
|
||||||
);
|
);
|
||||||
|
|
||||||
if (options.expectedFailures) {
|
if (options.expectedFailures) {
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ export async function runConformanceTest(
|
||||||
checks: ConformanceCheck[];
|
checks: ConformanceCheck[];
|
||||||
clientOutput: ClientExecutionResult;
|
clientOutput: ClientExecutionResult;
|
||||||
resultDir?: string;
|
resultDir?: string;
|
||||||
|
allowClientError?: boolean;
|
||||||
}> {
|
}> {
|
||||||
let resultDir: string | undefined;
|
let resultDir: string | undefined;
|
||||||
|
|
||||||
|
|
@ -164,7 +165,8 @@ export async function runConformanceTest(
|
||||||
return {
|
return {
|
||||||
checks,
|
checks,
|
||||||
clientOutput,
|
clientOutput,
|
||||||
resultDir
|
resultDir,
|
||||||
|
allowClientError: scenario.allowClientError
|
||||||
};
|
};
|
||||||
} finally {
|
} finally {
|
||||||
await scenario.stop();
|
await scenario.stop();
|
||||||
|
|
@ -174,7 +176,8 @@ export async function runConformanceTest(
|
||||||
export function printClientResults(
|
export function printClientResults(
|
||||||
checks: ConformanceCheck[],
|
checks: ConformanceCheck[],
|
||||||
verbose: boolean = false,
|
verbose: boolean = false,
|
||||||
clientOutput?: ClientExecutionResult
|
clientOutput?: ClientExecutionResult,
|
||||||
|
allowClientError: boolean = false
|
||||||
): {
|
): {
|
||||||
passed: number;
|
passed: number;
|
||||||
failed: number;
|
failed: number;
|
||||||
|
|
@ -195,7 +198,10 @@ export function printClientResults(
|
||||||
? clientOutput.exitCode !== 0
|
? clientOutput.exitCode !== 0
|
||||||
: false;
|
: false;
|
||||||
const overallFailure =
|
const overallFailure =
|
||||||
failed > 0 || warnings > 0 || clientTimedOut || clientExitedWithError;
|
failed > 0 ||
|
||||||
|
warnings > 0 ||
|
||||||
|
clientTimedOut ||
|
||||||
|
(clientExitedWithError && !allowClientError);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
// Verbose mode: JSON goes to stdout for piping to jq/jless
|
// Verbose mode: JSON goes to stdout for piping to jq/jless
|
||||||
|
|
@ -215,7 +221,7 @@ export function printClientResults(
|
||||||
console.error(`\n⚠️ CLIENT TIMED OUT - Test incomplete`);
|
console.error(`\n⚠️ CLIENT TIMED OUT - Test incomplete`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientExitedWithError && !clientTimedOut) {
|
if (clientExitedWithError && !clientTimedOut && !allowClientError) {
|
||||||
console.error(
|
console.error(
|
||||||
`\n⚠️ CLIENT EXITED WITH ERROR (code ${clientOutput?.exitCode}) - Test may be incomplete`
|
`\n⚠️ CLIENT EXITED WITH ERROR (code ${clientOutput?.exitCode}) - Test may be incomplete`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ export class ResourceMismatchScenario implements Scenario {
|
||||||
name = 'auth/resource-mismatch';
|
name = 'auth/resource-mismatch';
|
||||||
description =
|
description =
|
||||||
'Tests that client rejects when PRM resource does not match server URL';
|
'Tests that client rejects when PRM resource does not match server URL';
|
||||||
|
allowClientError = true;
|
||||||
|
|
||||||
private authServer = new ServerLifecycle();
|
private authServer = new ServerLifecycle();
|
||||||
private server = new ServerLifecycle();
|
private server = new ServerLifecycle();
|
||||||
|
|
|
||||||
|
|
@ -479,6 +479,7 @@ export class ScopeRetryLimitScenario implements Scenario {
|
||||||
name = 'auth/scope-retry-limit';
|
name = 'auth/scope-retry-limit';
|
||||||
description =
|
description =
|
||||||
'Tests that client implements retry limits to prevent infinite authorization loops on repeated 403 responses';
|
'Tests that client implements retry limits to prevent infinite authorization loops on repeated 403 responses';
|
||||||
|
allowClientError = true;
|
||||||
private authServer = new ServerLifecycle();
|
private authServer = new ServerLifecycle();
|
||||||
private server = new ServerLifecycle();
|
private server = new ServerLifecycle();
|
||||||
private checks: ConformanceCheck[] = [];
|
private checks: ConformanceCheck[] = [];
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ export interface ScenarioUrls {
|
||||||
export interface Scenario {
|
export interface Scenario {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
/**
|
||||||
|
* If true, a non-zero client exit code is expected and will not cause the test to fail.
|
||||||
|
* Use this for scenarios where the client is expected to error (e.g., rejecting invalid auth).
|
||||||
|
*/
|
||||||
|
allowClientError?: boolean;
|
||||||
start(): Promise<ScenarioUrls>;
|
start(): Promise<ScenarioUrls>;
|
||||||
stop(): Promise<void>;
|
stop(): Promise<void>;
|
||||||
getChecks(): ConformanceCheck[];
|
getChecks(): ConformanceCheck[];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue