Skip to content

Commit 68424ef

Browse files
committed
simplify changes
1 parent 4fcbb68 commit 68424ef

File tree

3 files changed

+1
-298
lines changed

3 files changed

+1
-298
lines changed

src/client/auth.test.ts

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,6 @@ describe("OAuth Authorization", () => {
354354
expect(authorizationUrl.searchParams.get("resource")).toBe("https://api.example.com/mcp-server");
355355
});
356356

357-
it("excludes resource parameter when not provided", async () => {
358-
const { authorizationUrl } = await startAuthorization(
359-
"https://auth.example.com",
360-
{
361-
clientInformation: validClientInfo,
362-
redirectUrl: "http://localhost:3000/callback",
363-
}
364-
);
365-
366-
expect(authorizationUrl.searchParams.has("resource")).toBe(false);
367-
});
368-
369357
it("includes scope parameter when provided", async () => {
370358
const { authorizationUrl } = await startAuthorization(
371359
"https://auth.example.com",
@@ -535,24 +523,6 @@ describe("OAuth Authorization", () => {
535523
expect(body.get("resource")).toBe("https://api.example.com/mcp-server");
536524
});
537525

538-
it("excludes resource parameter from token exchange when not provided", async () => {
539-
mockFetch.mockResolvedValueOnce({
540-
ok: true,
541-
status: 200,
542-
json: async () => validTokens,
543-
});
544-
545-
await exchangeAuthorization("https://auth.example.com", {
546-
clientInformation: validClientInfo,
547-
authorizationCode: "code123",
548-
codeVerifier: "verifier123",
549-
redirectUri: "http://localhost:3000/callback",
550-
});
551-
552-
const body = mockFetch.mock.calls[0][1].body as URLSearchParams;
553-
expect(body.has("resource")).toBe(false);
554-
});
555-
556526
it("validates token response schema", async () => {
557527
mockFetch.mockResolvedValueOnce({
558528
ok: true,
@@ -659,22 +629,6 @@ describe("OAuth Authorization", () => {
659629
expect(body.get("resource")).toBe("https://api.example.com/mcp-server");
660630
});
661631

662-
it("excludes resource parameter from refresh token request when not provided", async () => {
663-
mockFetch.mockResolvedValueOnce({
664-
ok: true,
665-
status: 200,
666-
json: async () => validTokensWithNewRefreshToken,
667-
});
668-
669-
await refreshAuthorization("https://auth.example.com", {
670-
clientInformation: validClientInfo,
671-
refreshToken: "refresh123",
672-
});
673-
674-
const body = mockFetch.mock.calls[0][1].body as URLSearchParams;
675-
expect(body.has("resource")).toBe(false);
676-
});
677-
678632
it("exchanges refresh token for new tokens and keep existing refresh token if none is returned", async () => {
679633
mockFetch.mockResolvedValueOnce({
680634
ok: true,
@@ -1136,47 +1090,5 @@ describe("OAuth Authorization", () => {
11361090
// Verify that the two resources are different (critical for security)
11371091
expect(authUrl1.searchParams.get("resource")).not.toBe(authUrl2.searchParams.get("resource"));
11381092
});
1139-
1140-
it("preserves query parameters in resource URI", async () => {
1141-
// Mock successful metadata discovery
1142-
mockFetch.mockImplementation((url) => {
1143-
const urlString = url.toString();
1144-
if (urlString.includes("/.well-known/oauth-authorization-server")) {
1145-
return Promise.resolve({
1146-
ok: true,
1147-
status: 200,
1148-
json: async () => ({
1149-
issuer: "https://auth.example.com",
1150-
authorization_endpoint: "https://auth.example.com/authorize",
1151-
token_endpoint: "https://auth.example.com/token",
1152-
response_types_supported: ["code"],
1153-
code_challenge_methods_supported: ["S256"],
1154-
}),
1155-
});
1156-
}
1157-
return Promise.resolve({ ok: false, status: 404 });
1158-
});
1159-
1160-
// Mock provider methods
1161-
(mockProvider.clientInformation as jest.Mock).mockResolvedValue({
1162-
client_id: "test-client",
1163-
client_secret: "test-secret",
1164-
});
1165-
(mockProvider.tokens as jest.Mock).mockResolvedValue(undefined);
1166-
(mockProvider.saveCodeVerifier as jest.Mock).mockResolvedValue(undefined);
1167-
(mockProvider.redirectToAuthorization as jest.Mock).mockResolvedValue(undefined);
1168-
1169-
// Call auth with resource containing query parameters
1170-
const result = await auth(mockProvider, {
1171-
serverUrl: "https://api.example.com/mcp-server?param=value&another=test",
1172-
});
1173-
1174-
expect(result).toBe("REDIRECT");
1175-
1176-
// Verify query parameters are preserved (only fragment is removed)
1177-
const redirectCall = (mockProvider.redirectToAuthorization as jest.Mock).mock.calls[0];
1178-
const authUrl: URL = redirectCall[0];
1179-
expect(authUrl.searchParams.get("resource")).toBe("https://api.example.com/mcp-server?param=value&another=test");
1180-
});
11811093
});
11821094
});

src/examples/server/demoInMemoryOAuthProvider.test.ts

Lines changed: 0 additions & 200 deletions
This file was deleted.

src/examples/server/demoInMemoryOAuthProvider.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ export class DemoInMemoryAuthProvider implements OAuthServerProvider {
150150
resource: tokenData.resource,
151151
};
152152
}
153-
154-
/**
155-
* Get token details including resource information (for demo introspection endpoint)
156-
*/
157-
getTokenDetails(token: string): AuthInfo | undefined {
158-
return this.tokens.get(token);
159-
}
160153
}
161154

162155

@@ -190,14 +183,12 @@ export const setupAuthServer = (authServerUrl: URL, mcpServerUrl: URL): OAuthMet
190183
}
191184

192185
const tokenInfo = await provider.verifyAccessToken(token);
193-
// For demo purposes, we'll add a method to get token details
194-
const tokenDetails = provider.getTokenDetails(token);
195186
res.json({
196187
active: true,
197188
client_id: tokenInfo.clientId,
198189
scope: tokenInfo.scopes.join(' '),
199190
exp: tokenInfo.expiresAt,
200-
...(tokenDetails?.resource && { aud: tokenDetails.resource })
191+
aud: tokenInfo.resource,
201192
});
202193
return
203194
} catch (error) {

0 commit comments

Comments
 (0)