From 34b79333fc55850a3ab96c94721c41927f17e7c9 Mon Sep 17 00:00:00 2001 From: Deborah Date: Thu, 21 Mar 2024 11:05:31 +0000 Subject: [PATCH 1/3] docs: Fix the Microsoft OneDrive Trigger docs link (#8930) --- .../nodes/Microsoft/OneDrive/MicrosoftOneDriveTrigger.node.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDriveTrigger.node.json b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDriveTrigger.node.json index 34d750416a851..90b99c598f981 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDriveTrigger.node.json +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDriveTrigger.node.json @@ -11,7 +11,7 @@ ], "primaryDocumentation": [ { - "url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.microsoftonedrivetrigger/" + "url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.microsoftonedrivetrigger/" } ], "generic": [ From 89df277b80002f46d198d7b8bd3d81f5b815c116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 21 Mar 2024 12:17:43 +0100 Subject: [PATCH 2/3] fix(MySQL Node): Set paired items correctly in single query batch mode (#8940) --- .../nodes/MySql/test/v2/runQueries.test.ts | 32 +++++++++++++++++++ .../nodes/MySql/v2/helpers/utils.ts | 4 +-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/MySql/test/v2/runQueries.test.ts b/packages/nodes-base/nodes/MySql/test/v2/runQueries.test.ts index cdcf00fd0781b..9dc3f8d451d2b 100644 --- a/packages/nodes-base/nodes/MySql/test/v2/runQueries.test.ts +++ b/packages/nodes-base/nodes/MySql/test/v2/runQueries.test.ts @@ -42,6 +42,38 @@ describe('Test MySql V2, runQueries', () => { jest.clearAllMocks(); }); + describe('in single query batch mode', () => { + it('should set paired items correctly', async () => { + const nodeOptions = { queryBatching: BATCH_MODE.SINGLE, nodeVersion: 2 }; + const pool = createFakePool(fakeConnection); + const mockExecuteFns = createMockExecuteFunction({}, mySqlMockNode); + + pool.query = jest.fn(async () => [ + [[{ finishedAt: '2023-12-30' }], [{ finishedAt: '2023-12-31' }]], + ]); + + const result = await configureQueryRunner.call( + mockExecuteFns, + nodeOptions, + pool, + )([ + { query: 'SELECT finishedAt FROM my_table WHERE id = ?', values: [123] }, + { query: 'SELECT finishedAt FROM my_table WHERE id = ?', values: [456] }, + ]); + + expect(result).toEqual([ + { + json: { finishedAt: '2023-12-30' }, + pairedItem: { item: 0 }, + }, + { + json: { finishedAt: '2023-12-31' }, + pairedItem: { item: 1 }, + }, + ]); + }); + }); + it('should execute in "Single" mode, should return success true', async () => { const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.SINGLE, nodeVersion: 2 }; diff --git a/packages/nodes-base/nodes/MySql/v2/helpers/utils.ts b/packages/nodes-base/nodes/MySql/v2/helpers/utils.ts index 4ac1f9b3d5f3a..be48ed42e64fd 100644 --- a/packages/nodes-base/nodes/MySql/v2/helpers/utils.ts +++ b/packages/nodes-base/nodes/MySql/v2/helpers/utils.ts @@ -159,9 +159,9 @@ export function prepareOutput( } else { response .filter((entry) => Array.isArray(entry)) - .forEach((entry) => { + .forEach((entry, index) => { const executionData = constructExecutionHelper(wrapData(entry), { - itemData, + itemData: Array.isArray(itemData) ? itemData[index] : itemData, }); returnData.push(...executionData); From 079a1147d41442bb7269d5e9da30e45019438ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 21 Mar 2024 13:49:34 +0100 Subject: [PATCH 3/3] fix(core): Ensure the generic OAuth2 API credential uses the OAuth2 credential test (#8941) --- .../services/credentials-tester.service.ts | 5 +-- .../test/unit/credentials-tester.unit.test.ts | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 packages/cli/test/unit/credentials-tester.unit.test.ts diff --git a/packages/cli/src/services/credentials-tester.service.ts b/packages/cli/src/services/credentials-tester.service.ts index 59b4abb5db581..0f56ef3600d81 100644 --- a/packages/cli/src/services/credentials-tester.service.ts +++ b/packages/cli/src/services/credentials-tester.service.ts @@ -84,7 +84,7 @@ export class CredentialsTester { return 'access_token' in oauthTokenData; } - private getCredentialTestFunction( + getCredentialTestFunction( credentialType: string, ): ICredentialTestFunction | ICredentialTestRequestData | undefined { // Check if test is defined on credentials @@ -116,7 +116,8 @@ export class CredentialsTester { for (const { name, testedBy } of nodeType.description.credentials ?? []) { if ( name === credentialType && - this.credentialTypes.getParentTypes(name).includes('oAuth2Api') + (this.credentialTypes.getParentTypes(name).includes('oAuth2Api') || + name === 'oAuth2Api') ) { return async function oauth2CredTest( this: ICredentialTestFunctions, diff --git a/packages/cli/test/unit/credentials-tester.unit.test.ts b/packages/cli/test/unit/credentials-tester.unit.test.ts new file mode 100644 index 0000000000000..e2987f5c84293 --- /dev/null +++ b/packages/cli/test/unit/credentials-tester.unit.test.ts @@ -0,0 +1,32 @@ +import { CredentialsTester } from '@/services/credentials-tester.service'; +import mock from 'jest-mock-extended/lib/Mock'; +import type { CredentialTypes } from '@/CredentialTypes'; +import type { ICredentialType, INodeType } from 'n8n-workflow'; +import type { NodeTypes } from '@/NodeTypes'; + +describe('CredentialsTester', () => { + const credentialTypes = mock(); + const nodeTypes = mock(); + const credentialsTester = new CredentialsTester(mock(), credentialTypes, nodeTypes, mock()); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should find the OAuth2 credential test for a generic OAuth2 API credential', () => { + credentialTypes.getByName.mockReturnValue(mock({ test: undefined })); + credentialTypes.getSupportedNodes.mockReturnValue(['oAuth2Api']); + credentialTypes.getParentTypes.mockReturnValue([]); + nodeTypes.getByName.mockReturnValue( + mock({ + description: { credentials: [{ name: 'oAuth2Api' }] }, + }), + ); + + const testFn = credentialsTester.getCredentialTestFunction('oAuth2Api'); + + if (typeof testFn !== 'function') fail(); + + expect(testFn.name).toBe('oauth2CredTest'); + }); +});