mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 05:29:44 +02:00
feat(Salesforce Trigger Node): Add OAuth2 JWT authentication support (#32257)
Co-authored-by: Dimitri Lavrenük <20122620+dlavrenuek@users.noreply.github.com>
This commit is contained in:
parent
ad6e10943d
commit
eda249642c
|
|
@ -37,12 +37,43 @@ export class SalesforceTrigger implements INodeType {
|
|||
{
|
||||
name: 'salesforceOAuth2Api',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'salesforceJwtApi',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['jwt'],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
polling: true,
|
||||
inputs: [],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Authentication',
|
||||
name: 'authentication',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'OAuth2',
|
||||
value: 'oAuth2',
|
||||
},
|
||||
{
|
||||
name: 'OAuth2 JWT',
|
||||
value: 'jwt',
|
||||
},
|
||||
],
|
||||
default: 'oAuth2',
|
||||
description: 'OAuth Authorization Flow',
|
||||
},
|
||||
{
|
||||
displayName: 'Trigger On',
|
||||
name: 'triggerOn',
|
||||
|
|
|
|||
|
|
@ -128,6 +128,30 @@ describe('SalesforceTrigger', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Authentication', () => {
|
||||
it('should offer both OAuth2 and JWT credentials', () => {
|
||||
const credentials = trigger.description.credentials ?? [];
|
||||
|
||||
const oAuth2 = credentials.find((c) => c.name === 'salesforceOAuth2Api');
|
||||
const jwt = credentials.find((c) => c.name === 'salesforceJwtApi');
|
||||
|
||||
expect(oAuth2?.displayOptions?.show?.authentication).toEqual(['oAuth2']);
|
||||
expect(jwt?.displayOptions?.show?.authentication).toEqual(['jwt']);
|
||||
});
|
||||
|
||||
it('should expose an authentication selector defaulting to OAuth2', () => {
|
||||
const authentication = trigger.description.properties.find(
|
||||
(p) => p.name === 'authentication',
|
||||
);
|
||||
|
||||
expect(authentication?.default).toBe('oAuth2');
|
||||
expect(authentication?.options).toEqual([
|
||||
{ name: 'OAuth2', value: 'oAuth2' },
|
||||
{ name: 'OAuth2 JWT', value: 'jwt' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Poll Function - Parameter Setup', () => {
|
||||
beforeEach(() => {
|
||||
mockPollFunctions.getNodeParameter.mockImplementation((paramName: string) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user