mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(AWS S3 Node): Fix File upload, and add node tests (#6153)
This commit is contained in:
committed by
GitHub
parent
a0dd17e115
commit
deb4c04f34
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"name": "Test S3 upload",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "8f35d24b-1493-43a4-846f-bacb577bfcb2",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [540, 340]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"mode": "jsonToBinary",
|
||||
"options": {}
|
||||
},
|
||||
"id": "eae2946a-1a1e-47e9-9fd6-e32119b13ec0",
|
||||
"name": "Move Binary Data",
|
||||
"type": "n8n-nodes-base.moveBinaryData",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 340]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "upload",
|
||||
"bucketName": "bucket",
|
||||
"fileName": "binary.json",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "6f21fa3f-ede1-44b1-8182-a2c07152f666",
|
||||
"name": "AWS S3",
|
||||
"type": "n8n-nodes-base.awsS3",
|
||||
"typeVersion": 1,
|
||||
"position": [1080, 340],
|
||||
"credentials": {
|
||||
"aws": {
|
||||
"id": "1",
|
||||
"name": "AWS account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return [{ key: \"value\" }];"
|
||||
},
|
||||
"id": "e12f1876-cfd1-47a4-a21b-d478452683bc",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [720, 340]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Move Binary Data": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AWS S3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Move Binary Data",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"AWS S3": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
48
packages/nodes-base/nodes/Aws/S3/test/AwsS3.node.test.ts
Normal file
48
packages/nodes-base/nodes/Aws/S3/test/AwsS3.node.test.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import nock from 'nock';
|
||||
import { getWorkflowFilenames, initBinaryDataManager, testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const workflows = getWorkflowFilenames(__dirname);
|
||||
|
||||
describe('Test S3 Node', () => {
|
||||
describe('File Upload', () => {
|
||||
let mock: nock.Scope;
|
||||
const now = 1683028800000;
|
||||
|
||||
beforeAll(async () => {
|
||||
jest.useFakeTimers({ doNotFake: ['nextTick'], now });
|
||||
|
||||
await initBinaryDataManager();
|
||||
|
||||
nock.disableNetConnect();
|
||||
mock = nock('https://bucket.s3.eu-central-1.amazonaws.com');
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
mock.get('/?location').reply(
|
||||
200,
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<LocationConstraint>
|
||||
<LocationConstraint>eu-central-1</LocationConstraint>
|
||||
</LocationConstraint>`,
|
||||
{
|
||||
'content-type': 'application/xml',
|
||||
},
|
||||
);
|
||||
|
||||
mock
|
||||
.put('/binary.json')
|
||||
.matchHeader(
|
||||
'X-Amz-Content-Sha256',
|
||||
'e43abcf3375244839c012f9633f95862d232a95b00d5bc7348b3098b9fed7f32',
|
||||
)
|
||||
.once()
|
||||
.reply(200, { success: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
});
|
||||
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user