refactor: Overhaul nodes-testing setup - Part 2 (no-changelog) (#14873)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-04-24 17:37:26 +02:00
committed by GitHub
parent 897338bd24
commit 91069f057e
119 changed files with 556 additions and 1002 deletions

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
getWorkflowFilenames,
initBinaryDataService,
testWorkflows,
} from '../../../../../test/nodes/Helpers';
import { getWorkflowFilenames, testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Create Container', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('create.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -86,9 +75,5 @@ describe('Azure Cosmos DB - Create Container', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Delete Container', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('delete.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -30,9 +19,5 @@ describe('Azure Cosmos DB - Delete Container', () => {
.reply(204, {});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Get Container', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('get.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -68,9 +57,5 @@ describe('Azure Cosmos DB - Get Container', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Get All Containers', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('getAll.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -170,9 +159,5 @@ describe('Azure Cosmos DB - Get All Containers', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -0,0 +1,8 @@
export const credentials = {
microsoftAzureCosmosDbSharedKeyApi: {
account: 'n8n-us-east-account',
key: 'I3rwpzP0XoFpNzJ7hRIUXjwgpD1qaVKi71NZBbk7oOHUXrbd80WAoIAAoRaT47W9hHO3b6us1yABACDbVdilag==',
database: 'database_1',
baseUrl: 'https://n8n-us-east-account.documents.azure.com/dbs/database_1',
},
};

View File

@@ -1,12 +1,9 @@
import { OperationalError } from 'n8n-workflow';
import type {
ICredentialDataDecryptedObject,
IHttpRequestOptions,
IRequestOptions,
} from 'n8n-workflow';
import type { IHttpRequestOptions, IRequestOptions } from 'n8n-workflow';
import { MicrosoftAzureCosmosDbSharedKeyApi } from '../../../../../credentials/MicrosoftAzureCosmosDbSharedKeyApi.credentials';
import { FAKE_CREDENTIALS_DATA } from '../../../../../test/nodes/FakeCredentialsMap';
import { MicrosoftAzureCosmosDbSharedKeyApi } from '@credentials/MicrosoftAzureCosmosDbSharedKeyApi.credentials';
import { credentials } from '../credentials';
jest.mock('crypto', () => ({
createHmac: jest.fn(() => ({
@@ -17,20 +14,18 @@ jest.mock('crypto', () => ({
}));
describe('Azure Cosmos DB', () => {
const { account, key, baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
describe('authenticate', () => {
const azureCosmosDbSharedKeyApi = new MicrosoftAzureCosmosDbSharedKeyApi();
it('should generate a valid authorization header', async () => {
jest.useFakeTimers().setSystemTime(new Date('2025-01-01T00:00:00Z'));
const credentials: ICredentialDataDecryptedObject = {
account: FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi.account,
key: FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi.key,
};
const requestOptions: IHttpRequestOptions = {
url: `${FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi.baseUrl}/colls/container1/docs/item1`,
url: `${baseUrl}/colls/container1/docs/item1`,
method: 'GET',
};
const result = await azureCosmosDbSharedKeyApi.authenticate(credentials, requestOptions);
const result = await azureCosmosDbSharedKeyApi.authenticate({ account, key }, requestOptions);
expect(result.headers?.authorization).toBe(
'type%3Dmaster%26ver%3D1.0%26sig%3Dfake-signature',
@@ -114,15 +109,11 @@ describe('Azure Cosmos DB', () => {
it('should properly construct the resourceId and payload', async () => {
jest.useFakeTimers().setSystemTime(new Date('2025-01-01T00:00:00Z'));
const credentials: ICredentialDataDecryptedObject = {
account: FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi.account,
key: FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi.key,
};
const requestOptions: IHttpRequestOptions = {
url: 'https://example.com/dbs/mydb/colls/mycoll/docs/mydoc',
method: 'GET',
};
const result = await azureCosmosDbSharedKeyApi.authenticate(credentials, requestOptions);
const result = await azureCosmosDbSharedKeyApi.authenticate({ account, key }, requestOptions);
expect(result.headers?.authorization).toBe(
'type%3Dmaster%26ver%3D1.0%26sig%3Dfake-signature',

View File

@@ -1,6 +1,16 @@
import type { IDataObject, IHttpRequestOptions, INodeExecutionData } from 'n8n-workflow';
import { mock } from 'jest-mock-extended';
import type {
IDataObject,
IExecuteSingleFunctions,
IHttpRequestOptions,
INode,
INodeExecutionData,
} from 'n8n-workflow';
import { NodeApiError, NodeOperationError, OperationalError } from 'n8n-workflow';
const azureCosmosDbApiRequest = jest.fn();
jest.mock('../../transport', () => ({ azureCosmosDbApiRequest }));
import { ErrorMap } from '../../helpers/errorHandler';
import {
getPartitionKey,
@@ -10,31 +20,19 @@ import {
validatePartitionKey,
validateCustomProperties,
} from '../../helpers/utils';
import { azureCosmosDbApiRequest } from '../../transport';
interface RequestBodyWithParameters extends IDataObject {
parameters: Array<{ name: string; value: string }>;
}
jest.mock('n8n-workflow', () => ({
...jest.requireActual('n8n-workflow'),
azureCosmosDbApiRequest: jest.fn(),
}));
const mockExecuteSingleFunctions = mock<IExecuteSingleFunctions>();
beforeEach(() => {
jest.resetAllMocks();
jest.mock('../../transport', () => ({
azureCosmosDbApiRequest: jest.fn(),
}));
mockExecuteSingleFunctions.getNode.mockReturnValue({ name: 'MockNode' } as INode);
});
describe('getPartitionKey', () => {
let mockExecuteSingleFunctions: any;
beforeEach(() => {
mockExecuteSingleFunctions = {
getNodeParameter: jest.fn(),
getNode: jest.fn(() => ({ name: 'MockNode' })),
};
});
test('should return partition key when found', async () => {
mockExecuteSingleFunctions.getNodeParameter.mockReturnValue('containerName');
const mockApiResponse = {
@@ -42,7 +40,7 @@ describe('getPartitionKey', () => {
paths: ['/partitionKeyPath'],
},
};
(azureCosmosDbApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
azureCosmosDbApiRequest.mockResolvedValue(mockApiResponse);
const result = await getPartitionKey.call(mockExecuteSingleFunctions);
@@ -52,7 +50,7 @@ describe('getPartitionKey', () => {
test('should throw NodeOperationError if partition key is not found', async () => {
mockExecuteSingleFunctions.getNodeParameter.mockReturnValue('containerName');
const mockApiResponse = {};
(azureCosmosDbApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
azureCosmosDbApiRequest.mockResolvedValue(mockApiResponse);
await expect(getPartitionKey.call(mockExecuteSingleFunctions)).rejects.toThrowError(
new NodeOperationError(mockExecuteSingleFunctions.getNode(), 'Partition key not found', {
@@ -77,7 +75,7 @@ describe('getPartitionKey', () => {
},
);
(azureCosmosDbApiRequest as jest.Mock).mockRejectedValue(mockError);
azureCosmosDbApiRequest.mockRejectedValue(mockError);
await expect(getPartitionKey.call(mockExecuteSingleFunctions)).rejects.toThrowError(
new NodeApiError(
@@ -93,17 +91,12 @@ describe('getPartitionKey', () => {
});
describe('validatePartitionKey', () => {
let mockExecuteSingleFunctions: any;
let requestOptions: any;
beforeEach(() => {
mockExecuteSingleFunctions = {
getNodeParameter: jest.fn(),
getNode: jest.fn(() => ({ name: 'MockNode' })),
};
requestOptions = { body: {}, headers: {} };
(azureCosmosDbApiRequest as jest.Mock).mockClear();
azureCosmosDbApiRequest.mockClear();
});
test('should throw NodeOperationError when partition key is missing for "create" operation', async () => {
@@ -115,7 +108,7 @@ describe('validatePartitionKey', () => {
paths: ['/partitionKeyPath'],
},
};
(azureCosmosDbApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
azureCosmosDbApiRequest.mockResolvedValue(mockApiResponse);
await expect(
validatePartitionKey.call(mockExecuteSingleFunctions, requestOptions),
@@ -140,7 +133,7 @@ describe('validatePartitionKey', () => {
paths: ['/partitionKeyPath'],
},
};
(azureCosmosDbApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
azureCosmosDbApiRequest.mockResolvedValue(mockApiResponse);
await expect(
validatePartitionKey.call(mockExecuteSingleFunctions, requestOptions),
@@ -164,7 +157,7 @@ describe('validatePartitionKey', () => {
paths: ['/partitionKeyPath'],
},
};
(azureCosmosDbApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
azureCosmosDbApiRequest.mockResolvedValue(mockApiResponse);
await expect(
validatePartitionKey.call(mockExecuteSingleFunctions, requestOptions),
@@ -188,7 +181,7 @@ describe('validatePartitionKey', () => {
paths: ['/partitionKeyPath'],
},
};
(azureCosmosDbApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
azureCosmosDbApiRequest.mockResolvedValue(mockApiResponse);
await expect(
validatePartitionKey.call(mockExecuteSingleFunctions, requestOptions),
@@ -205,15 +198,6 @@ describe('validatePartitionKey', () => {
});
describe('simplifyData', () => {
let mockExecuteSingleFunctions: any;
beforeEach(() => {
mockExecuteSingleFunctions = {
getNodeParameter: jest.fn(),
getNode: jest.fn(() => ({ name: 'MockNode' })),
};
});
test('should return the same data when "simple" parameter is false', async () => {
mockExecuteSingleFunctions.getNodeParameter.mockReturnValue(false);
const items = [{ json: { foo: 'bar' } }] as INodeExecutionData[];
@@ -234,14 +218,9 @@ describe('simplifyData', () => {
});
describe('validateQueryParameters', () => {
let mockExecuteSingleFunctions: any;
let requestOptions: IHttpRequestOptions;
beforeEach(() => {
mockExecuteSingleFunctions = {
getNodeParameter: jest.fn(),
getNode: jest.fn(() => ({ name: 'MockNode' })),
};
requestOptions = { body: {}, headers: {} } as IHttpRequestOptions;
});
@@ -340,21 +319,12 @@ describe('processJsonInput', () => {
});
describe('validateCustomProperties', () => {
let mockExecuteSingleFunctions: any;
let requestOptions: any;
beforeEach(() => {
mockExecuteSingleFunctions = {
getNodeParameter: jest.fn(),
getNode: jest.fn(() => ({ name: 'MockNode' })),
};
requestOptions = { body: {}, headers: {}, url: 'http://mock.url' };
});
afterEach(() => {
jest.resetAllMocks();
});
test('should merge custom properties into requestOptions.body for valid input', async () => {
const validCustomProperties = { property1: 'value1', property2: 'value2' };
mockExecuteSingleFunctions.getNodeParameter.mockReturnValue(validCustomProperties);

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Create Item', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('create.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -68,9 +57,5 @@ describe('Azure Cosmos DB - Create Item', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Delete Item', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('delete.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -61,9 +50,5 @@ describe('Azure Cosmos DB - Delete Item', () => {
.reply(204, '');
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Get Item', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('get.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -69,9 +58,5 @@ describe('Azure Cosmos DB - Get Item', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Get All Items', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('getAll.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -80,9 +69,5 @@ describe('Azure Cosmos DB - Get All Items', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Query Items', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('query.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -45,9 +34,5 @@ describe('Azure Cosmos DB - Query Items', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,28 +1,17 @@
import nock from 'nock';
import {
initBinaryDataService,
testWorkflows,
getWorkflowFilenames,
} from '../../../../../test/nodes/Helpers';
import { testWorkflows, getWorkflowFilenames } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Cosmos DB - Update Item', () => {
const workflows = getWorkflowFilenames(__dirname).filter((filename) =>
filename.includes('update.workflow.json'),
);
beforeAll(async () => {
await initBinaryDataService();
});
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
const { baseUrl } = credentials.microsoftAzureCosmosDbSharedKeyApi;
const baseUrl = 'https://n8n-us-east-account.documents.azure.com/dbs/database_1';
nock.cleanAll();
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/json' })
@@ -73,9 +62,5 @@ describe('Azure Cosmos DB - Update Item', () => {
});
});
afterEach(() => {
nock.cleanAll();
});
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -4,9 +4,9 @@ import {
type ILoadOptionsFunctions,
} from 'n8n-workflow';
import { FAKE_CREDENTIALS_DATA } from '../../../../../test/nodes/FakeCredentialsMap';
import { AzureCosmosDb } from '../../AzureCosmosDb.node';
import { HeaderConstants } from '../../helpers/constants';
import { credentials } from '../credentials';
describe('Azure Cosmos DB', () => {
describe('List search', () => {
@@ -31,7 +31,7 @@ describe('Azure Cosmos DB', () => {
const mockGetCredentials = jest.fn(async (type: string, _itemIndex?: number) => {
if (type === 'microsoftAzureCosmosDbSharedKeyApi') {
return FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi;
return credentials.microsoftAzureCosmosDbSharedKeyApi;
}
throw new OperationalError('Unknown credentials');
});
@@ -100,7 +100,7 @@ describe('Azure Cosmos DB', () => {
const mockGetCredentials = jest.fn(async (type: string, _itemIndex?: number) => {
if (type === 'microsoftAzureCosmosDbSharedKeyApi') {
return FAKE_CREDENTIALS_DATA.microsoftAzureCosmosDbSharedKeyApi;
return credentials.microsoftAzureCosmosDbSharedKeyApi;
}
throw new OperationalError('Unknown credentials');
});

View File

@@ -1,13 +1,6 @@
import type {
ICredentialDataDecryptedObject,
IDataObject,
IHttpRequestOptions,
ILoadOptionsFunctions,
WorkflowTestData,
} from 'n8n-workflow';
import type { ILoadOptionsFunctions, WorkflowTestData } from 'n8n-workflow';
import { NodeConnectionTypes } from 'n8n-workflow';
import { CredentialsHelper } from '@test/nodes/credentials-helper';
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
import * as Helpers from '@test/nodes/Helpers';
@@ -18,6 +11,15 @@ describe('Microsoft Entra Node', () => {
const baseUrl = 'https://graph.microsoft.com/v1.0';
describe('Credentials', () => {
const credentials = {
microsoftEntraOAuth2Api: {
scope: '',
oauthTokenData: {
access_token: 'ACCESSTOKEN',
},
},
};
const tests: WorkflowTestData[] = [
{
description: 'should use correct credentials',
@@ -92,33 +94,10 @@ describe('Microsoft Entra Node', () => {
},
],
},
credentials,
},
];
beforeAll(() => {
jest
.spyOn(CredentialsHelper.prototype, 'authenticate')
.mockImplementation(
async (
credentials: ICredentialDataDecryptedObject,
typeName: string,
requestParams: IHttpRequestOptions,
): Promise<IHttpRequestOptions> => {
if (typeName === 'microsoftEntraOAuth2Api') {
return {
...requestParams,
headers: {
authorization:
'bearer ' + (credentials.oauthTokenData as IDataObject).access_token,
},
};
} else {
return requestParams;
}
},
);
});
test.each(tests)('$description', async (testData) => {
const { result } = await executeWorkflow(testData);
const resultNodeData = Helpers.getResultNodeData(result, testData);

View File

@@ -0,0 +1,8 @@
export const credentials = {
microsoftExcelOAuth2Api: {
scope: 'openid',
oauthTokenData: {
access_token: 'token',
},
},
};

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => addTable', () => {
nock('https://graph.microsoft.com/v1.0/me')
.post(
@@ -23,5 +25,5 @@ describe('Test MicrosoftExcelV2, table => addTable', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/addTable.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => append', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -24,5 +26,5 @@ describe('Test MicrosoftExcelV2, table => append', () => {
.reply(200);
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/append.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => convertToRange', () => {
nock('https://graph.microsoft.com/v1.0/me')
.post(
@@ -19,5 +21,5 @@ describe('Test MicrosoftExcelV2, table => convertToRange', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/convertToRange.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => deleteTable', () => {
nock('https://graph.microsoft.com/v1.0/me')
.delete(
@@ -10,5 +12,5 @@ describe('Test MicrosoftExcelV2, table => deleteTable', () => {
.reply(200);
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/deleteTable.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => getColumns', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -21,5 +23,5 @@ describe('Test MicrosoftExcelV2, table => getColumns', () => {
.reply(200, { value: [] });
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/getColumns.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => getRows', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -30,5 +32,5 @@ describe('Test MicrosoftExcelV2, table => getRows', () => {
.reply(200, { value: [] });
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/getRows.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, table => lookup', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -38,5 +40,5 @@ describe('Test MicrosoftExcelV2, table => lookup', () => {
.reply(200, { value: [] });
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/lookup.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, workbook => addWorksheet', () => {
nock('https://graph.microsoft.com/v1.0/me')
.post('/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/createSession', {
@@ -22,5 +24,5 @@ describe('Test MicrosoftExcelV2, workbook => addWorksheet', () => {
.reply(200);
const workflows = ['nodes/Microsoft/Excel/test/v2/node/workbook/addWorksheet.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,11 +2,13 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, workbook => deleteWorkbook', () => {
nock('https://graph.microsoft.com/v1.0/me')
.delete('/drive/items/01FUWX3BXJLISGF2CFWBGYPHXFCXPXOJUK')
.reply(200);
const workflows = ['nodes/Microsoft/Excel/test/v2/node/workbook/deleteWorkbook.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, workbook => getAll', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get("/drive/root/search(q='.xlsx')?%24select=name&%24top=2")
@@ -19,5 +21,5 @@ describe('Test MicrosoftExcelV2, workbook => getAll', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/workbook/getAll.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => append', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -38,5 +40,5 @@ describe('Test MicrosoftExcelV2, worksheet => append', () => {
.reply(200, { values: [[4, 'Don', 37, 'data 44']] });
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/append.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => clear', () => {
nock('https://graph.microsoft.com/v1.0/me')
.post(
@@ -13,5 +15,5 @@ describe('Test MicrosoftExcelV2, worksheet => clear', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/clear.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => deleteWorksheet', () => {
nock('https://graph.microsoft.com/v1.0/me')
.delete(
@@ -12,5 +14,5 @@ describe('Test MicrosoftExcelV2, worksheet => deleteWorksheet', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/deleteWorksheet.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => getAll', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -25,5 +27,5 @@ describe('Test MicrosoftExcelV2, worksheet => getAll', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/getAll.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => readRows', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -27,5 +29,5 @@ describe('Test MicrosoftExcelV2, worksheet => readRows', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/readRows.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => update', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -52,5 +54,5 @@ describe('Test MicrosoftExcelV2, worksheet => update', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/update.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftExcelV2, worksheet => upsert', () => {
nock('https://graph.microsoft.com/v1.0/me')
.get(
@@ -54,5 +56,5 @@ describe('Test MicrosoftExcelV2, worksheet => upsert', () => {
});
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/upsert.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_create.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -55,6 +57,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_delete.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -24,6 +26,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_get.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -76,6 +78,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_getAll.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -25,6 +27,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = [
'nodes/Microsoft/Storage/test/workflows/blob_getAllLimitOptions.workflow.json',
@@ -20,6 +22,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/container_create.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -27,6 +29,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/container_delete.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -24,6 +26,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/container_get.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -33,6 +35,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/container_getAll.workflow.json'];
const workflowTests = workflowToTests(workflows);
@@ -25,6 +27,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,5 +1,7 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = [
'nodes/Microsoft/Storage/test/workflows/container_getAllLimitOptions.workflow.json',
@@ -20,6 +22,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -0,0 +1,29 @@
export const credentials = {
azureStorageOAuth2Api: {
grantType: 'authorizationCode',
authUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
accessTokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
clientId: 'CLIENTID',
clientSecret: 'CLIENTSECRET',
scope: 'https://storage.azure.com/user_impersonation',
authQueryParameters: 'response_mode=query',
authentication: 'body',
oauthTokenData: {
token_type: 'Bearer',
scope: 'https://storage.azure.com/user_impersonation',
expires_in: 4730,
ext_expires_in: 4730,
access_token: 'ACCESSTOKEN',
callbackQueryString: {
session_state: 'SESSIONSTATE',
},
},
account: 'myaccount',
baseUrl: 'https://myaccount.blob.core.windows.net',
},
azureStorageSharedKeyApi: {
account: 'devstoreaccount1',
key: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
baseUrl: 'https://myaccount.blob.core.windows.net',
},
};

View File

@@ -1,43 +1,13 @@
import type {
ICredentialDataDecryptedObject,
IDataObject,
IHttpRequestOptions,
} from 'n8n-workflow';
import { CredentialsHelper } from '@test/nodes/credentials-helper';
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/credentials_oauth2.workflow.json'];
const workflowTests = workflowToTests(workflows);
describe('should use correct oauth2 credentials', () => {
beforeAll(() => {
jest
.spyOn(CredentialsHelper.prototype, 'authenticate')
.mockImplementation(
async (
credentials: ICredentialDataDecryptedObject,
typeName: string,
requestParams: IHttpRequestOptions,
): Promise<IHttpRequestOptions> => {
if (typeName === 'azureStorageOAuth2Api') {
return {
...requestParams,
headers: {
authorization: `bearer ${(credentials.oauthTokenData as IDataObject).access_token as string}`,
},
};
} else {
return requestParams;
}
},
);
});
afterAll(() => {
jest.restoreAllMocks();
});
beforeEach(() => jest.restoreAllMocks());
for (const workflow of workflowTests) {
workflow.nock = {
@@ -67,6 +37,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});

View File

@@ -1,44 +1,17 @@
import type { ICredentialDataDecryptedObject, IHttpRequestOptions } from 'n8n-workflow';
import { CredentialsHelper } from '@test/nodes/credentials-helper';
import { FAKE_CREDENTIALS_DATA } from '@test/nodes/FakeCredentialsMap';
import { AzureStorageSharedKeyApi } from '@credentials/AzureStorageSharedKeyApi.credentials';
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { AzureStorageSharedKeyApi } from '../../../../../credentials/AzureStorageSharedKeyApi.credentials';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const { account, baseUrl, key } = FAKE_CREDENTIALS_DATA.azureStorageSharedKeyApi;
const { account, baseUrl, key } = credentials.azureStorageSharedKeyApi;
const workflows = ['nodes/Microsoft/Storage/test/workflows/credentials_sharedKey.workflow.json'];
const workflowTests = workflowToTests(workflows);
describe('should use correct shared key credentials', () => {
beforeAll(() => {
jest
.spyOn(CredentialsHelper.prototype, 'authenticate')
.mockImplementation(
async (
_credentials: ICredentialDataDecryptedObject,
typeName: string,
requestParams: IHttpRequestOptions,
): Promise<IHttpRequestOptions> => {
if (typeName === 'azureStorageSharedKeyApi') {
return {
...requestParams,
headers: {
authorization:
'SharedKey Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
},
};
} else {
return requestParams;
}
},
);
});
afterAll(() => {
jest.restoreAllMocks();
});
beforeEach(() => jest.restoreAllMocks());
for (const workflow of workflowTests) {
workflow.nock = {
@@ -68,6 +41,7 @@ describe('Azure Storage Node', () => {
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
});
@@ -76,7 +50,7 @@ describe('Azure Storage Node', () => {
const azureStorageSharedKeyApi = new AzureStorageSharedKeyApi();
it('should remove undefined query parameters and headers', async () => {
const credentials: ICredentialDataDecryptedObject = {
const authCredentials: ICredentialDataDecryptedObject = {
account,
key,
};
@@ -89,14 +63,14 @@ describe('Azure Storage Node', () => {
method: 'GET',
};
const result = await azureStorageSharedKeyApi.authenticate(credentials, requestOptions);
const result = await azureStorageSharedKeyApi.authenticate(authCredentials, requestOptions);
expect(result.qs).toEqual({ restype: 'container' });
expect(result.headers).not.toHaveProperty('Content-Length');
});
it('should default method to GET if not provided', async () => {
const credentials: ICredentialDataDecryptedObject = {
const authCredentials: ICredentialDataDecryptedObject = {
account,
key,
};
@@ -108,12 +82,12 @@ describe('Azure Storage Node', () => {
},
};
const result = await azureStorageSharedKeyApi.authenticate(credentials, requestOptions);
const result = await azureStorageSharedKeyApi.authenticate(authCredentials, requestOptions);
expect(result.method).toBe('GET');
});
it('should generate a valid authorization header', async () => {
const credentials: ICredentialDataDecryptedObject = {
const authCredentials: ICredentialDataDecryptedObject = {
account,
key,
};
@@ -133,7 +107,7 @@ describe('Azure Storage Node', () => {
},
method: 'PUT',
};
const result = await azureStorageSharedKeyApi.authenticate(credentials, requestOptions);
const result = await azureStorageSharedKeyApi.authenticate(authCredentials, requestOptions);
expect(result.headers?.authorization).toBe(
'SharedKey devstoreaccount1:6sSQ3N4yNFQynBs/iLptIRPS5DQeaFBocW+dyYbAdOI=',

View File

@@ -1,9 +1,8 @@
import type { ILoadOptionsFunctions, INodeParameterResourceLocator } from 'n8n-workflow';
import { FAKE_CREDENTIALS_DATA } from '@test/nodes/FakeCredentialsMap';
import { AzureStorage } from '../../AzureStorage.node';
import { XMsVersion } from '../../GenericFunctions';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
describe('List search', () => {
@@ -25,7 +24,7 @@ describe('Azure Storage Node', () => {
});
const mockGetCredentials = jest.fn(async (type: string, _itemIndex?: number) => {
if (type === 'azureStorageSharedKeyApi') {
return FAKE_CREDENTIALS_DATA.azureStorageSharedKeyApi;
return credentials.azureStorageSharedKeyApi;
}
// eslint-disable-next-line n8n-local-rules/no-plain-errors
throw new Error('Unknown credentials');
@@ -76,7 +75,7 @@ describe('Azure Storage Node', () => {
});
const mockGetCredentials = jest.fn(async (type: string, _itemIndex?: number) => {
if (type === 'azureStorageSharedKeyApi') {
return FAKE_CREDENTIALS_DATA.azureStorageSharedKeyApi;
return credentials.azureStorageSharedKeyApi;
}
// eslint-disable-next-line n8n-local-rules/no-plain-errors
throw new Error('Unknown credentials');

View File

@@ -0,0 +1,8 @@
export const credentials = {
microsoftTeamsOAuth2Api: {
scope: 'openid',
oauthTokenData: {
access_token: 'token',
},
},
};

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channel => create', () => {
nock('https://graph.microsoft.com')
.post('/v1.0/teams/1644e7fe-547e-4223-a24f-922395865343/channels')
@@ -20,5 +22,5 @@ describe('Test MicrosoftTeamsV2, channel => create', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/create.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channel => deleteChannel', () => {
nock('https://graph.microsoft.com')
.delete(
@@ -10,5 +12,5 @@ describe('Test MicrosoftTeamsV2, channel => deleteChannel', () => {
.reply(200, {});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/deleteChannel.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channel => get', () => {
nock('https://graph.microsoft.com')
.get(
@@ -23,5 +25,5 @@ describe('Test MicrosoftTeamsV2, channel => get', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/get.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channel => getAll', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/teams/1111-2222-3333/channels')
@@ -47,5 +49,5 @@ describe('Test MicrosoftTeamsV2, channel => getAll', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/getAll.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channel => update', () => {
nock('https://graph.microsoft.com')
.patch(
@@ -11,5 +13,5 @@ describe('Test MicrosoftTeamsV2, channel => update', () => {
.reply(200, {});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/update.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channelMessage => create', () => {
nock('https://graph.microsoft.com')
.post('/beta/teams/1111-2222-3333/channels/42:aaabbbccc.tacv2/messages', {
@@ -52,5 +54,5 @@ describe('Test MicrosoftTeamsV2, channelMessage => create', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channelMessage/create.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, channelMessage => getAll', () => {
nock('https://graph.microsoft.com')
.get('/beta/teams/1111-2222-3333/channels/42:aaabbbccc.tacv2/messages')
@@ -64,5 +66,5 @@ describe('Test MicrosoftTeamsV2, channelMessage => getAll', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channelMessage/getAll.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, chatMessage => create', () => {
nock('https://graph.microsoft.com')
.post('/v1.0/chats/19:ebed9ad42c904d6c83adf0db360053ec@thread.v2/messages')
@@ -46,5 +48,5 @@ describe('Test MicrosoftTeamsV2, chatMessage => create', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/chatMessage/create.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, chatMessage => get', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/chats/19:ebed9ad42c904d6c83adf0db360053ec@thread.v2/messages/1698378560692')
@@ -47,5 +49,5 @@ describe('Test MicrosoftTeamsV2, chatMessage => get', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/chatMessage/get.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, chatMessage => getAll', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/chats/19:ebed9ad42c904d6c83adf0db360053ec@thread.v2/messages')
@@ -87,5 +89,5 @@ describe('Test MicrosoftTeamsV2, chatMessage => getAll', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/chatMessage/getAll.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, task => create', () => {
nock('https://graph.microsoft.com')
.post('/v1.0/planner/tasks', {
@@ -70,5 +72,5 @@ describe('Test MicrosoftTeamsV2, task => create', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/task/create.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, task => deleteTask', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
@@ -11,5 +13,5 @@ describe('Test MicrosoftTeamsV2, task => deleteTask', () => {
.reply(200, {});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/task/deleteTask.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, task => get', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
@@ -58,5 +60,5 @@ describe('Test MicrosoftTeamsV2, task => get', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/task/get.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, task => getAll', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/me')
@@ -147,5 +149,5 @@ describe('Test MicrosoftTeamsV2, task => getAll', () => {
});
const workflows = ['nodes/Microsoft/Teams/test/v2/node/task/getAll.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});

View File

@@ -2,6 +2,8 @@ import nock from 'nock';
import { testWorkflows } from '@test/nodes/Helpers';
import { credentials } from '../../../credentials';
describe('Test MicrosoftTeamsV2, task => update', () => {
nock('https://graph.microsoft.com')
.get('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
@@ -15,5 +17,5 @@ describe('Test MicrosoftTeamsV2, task => update', () => {
.reply(200);
const workflows = ['nodes/Microsoft/Teams/test/v2/node/task/update.workflow.json'];
testWorkflows(workflows);
testWorkflows(workflows, credentials);
});