Skip to content

Commit 3cb3c72

Browse files
committed
clean up constructor calls for server lifecycle
1 parent eed3b22 commit 3cb3c72

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

src/scenarios/client/auth/basic-dcr.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@ export class AuthBasicDCRScenario implements Scenario {
99
name = 'auth/basic-dcr';
1010
description =
1111
'Tests Basic OAuth flow with DCR, PRM at path-based location, OAuth metadata at root location, and no scopes required';
12-
private authServer = new ServerLifecycle(() => this.authBaseUrl);
13-
private server = new ServerLifecycle(() => this.baseUrl);
12+
private authServer = new ServerLifecycle();
13+
private server = new ServerLifecycle();
1414
private checks: ConformanceCheck[] = [];
15-
private baseUrl: string = '';
16-
private authBaseUrl: string = '';
1715

1816
async start(): Promise<ScenarioUrls> {
1917
this.checks = [];
2018

21-
const authApp = createAuthServer(this.checks, () => this.authBaseUrl);
22-
this.authBaseUrl = await this.authServer.start(authApp);
19+
const authApp = createAuthServer(this.checks, this.authServer.getUrl);
20+
await this.authServer.start(authApp);
2321

2422
const app = createServer(
2523
this.checks,
26-
() => this.baseUrl,
27-
() => this.authBaseUrl
24+
this.server.getUrl,
25+
this.authServer.getUrl
2826
);
2927

3028
// For this scenario, reject PRM requests at root location since we have the path-based PRM.
@@ -58,9 +56,9 @@ export class AuthBasicDCRScenario implements Scenario {
5856
}
5957
);
6058

61-
this.baseUrl = await this.server.start(app);
59+
await this.server.start(app);
6260

63-
return { serverUrl: `${this.baseUrl}/mcp` };
61+
return { serverUrl: `${this.server.getUrl()}/mcp` };
6462
}
6563

6664
async stop() {

src/scenarios/client/auth/basic-metadata-var1.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@ export class AuthBasicMetadataVar1Scenario implements Scenario {
99
name = 'auth/basic-metadata-var1';
1010
description =
1111
'Tests Basic OAuth flow with DCR, PRM at root location, OAuth metadata at OpenID discovery path, and no scopes required';
12-
private authServer = new ServerLifecycle(() => this.authBaseUrl);
13-
private server = new ServerLifecycle(() => this.baseUrl);
12+
private authServer = new ServerLifecycle();
13+
private server = new ServerLifecycle();
1414
private checks: ConformanceCheck[] = [];
15-
private baseUrl: string = '';
16-
private authBaseUrl: string = '';
1715

1816
async start(): Promise<ScenarioUrls> {
1917
this.checks = [];
2018

21-
const authApp = createAuthServer(this.checks, () => this.authBaseUrl, {
19+
const authApp = createAuthServer(this.checks, this.authServer.getUrl, {
2220
metadataPath: '/.well-known/openid-configuration',
2321
isOpenIdConfiguration: true
2422
});
25-
this.authBaseUrl = await this.authServer.start(authApp);
23+
await this.authServer.start(authApp);
2624

2725
const app = createServer(
2826
this.checks,
29-
() => this.baseUrl,
30-
() => this.authBaseUrl,
27+
this.server.getUrl,
28+
this.authServer.getUrl,
3129
{
3230
// TODO: this will put this path in the WWW-Authenticate header
3331
// but RFC 9728 states that in that case, the resource in the PRM
@@ -38,9 +36,9 @@ export class AuthBasicMetadataVar1Scenario implements Scenario {
3836
prmPath: '/.well-known/oauth-protected-resource'
3937
}
4038
);
41-
this.baseUrl = await this.server.start(app);
39+
await this.server.start(app);
4240

43-
return { serverUrl: `${this.baseUrl}/mcp` };
41+
return { serverUrl: `${this.server.getUrl()}/mcp` };
4442
}
4543

4644
async stop() {

src/scenarios/client/auth/helpers/serverLifecycle.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ export class ServerLifecycle {
55
private httpServer: any = null;
66
private baseUrl: string = '';
77

8-
constructor(private getBaseUrl: () => string) {}
9-
108
async start(app: express.Application): Promise<string> {
119
this.app = app;
1210
this.httpServer = this.app.listen(0);

0 commit comments

Comments
 (0)