|
|
@ -1,8 +1,10 @@ |
|
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
|
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
|
|
|
getMcpAuthorizationServerMetadata, |
|
|
getMcpOAuthBaseUrl, |
|
|
getMcpOAuthBaseUrl, |
|
|
getMcpProtectedResourceMetadataUrl, |
|
|
getMcpProtectedResourceMetadataUrl, |
|
|
|
|
|
getMcpResourceUrl, |
|
|
isMcpOAuthEnabled |
|
|
isMcpOAuthEnabled |
|
|
} from './mcp-oauth.helper'; |
|
|
} from './mcp-oauth.helper'; |
|
|
|
|
|
|
|
|
@ -24,6 +26,23 @@ describe('mcp-oauth.helper', () => { |
|
|
} as unknown as ConfigurationService; |
|
|
} as unknown as ConfigurationService; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('getMcpAuthorizationServerMetadata', () => { |
|
|
|
|
|
it('returns RFC 8414 authorization server metadata', () => { |
|
|
|
|
|
mockConfig.ROOT_URL = 'http://localhost:3333/'; |
|
|
|
|
|
|
|
|
|
|
|
expect(getMcpAuthorizationServerMetadata(configurationService)).toEqual({ |
|
|
|
|
|
authorization_endpoint: 'http://localhost:3333/oauth/authorize', |
|
|
|
|
|
client_id_metadata_document_supported: true, |
|
|
|
|
|
code_challenge_methods_supported: ['S256'], |
|
|
|
|
|
grant_types_supported: ['authorization_code', 'refresh_token'], |
|
|
|
|
|
issuer: 'http://localhost:3333', |
|
|
|
|
|
response_types_supported: ['code'], |
|
|
|
|
|
token_endpoint: 'http://localhost:3333/api/v1/oauth/token', |
|
|
|
|
|
token_endpoint_auth_methods_supported: ['none'] |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('getMcpOAuthBaseUrl', () => { |
|
|
describe('getMcpOAuthBaseUrl', () => { |
|
|
it('returns the root URL without trailing slashes', () => { |
|
|
it('returns the root URL without trailing slashes', () => { |
|
|
mockConfig.ROOT_URL = 'https://ghostfol.io///'; |
|
|
mockConfig.ROOT_URL = 'https://ghostfol.io///'; |
|
|
@ -44,6 +63,16 @@ describe('mcp-oauth.helper', () => { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('getMcpResourceUrl', () => { |
|
|
|
|
|
it('returns the resource URL as a URL instance', () => { |
|
|
|
|
|
mockConfig.ROOT_URL = 'http://localhost:3333/'; |
|
|
|
|
|
|
|
|
|
|
|
expect(getMcpResourceUrl(configurationService)).toEqual( |
|
|
|
|
|
new URL('http://localhost:3333/mcp') |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('isMcpOAuthEnabled', () => { |
|
|
describe('isMcpOAuthEnabled', () => { |
|
|
it('returns true when both ENABLE_FEATURE_MCP and ENABLE_FEATURE_MCP_OAUTH are true', () => { |
|
|
it('returns true when both ENABLE_FEATURE_MCP and ENABLE_FEATURE_MCP_OAUTH are true', () => { |
|
|
mockConfig.ENABLE_FEATURE_MCP = true; |
|
|
mockConfig.ENABLE_FEATURE_MCP = true; |
|
|
|