summaryrefslogtreecommitdiff
path: root/packages/core/src/mcp/oauth-utils.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/mcp/oauth-utils.test.ts')
-rw-r--r--packages/core/src/mcp/oauth-utils.test.ts40
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', () => {