mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 05:29:44 +02:00
Merge 45d41998f9 into ec074519d9
This commit is contained in:
commit
2b561963cc
|
|
@ -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',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user