diff options
| author | Brian Ray <[email protected]> | 2025-08-15 15:14:48 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-15 19:14:48 +0000 |
| commit | 2c07dc0757867a138b3832d781457ecf5d9afcf7 (patch) | |
| tree | 1d46ae2cfae9105c4efe18752dec62ca35fa27fc /packages/core/src/mcp/oauth-utils.test.ts | |
| parent | 01b8a7565cb419f906817507f6e788e14d6f8aae (diff) | |
fixes for oauth spec - adds github oauth support. Resource paramater. (#6281)
Diffstat (limited to 'packages/core/src/mcp/oauth-utils.test.ts')
| -rw-r--r-- | packages/core/src/mcp/oauth-utils.test.ts | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/packages/core/src/mcp/oauth-utils.test.ts b/packages/core/src/mcp/oauth-utils.test.ts index 12871ff2..47bfb9ae 100644 --- a/packages/core/src/mcp/oauth-utils.test.ts +++ b/packages/core/src/mcp/oauth-utils.test.ts @@ -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', () => { |
