pull:初次提交
This commit is contained in:
40
n8n-n8n-1.109.2/packages/nodes-base/nodes/Totp/test/Totp.node.test.ts
Executable file
40
n8n-n8n-1.109.2/packages/nodes-base/nodes/Totp/test/Totp.node.test.ts
Executable file
@@ -0,0 +1,40 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import type { WorkflowTestData } from 'n8n-workflow';
|
||||
|
||||
jest.mock('otpauth', () => {
|
||||
return {
|
||||
TOTP: jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
generate: jest.fn().mockReturnValue('123456'),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Execute TOTP node', () => {
|
||||
const testHarness = new NodeTestHarness();
|
||||
const tests: WorkflowTestData[] = [
|
||||
{
|
||||
description: 'Generate TOTP Token',
|
||||
input: {
|
||||
workflowData: testHarness.readWorkflowJSON('Totp.workflow.test.json'),
|
||||
},
|
||||
output: {
|
||||
nodeData: {
|
||||
// ignore json.secondsRemaining to prevent flakiness
|
||||
TOTP: [[{ json: expect.objectContaining({ token: '123456' }) }]],
|
||||
},
|
||||
},
|
||||
credentials: {
|
||||
totpApi: {
|
||||
label: 'GitHub:john-doe',
|
||||
secret: 'BVDRSBXQB2ZEL5HE',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const testData of tests) {
|
||||
testHarness.setupTest(testData);
|
||||
}
|
||||
});
|
||||
41
n8n-n8n-1.109.2/packages/nodes-base/nodes/Totp/test/Totp.workflow.test.json
Executable file
41
n8n-n8n-1.109.2/packages/nodes-base/nodes/Totp/test/Totp.workflow.test.json
Executable file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f2e03169-0e94-4a42-821b-3e8f67f449d7",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [580, 320]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"additionalOptions": {}
|
||||
},
|
||||
"id": "831f657d-2724-4a25-bb94-cf37355654bb",
|
||||
"name": "TOTP",
|
||||
"type": "n8n-nodes-base.totp",
|
||||
"typeVersion": 1,
|
||||
"position": [800, 320],
|
||||
"credentials": {
|
||||
"totpApi": {
|
||||
"id": "1",
|
||||
"name": "TOTP account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "TOTP",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user