This commit is contained in:
Temo 2026-10-16 22:32:34 +04:00 committed by GitHub
commit 2b561963cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 58 additions and 1 deletions

View File

@ -1,4 +1,9 @@
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class FreshserviceApi implements ICredentialType {
name = 'freshserviceApi';
@ -26,4 +31,21 @@ export class FreshserviceApi implements ICredentialType {
'Domain in the Freshservice org URL. For example, in <code>https://n8n.freshservice.com</code>, the domain is <code>n8n</code>',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
auth: {
username: '={{$credentials.apiKey}}',
password: 'X',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '=https://{{$credentials.domain}}.freshservice.com/api/v2',
url: '/agents/me',
},
};
}

View File

@ -0,0 +1,35 @@
import type { IAuthenticateGeneric } from 'n8n-workflow';
import { FreshserviceApi } from '../FreshserviceApi.credentials';
describe('FreshserviceApi Credential', () => {
const freshserviceApi = new FreshserviceApi();
it('should have correct metadata and properties', () => {
expect(freshserviceApi.name).toBe('freshserviceApi');
expect(freshserviceApi.displayName).toBe('Freshservice API');
expect(freshserviceApi.documentationUrl).toBe('freshservice');
expect(freshserviceApi.properties).toHaveLength(2);
expect(freshserviceApi.properties[0].name).toBe('apiKey');
expect(freshserviceApi.properties[0].typeOptions).toEqual({ password: true });
expect(freshserviceApi.properties[1].name).toBe('domain');
});
it('should have correct test request configuration', () => {
expect(freshserviceApi.test.request.baseURL).toBe(
'=https://{{$credentials.domain}}.freshservice.com/api/v2',
);
expect(freshserviceApi.test.request.url).toBe('/agents/me');
});
describe('authenticate', () => {
it('should be configured for basic auth with apiKey as username and X as password', () => {
const auth = freshserviceApi.authenticate as IAuthenticateGeneric;
expect(auth.type).toBe('generic');
expect(auth.properties.auth).toBeDefined();
expect(auth.properties.auth?.username).toBe('={{$credentials.apiKey}}');
expect(auth.properties.auth?.password).toBe('X');
});
});
});