test(core): Cover JWKS URI default injection in overwriteCredentialsProperties
Some checks failed
CI: Python / Checks (push) Has been cancelled

Three cases added to FrontendService.overwriteCredentialsProperties tests:
oAuth2Api itself receives the per-instance JWKS URI as the default of its
jwksUri property, credentials extending oAuth2Api receive the same default,
and unrelated credentials are not mutated.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Guillaume Jacquart 2026-05-05 18:10:32 +02:00
parent 95bbac43e8
commit 3f5b4f0081
No known key found for this signature in database

View File

@ -596,6 +596,76 @@ describe('FrontendService', () => {
expect(credential.__skipManagedCreation).toBeUndefined();
});
describe('JWKS URI injection', () => {
const expectedJwksUri = 'http://localhost:5678/rest/.well-known/jwks.json';
const makeJwksUriProperty = () => ({
displayName: 'JWKS URI',
name: 'jwksUri',
type: 'string' as const,
default: '',
});
it('should inject the instance JWKS URI on oAuth2Api', () => {
const credential = {
name: 'oAuth2Api',
displayName: 'OAuth2 API',
properties: [makeJwksUriProperty()],
} as unknown as ICredentialType;
loadNodesAndCredentials.types = { credentials: [credential], nodes: [] };
(credentialTypes.getParentTypes as jest.Mock).mockReturnValue([]);
const { service } = createMockService();
(service as any).overwriteCredentialsProperties();
const jwksProperty = credential.properties?.find((p) => p.name === 'jwksUri');
expect(jwksProperty?.default).toBe(expectedJwksUri);
});
it('should inject the instance JWKS URI on credentials extending oAuth2Api', () => {
const credential = {
name: 'slackOAuth2Api',
displayName: 'Slack OAuth2 API',
properties: [makeJwksUriProperty()],
} as unknown as ICredentialType;
loadNodesAndCredentials.types = { credentials: [credential], nodes: [] };
(credentialTypes.getParentTypes as jest.Mock).mockReturnValue(['oAuth2Api']);
const { service } = createMockService();
(service as any).overwriteCredentialsProperties();
const jwksProperty = credential.properties?.find((p) => p.name === 'jwksUri');
expect(jwksProperty?.default).toBe(expectedJwksUri);
});
it('should leave non-OAuth2 credentials untouched', () => {
const credential = {
name: 'httpBasicAuth',
displayName: 'Basic Auth',
properties: [
{
displayName: 'User',
name: 'user',
type: 'string' as const,
default: '',
},
],
} as unknown as ICredentialType;
loadNodesAndCredentials.types = { credentials: [credential], nodes: [] };
(credentialTypes.getParentTypes as jest.Mock).mockReturnValue([]);
const { service } = createMockService();
(service as any).overwriteCredentialsProperties();
expect(credential.properties).toEqual([
{ displayName: 'User', name: 'user', type: 'string', default: '' },
]);
});
});
});
describe('generateTypes', () => {