fix(DeepL Node): Update credentials to use header-based authentication (#24614)

Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
moseoh
2026-05-05 02:10:45 +09:00
committed by GitHub
parent 4b9e975ca0
commit b72bd1987c
2 changed files with 36 additions and 2 deletions
@@ -41,8 +41,8 @@ export class DeepLApi implements ICredentialType {
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
qs: {
auth_key: '={{$credentials.apiKey}}',
headers: {
Authorization: '={{ "DeepL-Auth-Key " + $credentials.apiKey }}',
},
},
};
@@ -0,0 +1,34 @@
import { DeepLApi } from '../DeepLApi.credentials';
describe('DeepLApi Credential', () => {
const deepLApi = new DeepLApi();
it('should have correct metadata and properties', () => {
expect(deepLApi.name).toBe('deepLApi');
expect(deepLApi.displayName).toBe('DeepL API');
expect(deepLApi.documentationUrl).toBe('deepl');
expect(deepLApi.properties).toHaveLength(2);
expect(deepLApi.properties[0].name).toBe('apiKey');
expect(deepLApi.properties[1].name).toBe('apiPlan');
});
it('should have correct test request configuration', () => {
expect(deepLApi.test.request.url).toBe('/usage');
expect(deepLApi.test.request.baseURL).toBe(
'={{$credentials.apiPlan === "pro" ? "https://api.deepl.com/v2" : "https://api-free.deepl.com/v2" }}',
);
});
describe('authenticate', () => {
it('should be configured for header-based authentication with correct format', () => {
const auth = deepLApi.authenticate as any;
expect(auth.type).toBe('generic');
expect(auth.properties.qs).toBeUndefined();
expect(auth.properties.headers).toBeDefined();
expect(auth.properties.headers.Authorization).toBe(
'={{ "DeepL-Auth-Key " + $credentials.apiKey }}',
);
});
});
});