Skip to content

Commit 0adab5f

Browse files
committed
move around
1 parent 05ea16a commit 0adab5f

File tree

4 files changed

+14
-332
lines changed

4 files changed

+14
-332
lines changed

auth-compat/src/cli/index.ts

Lines changed: 3 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { Command } from 'commander';
44
import { ComplianceTestRunner, TestSuite } from '../test-framework/index.js';
5+
import { basicSuite, behaviorSuite, metadataLocationSuite, oauthSuite } from '../test-framework/suites.js';
56

67
const program = new Command();
78

@@ -16,119 +17,10 @@ program
1617
.option('--timeout <ms>', 'Timeout for client execution in milliseconds', '30000')
1718
.option('--json', 'Output results as JSON', false)
1819
.option('--verbose', 'Verbose output', false)
19-
.action(async (clientCommand: string, options) => {
20-
await runTests(clientCommand, options);
20+
.action(async (options) => {
21+
await runTests(options);
2122
});
2223

23-
// Test suite definitions
24-
const basicSuite: TestSuite = {
25-
name: 'Basic Compliance',
26-
description: 'Tests basic MCP protocol compliance without authentication',
27-
scenarios: [
28-
{
29-
name: 'Basic MCP Connection',
30-
description: 'Client can connect and list tools without auth',
31-
serverConfig: {
32-
authRequired: false
33-
},
34-
expectedResult: 'PASS'
35-
}
36-
]
37-
};
38-
39-
const oauthSuite: TestSuite = {
40-
name: 'OAuth Compliance',
41-
description: 'Tests OAuth2/OIDC authorization flow',
42-
scenarios: [
43-
{
44-
name: 'Standard OAuth Flow',
45-
description: 'Client completes OAuth flow with default settings',
46-
serverConfig: {
47-
authRequired: true
48-
},
49-
expectedResult: 'PASS'
50-
}
51-
]
52-
};
53-
54-
const metadataLocationSuite: TestSuite = {
55-
name: 'Metadata Location Tests',
56-
description: 'Tests different OAuth protected resource metadata locations',
57-
scenarios: [
58-
{
59-
name: 'Standard location with WWW-Authenticate',
60-
serverConfig: {
61-
authRequired: true,
62-
metadataLocation: '/.well-known/oauth-protected-resource',
63-
includeWwwAuthenticate: true
64-
},
65-
expectedResult: 'PASS'
66-
},
67-
{
68-
name: 'Non-standard location with WWW-Authenticate',
69-
description: 'Custom metadata path advertised via WWW-Authenticate header',
70-
serverConfig: {
71-
authRequired: true,
72-
metadataLocation: '/custom/oauth/metadata',
73-
includeWwwAuthenticate: true
74-
},
75-
expectedResult: 'PASS'
76-
},
77-
{
78-
name: 'Nested well-known path with WWW-Authenticate',
79-
serverConfig: {
80-
authRequired: true,
81-
metadataLocation: '/.well-known/oauth-protected-resource/mcp',
82-
includeWwwAuthenticate: true
83-
},
84-
expectedResult: 'PASS'
85-
},
86-
{
87-
name: 'Standard location without WWW-Authenticate',
88-
description: 'Client should find metadata at standard location',
89-
serverConfig: {
90-
authRequired: true,
91-
metadataLocation: '/.well-known/oauth-protected-resource',
92-
includeWwwAuthenticate: false
93-
},
94-
expectedResult: 'PASS'
95-
},
96-
{
97-
name: 'Non-standard location without WWW-Authenticate',
98-
description: 'Client cannot find metadata without header hint',
99-
serverConfig: {
100-
authRequired: true,
101-
metadataLocation: '/custom/oauth/metadata',
102-
includeWwwAuthenticate: false
103-
},
104-
expectedResult: 'FAIL' // Should fail - client won't find non-standard location
105-
}
106-
]
107-
};
108-
109-
const behaviorSuite: TestSuite = {
110-
name: 'Client Behavior Validation',
111-
description: 'Tests specific client behaviors',
112-
scenarios: [
113-
{
114-
name: 'Client requests metadata',
115-
serverConfig: {
116-
authRequired: true
117-
},
118-
expectedResult: 'PASS',
119-
validateBehavior: (behavior) => {
120-
const errors = [];
121-
if (!behavior.authMetadataRequested) {
122-
errors.push('Client did not request OAuth metadata');
123-
}
124-
if (!behavior.initialized) {
125-
errors.push('Client did not complete initialization');
126-
}
127-
return errors;
128-
}
129-
}
130-
]
131-
};
13224

13325
async function runTests(options: any) {
13426
const verbose = options.verbose;

auth-compat/src/test-framework/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class ComplianceTestRunner {
8787
}, timeout);
8888

8989
clientProcess.on('exit', (code) => {
90+
console.log(`EXIT CODE: ${code}`);
9091
clearTimeout(timeoutHandle);
9192
if (!timedOut) {
9293
resolve(code || 0);
@@ -113,6 +114,8 @@ export class ComplianceTestRunner {
113114
}
114115

115116
// Generate report
117+
console.log(`EXIT CODE: ${clientExitCode}`);
118+
116119
const report: ComplianceReport = {
117120
overall_result: results.every(r => r.result === 'PASS') &&
118121
clientExitCode === 0 &&
@@ -186,7 +189,6 @@ export class ComplianceTestRunner {
186189
this.log('\n' + '='.repeat(60));
187190
this.log(`Suite Summary: ${suite.name}`);
188191
this.log(` Passed: ${passed}/${results.length}`);
189-
this.log(` Failed: ${failed}/${results.length}`);
190192

191193
return failed === 0;
192194
}
@@ -206,7 +208,6 @@ export class ComplianceTestRunner {
206208
this.log('OVERALL SUMMARY');
207209
this.log('='.repeat(60));
208210
this.log(`Total Suites Passed: ${totalSuitesPassed}/${allResults.length}`);
209-
this.log(`Total Suites Failed: ${totalSuitesFailed}/${allResults.length}`);
210211

211212
if (totalSuitesFailed === 0) {
212213
this.log('\n✅ All test suites passed!');
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env npx tsx
1+
import { TestSuite } from ".";
22

3-
import { ComplianceTestRunner, TestSuite } from '../src/test-framework/index.js';
43

5-
// Basic compliance tests
6-
const basicSuite: TestSuite = {
4+
5+
// Test suite definitions
6+
export const basicSuite: TestSuite = {
77
name: 'Basic Compliance',
88
description: 'Tests basic MCP protocol compliance without authentication',
99
scenarios: [
@@ -13,14 +13,12 @@ const basicSuite: TestSuite = {
1313
serverConfig: {
1414
authRequired: false
1515
},
16-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
1716
expectedResult: 'PASS'
1817
}
1918
]
2019
};
2120

22-
// OAuth compliance tests
23-
const oauthSuite: TestSuite = {
21+
export const oauthSuite: TestSuite = {
2422
name: 'OAuth Compliance',
2523
description: 'Tests OAuth2/OIDC authorization flow',
2624
scenarios: [
@@ -30,14 +28,12 @@ const oauthSuite: TestSuite = {
3028
serverConfig: {
3129
authRequired: true
3230
},
33-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
3431
expectedResult: 'PASS'
3532
}
3633
]
3734
};
3835

39-
// Metadata location tests
40-
const metadataLocationSuite: TestSuite = {
36+
export const metadataLocationSuite: TestSuite = {
4137
name: 'Metadata Location Tests',
4238
description: 'Tests different OAuth protected resource metadata locations',
4339
scenarios: [
@@ -48,7 +44,6 @@ const metadataLocationSuite: TestSuite = {
4844
metadataLocation: '/.well-known/oauth-protected-resource',
4945
includeWwwAuthenticate: true
5046
},
51-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
5247
expectedResult: 'PASS'
5348
},
5449
{
@@ -59,7 +54,6 @@ const metadataLocationSuite: TestSuite = {
5954
metadataLocation: '/custom/oauth/metadata',
6055
includeWwwAuthenticate: true
6156
},
62-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
6357
expectedResult: 'PASS'
6458
},
6559
{
@@ -69,7 +63,6 @@ const metadataLocationSuite: TestSuite = {
6963
metadataLocation: '/.well-known/oauth-protected-resource/mcp',
7064
includeWwwAuthenticate: true
7165
},
72-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
7366
expectedResult: 'PASS'
7467
},
7568
{
@@ -80,7 +73,6 @@ const metadataLocationSuite: TestSuite = {
8073
metadataLocation: '/.well-known/oauth-protected-resource',
8174
includeWwwAuthenticate: false
8275
},
83-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
8476
expectedResult: 'PASS'
8577
},
8678
{
@@ -91,14 +83,13 @@ const metadataLocationSuite: TestSuite = {
9183
metadataLocation: '/custom/oauth/metadata',
9284
includeWwwAuthenticate: false
9385
},
94-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
9586
expectedResult: 'FAIL' // Should fail - client won't find non-standard location
9687
}
9788
]
9889
};
9990

100-
// Behavior validation tests
101-
const behaviorSuite: TestSuite = {
91+
// TODO: this is busted
92+
export const behaviorSuite: TestSuite = {
10293
name: 'Client Behavior Validation',
10394
description: 'Tests specific client behaviors',
10495
scenarios: [
@@ -107,7 +98,6 @@ const behaviorSuite: TestSuite = {
10798
serverConfig: {
10899
authRequired: true
109100
},
110-
clientCommand: 'npx tsx examples/typescript-client/test-client.ts',
111101
expectedResult: 'PASS',
112102
validateBehavior: (behavior) => {
113103
const errors = [];
@@ -122,47 +112,3 @@ const behaviorSuite: TestSuite = {
122112
}
123113
]
124114
};
125-
126-
// Main test runner
127-
async function main() {
128-
const args = process.argv.slice(2);
129-
const verbose = args.includes('--verbose') || args.includes('-v');
130-
const json = args.includes('--json');
131-
const suite = args.find(arg => arg.startsWith('--suite='))?.split('=')[1];
132-
133-
const runner = new ComplianceTestRunner({ verbose, json });
134-
135-
// Select which suites to run
136-
let suitesToRun: TestSuite[] = [];
137-
138-
if (suite) {
139-
// Run specific suite
140-
const suiteMap: Record<string, TestSuite> = {
141-
'basic': basicSuite,
142-
'oauth': oauthSuite,
143-
'metadata': metadataLocationSuite,
144-
'behavior': behaviorSuite
145-
};
146-
147-
if (suiteMap[suite]) {
148-
suitesToRun = [suiteMap[suite]];
149-
} else {
150-
console.error(`Unknown suite: ${suite}`);
151-
console.error(`Available suites: ${Object.keys(suiteMap).join(', ')}`);
152-
process.exit(1);
153-
}
154-
} else {
155-
// Run all suites
156-
suitesToRun = [basicSuite, oauthSuite, metadataLocationSuite, behaviorSuite];
157-
}
158-
159-
console.log('MCP Authorization Compliance Test Suite');
160-
console.log('=' .repeat(60));
161-
162-
await runner.runSuites(suitesToRun);
163-
}
164-
165-
main().catch((error) => {
166-
console.error('Test runner error:', error);
167-
process.exit(1);
168-
});

0 commit comments

Comments
 (0)