From 1076a580c2be6d832ad566e4189062a6b299213a Mon Sep 17 00:00:00 2001 From: TemoSulava Date: Fri, 16 Oct 2026 22:00:49 +0400 Subject: [PATCH 1/2] fix(Freshservice Node): Support predefined credential in HTTP Request node Fixes #41100 --- .../FreshserviceApi.credentials.ts | 24 ++++++++++++- .../test/FreshserviceApi.credentials.test.ts | 35 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts diff --git a/packages/nodes-base/credentials/FreshserviceApi.credentials.ts b/packages/nodes-base/credentials/FreshserviceApi.credentials.ts index 5d028787836..46003b82656 100644 --- a/packages/nodes-base/credentials/FreshserviceApi.credentials.ts +++ b/packages/nodes-base/credentials/FreshserviceApi.credentials.ts @@ -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 https://n8n.freshservice.com, the domain is n8n', }, ]; + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + auth: { + username: '={{$credentials.apiKey}}', + password: 'X', + }, + }, + }; + + test: ICredentialTestRequest = { + request: { + baseURL: '=https://{{$credentials.domain}}.freshservice.com/api/v2', + url: '/departments', + }, + }; } diff --git a/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts b/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts new file mode 100644 index 00000000000..8719f834d14 --- /dev/null +++ b/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts @@ -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('/departments'); + }); + + 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'); + }); + }); +}); From 45d41998f9f9905266cdd57df9363f94b1a73d0b Mon Sep 17 00:00:00 2001 From: TemoSulava Date: Fri, 16 Oct 2026 22:33:16 +0400 Subject: [PATCH 2/2] fix(Freshservice Node): Use least-privilege endpoint for credential testing --- packages/nodes-base/credentials/FreshserviceApi.credentials.ts | 2 +- .../credentials/test/FreshserviceApi.credentials.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/credentials/FreshserviceApi.credentials.ts b/packages/nodes-base/credentials/FreshserviceApi.credentials.ts index 46003b82656..687f30d3920 100644 --- a/packages/nodes-base/credentials/FreshserviceApi.credentials.ts +++ b/packages/nodes-base/credentials/FreshserviceApi.credentials.ts @@ -45,7 +45,7 @@ export class FreshserviceApi implements ICredentialType { test: ICredentialTestRequest = { request: { baseURL: '=https://{{$credentials.domain}}.freshservice.com/api/v2', - url: '/departments', + url: '/agents/me', }, }; } diff --git a/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts b/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts index 8719f834d14..6745f4af6b2 100644 --- a/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts +++ b/packages/nodes-base/credentials/test/FreshserviceApi.credentials.test.ts @@ -19,7 +19,7 @@ describe('FreshserviceApi Credential', () => { expect(freshserviceApi.test.request.baseURL).toBe( '=https://{{$credentials.domain}}.freshservice.com/api/v2', ); - expect(freshserviceApi.test.request.url).toBe('/departments'); + expect(freshserviceApi.test.request.url).toBe('/agents/me'); }); describe('authenticate', () => {