refactor: Overhaul nodes-testing setup - Part 3 (no-changelog) (#14967)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-04-29 17:42:21 +02:00
committed by GitHub
parent 3e43f9f8bc
commit 979f9e6327
241 changed files with 1868 additions and 2013 deletions

View File

@@ -0,0 +1,109 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "99f866fa-f63c-477d-a0d0-48fbdb8a344a",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resource": "blob",
"operation": "create",
"container": { "__rl": true, "value": "mycontainer", "mode": "list" },
"blobCreate": "myblob",
"options": {
"accessTier": "Hot",
"blobType": "BlockBlob",
"cacheControl": "no-cache",
"contentCrc64": "3EDB64E77CB16A4C",
"contentEncoding": "utf8",
"contentLanguage": "en-US",
"contentMd5": "b97f46db5f3be7709d942eefe30e5b45",
"contentType": "application/json",
"encryptionContext": "context",
"encryptionScope": "encryptionScope",
"expiryOption": "Absolute",
"filename": "file.json",
"immutabilityPolicyUntilDate": "2025-01-01T00:00:00",
"immutabilityPolicyMode": "unlocked",
"leaseId": "leaseId123",
"legalHold": true,
"metadata": { "metadataValues": [{ "fieldName": "key1", "fieldValue": "value1" }] },
"origin": "http://contoso.com",
"tags": { "tagValues": [{ "tagName": "tag1", "tagValue": "value1" }] }
},
"requestOptions": {}
},
"type": "n8n-nodes-base.azureStorage",
"typeVersion": 1,
"position": [660, 0],
"id": "ab1b6258-5c75-4893-90bf-ef591264420c",
"name": "Azure Storage",
"credentials": {
"azureStorageSharedKeyApi": {
"id": "VPmcFM58eDDexWQL",
"name": "Azure Storage Shared Key account"
}
}
},
{
"parameters": {
"mode": "jsonToBinary",
"convertAllData": false,
"options": { "useRawData": true }
},
"name": "Move Binary Data",
"type": "n8n-nodes-base.moveBinaryData",
"typeVersion": 1,
"position": [440, 0],
"id": "221e00ed-8c9b-4313-a4d6-b87c64b09d80"
},
{
"parameters": {
"mode": "raw",
"jsonOutput": "{\n \"data\": {\n \"my_field_1\": \"value\",\n \"my_field_2\": 1\n }\n}\n",
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [220, 0],
"id": "6c03903b-0177-4e94-b1ad-4f6ad9e84f62",
"name": "Edit Fields"
}
],
"connections": {
"When clicking Test workflow": {
"main": [[{ "node": "Edit Fields", "type": "main", "index": 0 }]]
},
"Move Binary Data": { "main": [[{ "node": "Azure Storage", "type": "main", "index": 0 }]] },
"Edit Fields": { "main": [[{ "node": "Move Binary Data", "type": "main", "index": 0 }]] }
},
"pinData": {
"Azure Storage": [
{
"json": {
"etag": "\"0x22769D26D3F3740\"",
"lastModified": "Thu, 23 Jan 2025 17:53:23 GMT",
"contentMd5": "aWQGHD8kGQd5ZtEN/S1/aw==",
"requestId": "75b87ee3-a7f7-468d-b7d1-e7e7b3173dab",
"version": "2025-01-05",
"date": "Thu, 23 Jan 2025 17:53:23 GMT",
"requestServerEncrypted": true,
"accessControlAllowCredentials": "access-control-allow-credentials",
"accessControlAllowOrigin": "access-control-allow-origin",
"accessControlExposeHeaders": "access-control-expose-headers",
"contentCrc64": "x-ms-content-crc64",
"contentLength": 0,
"encryptionKeySha256": "x-ms-encryption-key-sha256",
"encryptionScope": "x-ms-encryption-scope",
"versionId": "Thu, 23 Jan 2025 17:53:23 GMT",
"keepAlive": "timeout=5",
"server": "Azurite-Blob/3.33.0"
}
}
]
}
}

View File

@@ -0,0 +1,51 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "99f866fa-f63c-477d-a0d0-48fbdb8a344a",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resource": "blob",
"operation": "delete",
"container": { "__rl": true, "mode": "id", "value": "mycontainer" },
"blob": { "__rl": true, "mode": "id", "value": "myblob" },
"options": { "leaseId": "leaseId123" },
"requestOptions": {}
},
"type": "n8n-nodes-base.azureStorage",
"typeVersion": 1,
"position": [660, 0],
"id": "ab1b6258-5c75-4893-90bf-ef591264420c",
"name": "Azure Storage",
"credentials": {
"azureStorageSharedKeyApi": {
"id": "VPmcFM58eDDexWQL",
"name": "Azure Storage Shared Key account"
}
}
}
],
"connections": {
"When clicking Test workflow": {
"main": [[{ "node": "Azure Storage", "type": "main", "index": 0 }]]
}
},
"pinData": {
"Azure Storage": [
{
"json": {
"requestId": "75b87ee3-a7f7-468d-b7d1-e7e7b3173dab",
"version": "2025-01-05",
"date": "Thu, 23 Jan 2025 17:53:23 GMT",
"deleteTypePermanent": true,
"clientRequestId": "x-ms-client-request-id"
}
}
]
}
}

View File

@@ -0,0 +1,115 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "99f866fa-f63c-477d-a0d0-48fbdb8a344a",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resource": "blob",
"operation": "get",
"container": { "__rl": true, "value": "mycontainer", "mode": "list" },
"blob": { "__rl": true, "value": "myblob", "mode": "list" },
"options": {
"leaseId": "leaseId123",
"origin": "origin123",
"simplify": false,
"upn": true
},
"requestOptions": {}
},
"type": "n8n-nodes-base.azureStorage",
"typeVersion": 1,
"position": [660, 0],
"id": "ab1b6258-5c75-4893-90bf-ef591264420c",
"name": "Azure Storage",
"credentials": {
"azureStorageSharedKeyApi": {
"id": "VPmcFM58eDDexWQL",
"name": "Azure Storage Shared Key account"
}
}
}
],
"connections": {
"When clicking Test workflow": {
"main": [[{ "node": "Azure Storage", "type": "main", "index": 0 }]]
}
},
"pinData": {
"Azure Storage": [
{
"binary": {
"data": {
"data": "ewoiZGF0YSI6ewoibXlfZmllbGRfMSI6InZhbHVlIiwKIm15X2ZpZWxkXzIiOjEKfQp9",
"fileExtension": "json",
"fileName": "file.json",
"fileSize": "51 B",
"fileType": "json",
"mimeType": "application/json"
}
},
"json": {
"name": "myblob",
"properties": {
"clientRequestId": "x-ms-client-request-id",
"lastModified": "last-modified",
"creationTime": "x-ms-creation-time",
"tagCount": "x-ms-tag-count",
"contentType": "application/json",
"contentRange": "content-range",
"etag": "\"0x22769D26D3F3740\"",
"contentMd5": "content-md5",
"contentCrc64": "x-ms-content-crc64",
"contentEncoding": "content-encoding",
"contentLanguage": "content-language",
"cacheControl": "cache-control",
"contentDisposition": "attachment; filename=\"file.json\"",
"blobSequenceNumber": "x-ms-blob-sequence-number",
"blobType": "x-ms-blob-type",
"copyCompletionTime": "x-ms-copy-completion-time",
"copyStatusDescription": "x-ms-copy-status-description",
"copyId": "x-ms-copy-id",
"copyProgress": "x-ms-copy-progress",
"copySource": "x-ms-copy-source",
"copyStatus": "x-ms-copy-status",
"incrementalCopy": "x-ms-incremental-copy",
"leaseDuration": "x-ms-lease-duration",
"leaseState": "x-ms-lease-state",
"leaseStatus": "x-ms-lease-status",
"accessControlAllowOrigin": "access-control-allow-origin",
"accessControlExposeHeaders": "access-control-expose-headers",
"vary": "vary",
"accessControlAllowCredentials": "access-control-allow-credentials",
"blobCommittedBlockCount": "x-ms-blob-committed-block-count",
"serverEncrypted": "x-ms-server-encrypted",
"encryptionKeySha256": "x-ms-encryption-key-sha256",
"encryptionContext": "x-ms-encryption-context",
"encryptionScope": "x-ms-encryption-scope",
"blobContentMd5": "x-ms-blob-content-md5",
"lastAccessTime": "x-ms-last-access-time",
"blobSealed": "x-ms-blob-sealed",
"immutabilityPolicyUntilDate": "x-ms-immutability-policy-until-date",
"immutabilityPolicyMode": "x-ms-immutability-policy-mode",
"legalHold": "x-ms-legal-hold",
"owner": "x-ms-owner",
"group": "x-ms-group",
"permissions": "x-ms-permissions",
"acl": "x-ms-acl",
"resourceType": "x-ms-resource-type",
"acceptRanges": "accept-ranges",
"date": "Thu, 23 Jan 2025 17:53:23 GMT",
"requestId": "75b87ee3-a7f7-468d-b7d1-e7e7b3173dab",
"version": "2025-01-05"
},
"metadata": { "key1": "value1" }
}
}
]
}
}

View File

@@ -0,0 +1,82 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "99f866fa-f63c-477d-a0d0-48fbdb8a344a",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resource": "blob",
"operation": "getAll",
"container": { "__rl": true, "value": "mycontainer", "mode": "list" },
"returnAll": true,
"options": { "simplify": false },
"requestOptions": {}
},
"type": "n8n-nodes-base.azureStorage",
"typeVersion": 1,
"position": [660, 0],
"id": "ab1b6258-5c75-4893-90bf-ef591264420c",
"name": "Azure Storage",
"credentials": {
"azureStorageSharedKeyApi": {
"id": "VPmcFM58eDDexWQL",
"name": "Azure Storage Shared Key account"
}
}
}
],
"connections": {
"When clicking Test workflow": {
"main": [[{ "node": "Azure Storage", "type": "main", "index": 0 }]]
}
},
"pinData": {
"Azure Storage": [
{
"json": {
"name": "myblob1",
"properties": {
"creationTime": "Wed, 22 Jan 2025 18:53:15 GMT",
"lastModified": "Wed, 22 Jan 2025 18:53:15 GMT",
"etag": "0x1F8268B228AA730",
"contentLength": 37,
"contentType": "application/json",
"contentMD5": "aWQGHD8kGQd5ZtEN/S1/aw==",
"blobType": "BlockBlob",
"leaseStatus": "unlocked",
"leaseState": "available",
"serverEncrypted": true,
"accessTier": "Hot",
"accessTierInferred": true,
"accessTierChangeTime": "Wed, 22 Jan 2025 18:53:15 GMT"
}
}
},
{
"json": {
"name": "myblob1",
"properties": {
"creationTime": "Wed, 22 Jan 2025 18:53:15 GMT",
"lastModified": "Wed, 22 Jan 2025 18:53:15 GMT",
"etag": "0x1F8268B228AA730",
"contentLength": 37,
"contentType": "application/json",
"contentMD5": "aWQGHD8kGQd5ZtEN/S1/aw==",
"blobType": "BlockBlob",
"leaseStatus": "unlocked",
"leaseState": "available",
"serverEncrypted": true,
"accessTier": "Hot",
"accessTierInferred": true,
"accessTierChangeTime": "Wed, 22 Jan 2025 18:53:15 GMT"
}
}
}
]
}
}

View File

@@ -0,0 +1,76 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "99f866fa-f63c-477d-a0d0-48fbdb8a344a",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resource": "blob",
"operation": "getAll",
"container": { "__rl": true, "value": "mycontainer", "mode": "list" },
"limit": 1,
"options": {
"fields": [
"copy",
"deleted",
"deletedwithversions",
"immutabilitypolicy",
"metadata",
"legalhold",
"versions",
"uncommittedblobs",
"tags",
"snapshots",
"permissions"
],
"filter": ["deleted", "files", "directories"],
"simplify": true,
"upn": true
},
"requestOptions": {}
},
"type": "n8n-nodes-base.azureStorage",
"typeVersion": 1,
"position": [660, 0],
"id": "ab1b6258-5c75-4893-90bf-ef591264420c",
"name": "Azure Storage",
"credentials": {
"azureStorageSharedKeyApi": {
"id": "VPmcFM58eDDexWQL",
"name": "Azure Storage account"
}
}
}
],
"connections": {
"When clicking Test workflow": {
"main": [[{ "node": "Azure Storage", "type": "main", "index": 0 }]]
}
},
"pinData": {
"Azure Storage": [
{
"json": {
"name": "myblob1",
"properties": {
"creationTime": "Wed, 22 Jan 2025 18:53:15 GMT",
"lastModified": "Wed, 22 Jan 2025 18:53:15 GMT",
"etag": "0x1F8268B228AA730",
"contentLength": 37,
"contentType": "application/json",
"contentMD5": "aWQGHD8kGQd5ZtEN/S1/aw==",
"blobType": "BlockBlob",
"leaseStatus": "unlocked",
"leaseState": "available",
"serverEncrypted": true
}
}
}
]
}
}

View File

@@ -1,64 +1,61 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_create.workflow.json'];
const workflowTests = workflowToTests(workflows);
const { baseUrl } = credentials.azureStorageOAuth2Api;
describe('should create blob', () => {
for (const workflow of workflowTests) {
workflow.nock = {
baseUrl: 'https://myaccount.blob.core.windows.net',
mocks: [
{
method: 'put',
path: '/mycontainer/myblob',
statusCode: 201,
requestHeaders: {
'x-ms-access-tier': 'Hot',
'x-ms-blob-type': 'BlockBlob',
'x-ms-blob-cache-control': 'no-cache',
'x-ms-content-crc64': '3EDB64E77CB16A4C',
'x-ms-blob-content-encoding': 'utf8',
'x-ms-blob-content-language': 'en-US',
'x-ms-blob-content-md5': 'b97f46db5f3be7709d942eefe30e5b45',
'x-ms-blob-content-type': 'application/json',
'x-ms-encryption-context': 'context',
'x-ms-encryption-scope': 'encryptionScope',
'x-ms-expiry-option': 'Absolute',
'x-ms-blob-content-disposition': 'attachment; filename="file.json"',
'x-ms-immutability-policy-until-date': 'Wed, 01 Jan 2025 00:00:00 -0500',
'x-ms-immutability-policy-mode': 'unlocked',
'x-ms-lease-id': 'leaseId123',
'x-ms-legal-hold': 'true',
'x-ms-meta-key1': 'value1',
},
responseBody: '',
responseHeaders: {
server: 'Azurite-Blob/3.33.0',
etag: '"0x22769D26D3F3740"',
'last-modified': 'Thu, 23 Jan 2025 17:53:23 GMT',
'content-md5': 'aWQGHD8kGQd5ZtEN/S1/aw==',
'x-ms-request-id': '75b87ee3-a7f7-468d-b7d1-e7e7b3173dab',
'x-ms-version': '2025-01-05',
date: 'Thu, 23 Jan 2025 17:53:23 GMT',
'x-ms-request-server-encrypted': 'true',
'keep-alive': 'timeout=5',
'content-length': '0',
'x-ms-version-id': 'Thu, 23 Jan 2025 17:53:23 GMT',
'access-control-allow-credentials': 'access-control-allow-credentials',
'access-control-allow-origin': 'access-control-allow-origin',
'access-control-expose-headers': 'access-control-expose-headers',
'x-ms-content-crc64': 'x-ms-content-crc64',
'x-ms-encryption-key-sha256': 'x-ms-encryption-key-sha256',
'x-ms-encryption-scope': 'x-ms-encryption-scope',
},
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['blob_create.workflow.json'],
nock: {
baseUrl,
mocks: [
{
method: 'put',
path: '/mycontainer/myblob',
statusCode: 201,
requestHeaders: {
'x-ms-access-tier': 'Hot',
'x-ms-blob-type': 'BlockBlob',
'x-ms-blob-cache-control': 'no-cache',
'x-ms-content-crc64': '3EDB64E77CB16A4C',
'x-ms-blob-content-encoding': 'utf8',
'x-ms-blob-content-language': 'en-US',
'x-ms-blob-content-md5': 'b97f46db5f3be7709d942eefe30e5b45',
'x-ms-blob-content-type': 'application/json',
'x-ms-encryption-context': 'context',
'x-ms-encryption-scope': 'encryptionScope',
'x-ms-expiry-option': 'Absolute',
'x-ms-blob-content-disposition': 'attachment; filename="file.json"',
'x-ms-immutability-policy-until-date': 'Wed, 01 Jan 2025 00:00:00 -0500',
'x-ms-immutability-policy-mode': 'unlocked',
'x-ms-lease-id': 'leaseId123',
'x-ms-legal-hold': 'true',
'x-ms-meta-key1': 'value1',
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
responseBody: '',
responseHeaders: {
server: 'Azurite-Blob/3.33.0',
etag: '"0x22769D26D3F3740"',
'last-modified': 'Thu, 23 Jan 2025 17:53:23 GMT',
'content-md5': 'aWQGHD8kGQd5ZtEN/S1/aw==',
'x-ms-request-id': '75b87ee3-a7f7-468d-b7d1-e7e7b3173dab',
'x-ms-version': '2025-01-05',
date: 'Thu, 23 Jan 2025 17:53:23 GMT',
'x-ms-request-server-encrypted': 'true',
'keep-alive': 'timeout=5',
'content-length': '0',
'x-ms-version-id': 'Thu, 23 Jan 2025 17:53:23 GMT',
'access-control-allow-credentials': 'access-control-allow-credentials',
'access-control-allow-origin': 'access-control-allow-origin',
'access-control-expose-headers': 'access-control-expose-headers',
'x-ms-content-crc64': 'x-ms-content-crc64',
'x-ms-encryption-key-sha256': 'x-ms-encryption-key-sha256',
'x-ms-encryption-scope': 'x-ms-encryption-scope',
},
},
],
},
});
});

View File

@@ -1,33 +1,30 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_delete.workflow.json'];
const workflowTests = workflowToTests(workflows);
const { baseUrl } = credentials.azureStorageOAuth2Api;
describe('should delete blob', () => {
for (const workflow of workflowTests) {
workflow.nock = {
baseUrl: 'https://myaccount.blob.core.windows.net',
mocks: [
{
method: 'delete',
path: '/mycontainer/myblob',
statusCode: 202,
responseBody: '',
responseHeaders: {
'x-ms-request-id': '75b87ee3-a7f7-468d-b7d1-e7e7b3173dab',
'x-ms-version': '2025-01-05',
date: 'Thu, 23 Jan 2025 17:53:23 GMT',
'x-ms-delete-type-permanent': 'true',
'x-ms-client-request-id': 'x-ms-client-request-id',
},
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['blob_delete.workflow.json'],
nock: {
baseUrl,
mocks: [
{
method: 'delete',
path: '/mycontainer/myblob',
statusCode: 202,
responseBody: '',
responseHeaders: {
'x-ms-request-id': '75b87ee3-a7f7-468d-b7d1-e7e7b3173dab',
'x-ms-version': '2025-01-05',
date: 'Thu, 23 Jan 2025 17:53:23 GMT',
'x-ms-delete-type-permanent': 'true',
'x-ms-client-request-id': 'x-ms-client-request-id',
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
},
],
},
});
});

View File

@@ -1,85 +1,82 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_get.workflow.json'];
const workflowTests = workflowToTests(workflows);
describe('should get blob', () => {
for (const workflow of workflowTests) {
workflow.nock = {
baseUrl: 'https://myaccount.blob.core.windows.net',
mocks: [
{
method: 'get',
path: '/mycontainer/myblob',
statusCode: 200,
responseBody: {
type: 'Buffer',
data: [
123, 10, 34, 100, 97, 116, 97, 34, 58, 123, 10, 34, 109, 121, 95, 102, 105, 101,
108, 100, 95, 49, 34, 58, 34, 118, 97, 108, 117, 101, 34, 44, 10, 34, 109, 121, 95,
102, 105, 101, 108, 100, 95, 50, 34, 58, 49, 10, 125, 10, 125,
],
},
responseHeaders: {
'x-ms-request-id': '75b87ee3-a7f7-468d-b7d1-e7e7b3173dab',
'x-ms-version': '2025-01-05',
date: 'Thu, 23 Jan 2025 17:53:23 GMT',
'x-ms-client-request-id': 'x-ms-client-request-id',
'last-modified': 'last-modified',
'x-ms-creation-time': 'x-ms-creation-time',
'x-ms-tag-count': 'x-ms-tag-count',
'content-type': 'application/json',
'content-range': 'content-range',
etag: '"0x22769D26D3F3740"',
'content-md5': 'content-md5',
'x-ms-content-crc64': 'x-ms-content-crc64',
'content-encoding': 'content-encoding',
'content-language': 'content-language',
'cache-control': 'cache-control',
'content-disposition': 'attachment; filename="file.json"',
'x-ms-blob-sequence-number': 'x-ms-blob-sequence-number',
'x-ms-blob-type': 'x-ms-blob-type',
'x-ms-copy-completion-time': 'x-ms-copy-completion-time',
'x-ms-copy-status-description': 'x-ms-copy-status-description',
'x-ms-copy-id': 'x-ms-copy-id',
'x-ms-copy-progress': 'x-ms-copy-progress',
'x-ms-copy-source': 'x-ms-copy-source',
'x-ms-copy-status': 'x-ms-copy-status',
'x-ms-incremental-copy': 'x-ms-incremental-copy',
'x-ms-lease-duration': 'x-ms-lease-duration',
'x-ms-lease-state': 'x-ms-lease-state',
'x-ms-lease-status': 'x-ms-lease-status',
'accept-ranges': 'accept-ranges',
'access-control-allow-origin': 'access-control-allow-origin',
'access-control-expose-headers': 'access-control-expose-headers',
vary: 'vary',
'access-control-allow-credentials': 'access-control-allow-credentials',
'x-ms-blob-committed-block-count': 'x-ms-blob-committed-block-count',
'x-ms-server-encrypted': 'x-ms-server-encrypted',
'x-ms-encryption-key-sha256': 'x-ms-encryption-key-sha256',
'x-ms-encryption-context': 'x-ms-encryption-context',
'x-ms-encryption-scope': 'x-ms-encryption-scope',
'x-ms-blob-content-md5': 'x-ms-blob-content-md5',
'x-ms-last-access-time': 'x-ms-last-access-time',
'x-ms-blob-sealed': 'x-ms-blob-sealed',
'x-ms-immutability-policy-until-date': 'x-ms-immutability-policy-until-date',
'x-ms-immutability-policy-mode': 'x-ms-immutability-policy-mode',
'x-ms-legal-hold': 'x-ms-legal-hold',
'x-ms-owner': 'x-ms-owner',
'x-ms-group': 'x-ms-group',
'x-ms-permissions': 'x-ms-permissions',
'x-ms-acl': 'x-ms-acl',
'x-ms-resource-type': 'x-ms-resource-type',
'x-ms-meta-key1': 'value1',
},
const { baseUrl } = credentials.azureStorageOAuth2Api;
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['blob_get.workflow.json'],
assertBinaryData: true,
nock: {
baseUrl,
mocks: [
{
method: 'get',
path: '/mycontainer/myblob',
statusCode: 200,
responseBody: {
type: 'Buffer',
data: [
123, 10, 34, 100, 97, 116, 97, 34, 58, 123, 10, 34, 109, 121, 95, 102, 105, 101, 108,
100, 95, 49, 34, 58, 34, 118, 97, 108, 117, 101, 34, 44, 10, 34, 109, 121, 95, 102,
105, 101, 108, 100, 95, 50, 34, 58, 49, 10, 125, 10, 125,
],
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
responseHeaders: {
'x-ms-request-id': '75b87ee3-a7f7-468d-b7d1-e7e7b3173dab',
'x-ms-version': '2025-01-05',
date: 'Thu, 23 Jan 2025 17:53:23 GMT',
'x-ms-client-request-id': 'x-ms-client-request-id',
'last-modified': 'last-modified',
'x-ms-creation-time': 'x-ms-creation-time',
'x-ms-tag-count': 'x-ms-tag-count',
'content-type': 'application/json',
'content-range': 'content-range',
etag: '"0x22769D26D3F3740"',
'content-md5': 'content-md5',
'x-ms-content-crc64': 'x-ms-content-crc64',
'content-encoding': 'content-encoding',
'content-language': 'content-language',
'cache-control': 'cache-control',
'content-disposition': 'attachment; filename="file.json"',
'x-ms-blob-sequence-number': 'x-ms-blob-sequence-number',
'x-ms-blob-type': 'x-ms-blob-type',
'x-ms-copy-completion-time': 'x-ms-copy-completion-time',
'x-ms-copy-status-description': 'x-ms-copy-status-description',
'x-ms-copy-id': 'x-ms-copy-id',
'x-ms-copy-progress': 'x-ms-copy-progress',
'x-ms-copy-source': 'x-ms-copy-source',
'x-ms-copy-status': 'x-ms-copy-status',
'x-ms-incremental-copy': 'x-ms-incremental-copy',
'x-ms-lease-duration': 'x-ms-lease-duration',
'x-ms-lease-state': 'x-ms-lease-state',
'x-ms-lease-status': 'x-ms-lease-status',
'accept-ranges': 'accept-ranges',
'access-control-allow-origin': 'access-control-allow-origin',
'access-control-expose-headers': 'access-control-expose-headers',
vary: 'vary',
'access-control-allow-credentials': 'access-control-allow-credentials',
'x-ms-blob-committed-block-count': 'x-ms-blob-committed-block-count',
'x-ms-server-encrypted': 'x-ms-server-encrypted',
'x-ms-encryption-key-sha256': 'x-ms-encryption-key-sha256',
'x-ms-encryption-context': 'x-ms-encryption-context',
'x-ms-encryption-scope': 'x-ms-encryption-scope',
'x-ms-blob-content-md5': 'x-ms-blob-content-md5',
'x-ms-last-access-time': 'x-ms-last-access-time',
'x-ms-blob-sealed': 'x-ms-blob-sealed',
'x-ms-immutability-policy-until-date': 'x-ms-immutability-policy-until-date',
'x-ms-immutability-policy-mode': 'x-ms-immutability-policy-mode',
'x-ms-legal-hold': 'x-ms-legal-hold',
'x-ms-owner': 'x-ms-owner',
'x-ms-group': 'x-ms-group',
'x-ms-permissions': 'x-ms-permissions',
'x-ms-acl': 'x-ms-acl',
'x-ms-resource-type': 'x-ms-resource-type',
'x-ms-meta-key1': 'value1',
},
},
],
},
});
});

View File

@@ -1,34 +1,28 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = ['nodes/Microsoft/Storage/test/workflows/blob_getAll.workflow.json'];
const workflowTests = workflowToTests(workflows);
describe('should get all blobs', () => {
for (const workflow of workflowTests) {
workflow.nock = {
baseUrl: 'https://myaccount.blob.core.windows.net',
mocks: [
{
method: 'get',
path: '/mycontainer?restype=container&comp=list',
statusCode: 200,
responseBody:
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EnumerationResults ServiceEndpoint="https://myaccount.blob.core.windows.net" ContainerName="item1"><Prefix/><Marker/><MaxResults>1</MaxResults><Blobs><Blob><Name>myblob1</Name><Properties><Creation-Time>Wed, 22 Jan 2025 18:53:15 GMT</Creation-Time><Last-Modified>Wed, 22 Jan 2025 18:53:15 GMT</Last-Modified><Etag>0x1F8268B228AA730</Etag><Content-Length>37</Content-Length><Content-Type>application/json</Content-Type><Content-MD5>aWQGHD8kGQd5ZtEN/S1/aw==</Content-MD5><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><AccessTierChangeTime>Wed, 22 Jan 2025 18:53:15 GMT</AccessTierChangeTime></Properties></Blob></Blobs><NextMarker>myblob2</NextMarker></EnumerationResults>',
},
{
method: 'get',
path: '/mycontainer?restype=container&comp=list&marker=myblob2',
statusCode: 200,
responseBody:
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EnumerationResults ServiceEndpoint="https://myaccount.blob.core.windows.net" ContainerName="item1"><Prefix/><Marker/><MaxResults>1</MaxResults><Blobs><Blob><Name>myblob1</Name><Properties><Creation-Time>Wed, 22 Jan 2025 18:53:15 GMT</Creation-Time><Last-Modified>Wed, 22 Jan 2025 18:53:15 GMT</Last-Modified><Etag>0x1F8268B228AA730</Etag><Content-Length>37</Content-Length><Content-Type>application/json</Content-Type><Content-MD5>aWQGHD8kGQd5ZtEN/S1/aw==</Content-MD5><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><AccessTierChangeTime>Wed, 22 Jan 2025 18:53:15 GMT</AccessTierChangeTime></Properties></Blob></Blobs><NextMarker></NextMarker></EnumerationResults>',
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
const { baseUrl } = credentials.azureStorageOAuth2Api;
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['blob_getAll.workflow.json'],
nock: {
baseUrl,
mocks: [
{
method: 'get',
path: '/mycontainer?restype=container&comp=list',
statusCode: 200,
responseBody: `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EnumerationResults ServiceEndpoint="${baseUrl}" ContainerName="item1"><Prefix/><Marker/><MaxResults>1</MaxResults><Blobs><Blob><Name>myblob1</Name><Properties><Creation-Time>Wed, 22 Jan 2025 18:53:15 GMT</Creation-Time><Last-Modified>Wed, 22 Jan 2025 18:53:15 GMT</Last-Modified><Etag>0x1F8268B228AA730</Etag><Content-Length>37</Content-Length><Content-Type>application/json</Content-Type><Content-MD5>aWQGHD8kGQd5ZtEN/S1/aw==</Content-MD5><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><AccessTierChangeTime>Wed, 22 Jan 2025 18:53:15 GMT</AccessTierChangeTime></Properties></Blob></Blobs><NextMarker>myblob2</NextMarker></EnumerationResults>`,
},
{
method: 'get',
path: '/mycontainer?restype=container&comp=list&marker=myblob2',
statusCode: 200,
responseBody: `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EnumerationResults ServiceEndpoint="${baseUrl}" ContainerName="item1"><Prefix/><Marker/><MaxResults>1</MaxResults><Blobs><Blob><Name>myblob1</Name><Properties><Creation-Time>Wed, 22 Jan 2025 18:53:15 GMT</Creation-Time><Last-Modified>Wed, 22 Jan 2025 18:53:15 GMT</Last-Modified><Etag>0x1F8268B228AA730</Etag><Content-Length>37</Content-Length><Content-Type>application/json</Content-Type><Content-MD5>aWQGHD8kGQd5ZtEN/S1/aw==</Content-MD5><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><AccessTierChangeTime>Wed, 22 Jan 2025 18:53:15 GMT</AccessTierChangeTime></Properties></Blob></Blobs><NextMarker></NextMarker></EnumerationResults>`,
},
],
},
});
});

View File

@@ -1,29 +1,22 @@
import { equalityTest, workflowToTests } from '@test/nodes/Helpers';
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import { credentials } from '../credentials';
describe('Azure Storage Node', () => {
const workflows = [
'nodes/Microsoft/Storage/test/workflows/blob_getAllLimitOptions.workflow.json',
];
const workflowTests = workflowToTests(workflows);
describe('should get all blobs with limit and options', () => {
for (const workflow of workflowTests) {
workflow.nock = {
baseUrl: 'https://myaccount.blob.core.windows.net',
mocks: [
{
method: 'get',
path: '/mycontainer?restype=container&comp=list&maxresults=1&include=copy%2Cdeleted%2Cdeletedwithversions%2Cimmutabilitypolicy%2Cmetadata%2Clegalhold%2Cversions%2Cuncommittedblobs%2Ctags%2Csnapshots%2Cpermissions&showonly=deleted%2Cfiles%2Cdirectories',
statusCode: 200,
responseBody:
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EnumerationResults ServiceEndpoint="https://myaccount.blob.core.windows.net" ContainerName="item1"><Prefix/><Marker/><MaxResults>1</MaxResults><Blobs><Blob><Name>myblob1</Name><Properties><Creation-Time>Wed, 22 Jan 2025 18:53:15 GMT</Creation-Time><Last-Modified>Wed, 22 Jan 2025 18:53:15 GMT</Last-Modified><Etag>0x1F8268B228AA730</Etag><Content-Length>37</Content-Length><Content-Type>application/json</Content-Type><Content-MD5>aWQGHD8kGQd5ZtEN/S1/aw==</Content-MD5><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><AccessTierChangeTime>Wed, 22 Jan 2025 18:53:15 GMT</AccessTierChangeTime></Properties></Blob></Blobs><NextMarker>myblob2</NextMarker></EnumerationResults>',
},
],
};
workflow.credentials = credentials;
test(workflow.description, async () => await equalityTest(workflow));
}
const { baseUrl } = credentials.azureStorageOAuth2Api;
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['blob_getAllLimitOptions.workflow.json'],
nock: {
baseUrl,
mocks: [
{
method: 'get',
path: '/mycontainer?restype=container&comp=list&maxresults=1&include=copy%2Cdeleted%2Cdeletedwithversions%2Cimmutabilitypolicy%2Cmetadata%2Clegalhold%2Cversions%2Cuncommittedblobs%2Ctags%2Csnapshots%2Cpermissions&showonly=deleted%2Cfiles%2Cdirectories',
statusCode: 200,
responseBody: `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EnumerationResults ServiceEndpoint="${baseUrl}" ContainerName="item1"><Prefix/><Marker/><MaxResults>1</MaxResults><Blobs><Blob><Name>myblob1</Name><Properties><Creation-Time>Wed, 22 Jan 2025 18:53:15 GMT</Creation-Time><Last-Modified>Wed, 22 Jan 2025 18:53:15 GMT</Last-Modified><Etag>0x1F8268B228AA730</Etag><Content-Length>37</Content-Length><Content-Type>application/json</Content-Type><Content-MD5>aWQGHD8kGQd5ZtEN/S1/aw==</Content-MD5><BlobType>BlockBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><AccessTierChangeTime>Wed, 22 Jan 2025 18:53:15 GMT</AccessTierChangeTime></Properties></Blob></Blobs><NextMarker>myblob2</NextMarker></EnumerationResults>`,
},
],
},
});
});