feat: scenario option for authorization server test (#227)
This commit is contained in:
parent
38c4852d8c
commit
fa96f3aca1
1 changed files with 216 additions and 3 deletions
|
|
@ -2,7 +2,7 @@ import { promises as fs } from 'fs';
|
|||
import path from 'path';
|
||||
import { ConformanceCheck } from '../types';
|
||||
import { getClientScenarioForAuthorizationServer } from '../scenarios';
|
||||
import { createResultDir } from './utils';
|
||||
import { createResultDir, formatPrettyChecks } from './utils';
|
||||
|
||||
export async function runAuthorizationServerConformanceTest(
|
||||
serverUrl: string,
|
||||
|
|
@ -49,6 +49,49 @@ export async function runAuthorizationServerConformanceTest(
|
|||
};
|
||||
}
|
||||
|
||||
export function printAuthorizationServerResults(
|
||||
checks: ConformanceCheck[],
|
||||
scenarioDescription: string,
|
||||
verbose: boolean = false
|
||||
): {
|
||||
passed: number;
|
||||
failed: number;
|
||||
denominator: number;
|
||||
warnings: number;
|
||||
} {
|
||||
const denominator = checks.filter(
|
||||
(c) => c.status === 'SUCCESS' || c.status === 'FAILURE'
|
||||
).length;
|
||||
const passed = checks.filter((c) => c.status === 'SUCCESS').length;
|
||||
const failed = checks.filter((c) => c.status === 'FAILURE').length;
|
||||
const warnings = checks.filter((c) => c.status === 'WARNING').length;
|
||||
|
||||
if (verbose) {
|
||||
console.log(JSON.stringify(checks, null, 2));
|
||||
} else {
|
||||
console.log(`Checks:\n${formatPrettyChecks(checks)}`);
|
||||
}
|
||||
|
||||
console.log(`\nTest Results:`);
|
||||
console.log(
|
||||
`Passed: ${passed}/${denominator}, ${failed} failed, ${warnings} warnings`
|
||||
);
|
||||
|
||||
if (failed > 0) {
|
||||
console.log('\n=== Failed Checks ===');
|
||||
checks
|
||||
.filter((c) => c.status === 'FAILURE')
|
||||
.forEach((c) => {
|
||||
console.log(`\n - ${c.name}: ${c.description}`);
|
||||
if (c.errorMessage) {
|
||||
console.log(` Error: ${c.errorMessage}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { passed, failed, denominator, warnings };
|
||||
}
|
||||
|
||||
export function printAuthorizationServerSummary(
|
||||
allResults: { scenario: string; checks: ConformanceCheck[] }[]
|
||||
): { totalPassed: number; totalFailed: number } {
|
||||
|
|
|
|||
Loading…
Reference in a new issue