fixes for oauth spec - adds github oauth support. Resource paramater. (#6281)

This commit is contained in:
Brian Ray
2025-08-15 15:14:48 -04:00
committed by GitHub
parent 01b8a7565c
commit 2c07dc0757
5 changed files with 557 additions and 173 deletions

View File

@@ -28,8 +28,8 @@ describe('OAuthUtils', () => {
});
describe('buildWellKnownUrls', () => {
it('should build correct well-known URLs', () => {
const urls = OAuthUtils.buildWellKnownUrls('https://example.com/path');
it('should build standard root-based URLs by default', () => {
const urls = OAuthUtils.buildWellKnownUrls('https://example.com/mcp');
expect(urls.protectedResource).toBe(
'https://example.com/.well-known/oauth-protected-resource',
);
@@ -37,6 +37,42 @@ describe('OAuthUtils', () => {
'https://example.com/.well-known/oauth-authorization-server',
);
});
it('should build path-based URLs when includePathSuffix is true', () => {
const urls = OAuthUtils.buildWellKnownUrls(
'https://example.com/mcp',
true,
);
expect(urls.protectedResource).toBe(
'https://example.com/.well-known/oauth-protected-resource/mcp',
);
expect(urls.authorizationServer).toBe(
'https://example.com/.well-known/oauth-authorization-server/mcp',
);
});
it('should handle root path correctly', () => {
const urls = OAuthUtils.buildWellKnownUrls('https://example.com', true);
expect(urls.protectedResource).toBe(
'https://example.com/.well-known/oauth-protected-resource',
);
expect(urls.authorizationServer).toBe(
'https://example.com/.well-known/oauth-authorization-server',
);
});
it('should handle trailing slash in path', () => {
const urls = OAuthUtils.buildWellKnownUrls(
'https://example.com/mcp/',
true,
);
expect(urls.protectedResource).toBe(
'https://example.com/.well-known/oauth-protected-resource/mcp',
);
expect(urls.authorizationServer).toBe(
'https://example.com/.well-known/oauth-authorization-server/mcp',
);
});
});
describe('fetchProtectedResourceMetadata', () => {