first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,34 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Create Group', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_qqle3XBUA',
GroupName: 'MyNewGroup11',
})
.reply(200, {
Group: {
GroupName: 'MyNewGroup11',
UserPoolId: 'eu-central-1_qqle3XBUA',
CreationDate: 1743068959.243,
LastModifiedDate: 1743068959.243,
},
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['create.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,63 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [260, 360],
"id": "9ed2b86b-7c24-4ea0-a328-92d9e6dba35a",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"resource": "group",
"operation": "create",
"userPool": {
"__rl": true,
"value": "eu-central-1_qqle3XBUA",
"mode": "list",
"cachedResultName": "UserPoolThree"
},
"newGroupName": "MyNewGroup11",
"additionalFields": {},
"requestOptions": {}
},
"id": "fc6ee80d-3c8f-4ecc-a053-b4a717484c2a",
"name": "createGroup",
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [500, 360],
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"pinData": {
"createGroup": [
{
"json": {
"CreationDate": 1743068959.243,
"GroupName": "MyNewGroup11",
"LastModifiedDate": 1743068959.243,
"UserPoolId": "eu-central-1_qqle3XBUA"
}
}
]
},
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "createGroup",
"type": "main",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,35 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Delete Group', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_qqle3XBUA',
GroupName: 'MyNewGroup22',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DeleteGroup')
.reply(200, {
Group: {
GroupName: 'MyNewGroup22',
UserPoolId: 'eu-central-1_qqle3XBUA',
CreationDate: 1743068959.243,
LastModifiedDate: 1743068959.243,
},
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['delete.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,44 @@
{
"nodes": [
{
"parameters": {
"resource": "group",
"operation": "delete",
"userPool": {
"__rl": true,
"value": "eu-central-1_qqle3XBUA",
"mode": "list",
"cachedResultName": "UserPoolThree"
},
"group": {
"__rl": true,
"value": "MyNewGroup22",
"mode": "list",
"cachedResultName": "MyNewGroup22"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [200, 1300],
"id": "ece9e04f-305c-45ed-afc6-34d34303f8b0",
"name": "AWS Cognito1",
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {},
"pinData": {
"AWS Cognito1": [
{
"json": {
"deleted": true
}
}
]
}
}
@@ -0,0 +1,86 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Get Group', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_qqle3XBUA',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:123456789012:userpool/eu-central-1_qqle3XBUA',
CreationDate: 1739530218.869,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 4,
Id: 'eu-central-1_qqle3XBUA',
LastModifiedDate: 1739530218.869,
MfaConfiguration: 'OFF',
Name: 'UserPoolThree',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_qqle3XBUA',
Limit: 50,
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListGroups')
.reply(200, {
Groups: [
{
CreationDate: 1741609269.287,
GroupName: 'MyNewGroup2',
LastModifiedDate: 1741609269.287,
UserPoolId: 'eu-central-1_qqle3XBUA',
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_qqle3XBUA',
GroupName: 'MyNewGroup2',
Limit: 50,
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsersInGroup')
.reply(200, {
Users: [],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_qqle3XBUA',
GroupName: 'MyNewGroup2',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.GetGroup')
.reply(200, {
Group: {
CreationDate: 1741609269.287,
GroupName: 'MyNewGroup2',
LastModifiedDate: 1741609269.287,
UserPoolId: 'eu-central-1_qqle3XBUA',
},
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['get.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,47 @@
{
"nodes": [
{
"parameters": {
"resource": "group",
"operation": "get",
"userPool": {
"__rl": true,
"value": "eu-central-1_qqle3XBUA",
"mode": "list",
"cachedResultName": "UserPoolThree"
},
"group": {
"__rl": true,
"value": "MyNewGroup2",
"mode": "list",
"cachedResultName": "MyNewGroup2"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [200, 1300],
"id": "ece9e04f-305c-45ed-afc6-34d34303f8b0",
"name": "AWS Cognito1",
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {},
"pinData": {
"AWS Cognito1": [
{
"json": {
"CreationDate": 1741609269.287,
"GroupName": "MyNewGroup2",
"LastModifiedDate": 1741609269.287,
"UserPoolId": "eu-central-1_qqle3XBUA"
}
}
]
}
}
@@ -0,0 +1,144 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Get All Groups', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListGroups')
.reply(200, {
Groups: [
{
GroupName: 'MyNewGroup',
Description: 'Updated',
CreationDate: 1732740693.563,
LastModifiedDate: 1733422336.443,
Precedence: 0,
RoleArn: 'arn:aws:iam::123456789012:group/Admins',
UserPoolId: 'eu-central-1_KkXQgdCJv',
Users: [
{
Username: 'user1',
Attributes: [{ Name: 'email', Value: 'user1@example.com' }],
},
{
Username: 'user2',
Attributes: [{ Name: 'email', Value: 'user2@example.com' }],
},
],
},
{
GroupName: 'MyNewTesttttt',
Description: 'Updated description',
CreationDate: 1733424987.825,
LastModifiedDate: 1741609241.742,
Precedence: 5,
UserPoolId: 'eu-central-1_KkXQgdCJv',
Users: [],
},
{
GroupName: 'MyNewTest1',
Description: 'test',
CreationDate: 1733398042.783,
LastModifiedDate: 1733691256.447,
Precedence: 5,
UserPoolId: 'eu-central-1_KkXQgdCJv',
Users: [],
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
GroupName: 'MyNewGroup',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsersInGroup')
.reply(200, {
Users: [],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
GroupName: 'MyNewTesttttt',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsersInGroup')
.reply(200, {
Users: [],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
GroupName: 'MyNewTest1',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsersInGroup')
.reply(200, {
Users: [],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListGroups')
.reply(200, {
Groups: [
{
GroupName: 'MyNewGroup',
Description: 'Updated',
CreationDate: 1732740693.563,
LastModifiedDate: 1733422336.443,
Precedence: 0,
RoleArn: 'arn:aws:iam::123456789012:group/Admins',
UserPoolId: 'eu-central-1_KkXQgdCJv',
Users: [],
},
{
GroupName: 'MyNewTesttttt',
Description: 'Updated description',
CreationDate: 1733424987.825,
LastModifiedDate: 1741609241.742,
Precedence: 5,
UserPoolId: 'eu-central-1_KkXQgdCJv',
Users: [],
},
{
GroupName: 'MyNewTest1',
Description: 'test',
CreationDate: 1733398042.783,
LastModifiedDate: 1733691256.447,
Precedence: 5,
UserPoolId: 'eu-central-1_KkXQgdCJv',
Users: [],
},
],
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['getAll.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,89 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [260, 360],
"id": "9ed2b86b-7c24-4ea0-a328-92d9e6dba35a",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"resource": "group",
"userPool": {
"__rl": true,
"value": "eu-central-1_KkXQgdCJv",
"mode": "list",
"cachedResultName": "AWS test"
},
"returnAll": true,
"includeUsers": true,
"requestOptions": {}
},
"id": "f1d96de9-a43f-4452-8760-94fc13990e0b",
"name": "getAllGroups",
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [460, 360],
"alwaysOutputData": true,
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"pinData": {
"getAllGroups": [
{
"json": {
"CreationDate": 1732740693.563,
"Description": "Updated",
"GroupName": "MyNewGroup",
"LastModifiedDate": 1733422336.443,
"Precedence": 0,
"RoleArn": "arn:aws:iam::123456789012:group/Admins",
"UserPoolId": "eu-central-1_KkXQgdCJv",
"Users": []
}
},
{
"json": {
"CreationDate": 1733424987.825,
"Description": "Updated description",
"GroupName": "MyNewTesttttt",
"LastModifiedDate": 1741609241.742,
"Precedence": 5,
"UserPoolId": "eu-central-1_KkXQgdCJv",
"Users": []
}
},
{
"json": {
"CreationDate": 1733398042.783,
"Description": "test",
"GroupName": "MyNewTest1",
"LastModifiedDate": 1733691256.447,
"Precedence": 5,
"UserPoolId": "eu-central-1_KkXQgdCJv",
"Users": []
}
}
]
},
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "getAllGroups",
"type": "main",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,36 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Update Group', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
GroupName: 'MyNewTesttttt',
Description: 'Updated description',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.UpdateGroup')
.reply(200, {
Group: {
GroupName: 'MyNewTesttttt',
UserPoolId: 'eu-central-1_KkXQgdCJv',
Description: 'Updated description',
},
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['update.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,67 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-80, -100],
"id": "7da2ce49-9a9d-4240-b082-ff1b12d101b1",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"resource": "group",
"operation": "update",
"userPool": {
"__rl": true,
"value": "eu-central-1_KkXQgdCJv",
"mode": "list",
"cachedResultName": "AWS test"
},
"group": {
"__rl": true,
"value": "MyNewTesttttt",
"mode": "list",
"cachedResultName": "MyNewTesttttt"
},
"additionalFields": {
"description": "Updated description"
},
"requestOptions": {}
},
"id": "fd0610c8-9af2-4ca5-943f-f0de5d897fc0",
"name": "updateGroup",
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [160, -100],
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "updateGroup",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"updateGroup": [
{
"json": {
"updated": true
}
}
]
}
}
@@ -0,0 +1,701 @@
import { mock } from 'jest-mock-extended';
import type { MockProxy } from 'jest-mock-extended';
import type { IExecuteSingleFunctions, IHttpRequestOptions } from 'n8n-workflow';
import { NodeOperationError, NodeApiError } from 'n8n-workflow';
import {
getUserPool,
validateArn,
simplifyUserPool,
preSendUserFields,
preSendAttributes,
preSendDesiredDeliveryMediums,
getUsersInGroup,
simplifyUser,
getUserNameFromExistingUsers,
} from '../../helpers/utils';
import { searchUsers } from '../../methods/listSearch';
import { awsApiRequest, awsApiRequestAllItems } from '../../transport/index';
jest.mock('../../transport/index', () => ({
awsApiRequest: jest.fn(),
awsApiRequestAllItems: jest.fn(),
}));
jest.mock('../../methods/listSearch', () => ({
searchUsers: jest.fn(),
}));
describe('AWS Cognito - Helpers functions', () => {
let loadOptionsFunctions: MockProxy<IExecuteSingleFunctions>;
let mockRequestWithAuthentication: jest.Mock;
let mockReturnJsonArray: jest.Mock;
let requestOptions: IHttpRequestOptions;
beforeEach(() => {
loadOptionsFunctions = mock<IExecuteSingleFunctions>();
mockRequestWithAuthentication = jest.fn();
mockReturnJsonArray = jest.fn();
loadOptionsFunctions.helpers.httpRequestWithAuthentication = mockRequestWithAuthentication;
loadOptionsFunctions.helpers.returnJsonArray = mockReturnJsonArray;
loadOptionsFunctions.getCredentials.mockResolvedValue({
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
});
});
afterEach(() => {
jest.resetAllMocks();
});
describe('getUserPool', () => {
it('should fetch the user pool information', async () => {
const userPoolId = 'eu-central-1_W3WwpiBXV';
const mockResponse = {
UserPool: {
Id: userPoolId,
Name: 'UserPoolSimple',
},
};
(awsApiRequest as jest.Mock).mockResolvedValue(mockResponse);
const userPool = await getUserPool.call(loadOptionsFunctions, userPoolId);
expect(userPool).toEqual({ Id: userPoolId, Name: 'UserPoolSimple' });
});
it('should throw an error if user pool ID is missing', async () => {
await expect(getUserPool.call(loadOptionsFunctions, '')).rejects.toThrowError(
NodeOperationError,
);
});
it('should throw an error if user pool is not found', async () => {
const userPoolId = 'invalid-user-pool-id';
(awsApiRequest as jest.Mock).mockResolvedValue({});
await expect(getUserPool.call(loadOptionsFunctions, userPoolId)).rejects.toThrowError(
NodeOperationError,
);
});
});
describe('getUsersInGroup', () => {
it('should throw an error if UserPoolId is missing', async () => {
loadOptionsFunctions.getNodeParameter.mockReturnValue(undefined);
await expect(
getUsersInGroup.call(loadOptionsFunctions, 'groupName', ''),
).rejects.toThrowError(NodeOperationError);
});
it('should return an empty list if no users are found', async () => {
(loadOptionsFunctions.getNodeParameter as jest.Mock).mockReturnValue('userPoolId');
(awsApiRequestAllItems as jest.Mock).mockResolvedValue([]);
const result = await getUsersInGroup.call(loadOptionsFunctions, 'groupName', 'userPoolId');
expect(result).toEqual([]);
});
it('should return users correctly', async () => {
const mockUsers = [
{
Username: 'user1',
Enabled: true,
Attributes: [{ Name: 'email', Value: 'user1@example.com' }],
},
{
Username: 'user2',
Enabled: true,
Attributes: [{ Name: 'email', Value: 'user2@example.com' }],
},
];
(awsApiRequestAllItems as jest.Mock).mockResolvedValue(mockUsers);
const result = await getUsersInGroup.call(loadOptionsFunctions, 'groupName', 'userPoolId');
expect(result).toEqual([
{
Username: 'user1',
Enabled: true,
Attributes: [
{
Name: 'email',
Value: 'user1@example.com',
},
],
},
{
Username: 'user2',
Enabled: true,
Attributes: [
{
Name: 'email',
Value: 'user2@example.com',
},
],
},
]);
});
it('should handle empty attributes and missing values', async () => {
const mockUsers = [
{
Username: 'user1',
Enabled: true,
Attributes: [{ Name: 'email', Value: '' }],
},
];
(awsApiRequestAllItems as jest.Mock).mockResolvedValue(mockUsers);
const result = await getUsersInGroup.call(loadOptionsFunctions, 'groupName', 'userPoolId');
expect(result).toEqual([
{
Username: 'user1',
Enabled: true,
Attributes: [
{
Name: 'email',
Value: '',
},
],
},
]);
});
});
describe('validateArn', () => {
it('should validate the ARN format', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.arn') {
return 'arn:aws:iam::123456789012:role/GroupRole';
}
return '';
});
requestOptions = {
body: { additionalFields: { arn: 'arn:aws:iam::123456789012:role/GroupRole' } },
headers: {},
url: 'example.com',
};
const result = await validateArn.call(loadOptionsFunctions, requestOptions);
expect(result).toEqual(requestOptions);
});
it('should throw an error if the ARN format is invalid', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.arn') {
return 'invalid-arn';
}
return '';
});
requestOptions = {
body: { additionalFields: { arn: 'invalid-arn' } },
headers: {},
url: 'example.com',
};
await expect(validateArn.call(loadOptionsFunctions, requestOptions)).rejects.toThrowError(
NodeApiError,
);
});
});
describe('simplifyUserPool', () => {
it('should simplify the user pool data when simple is true', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation(() => true);
const items = [{ json: { UserPool: { Id: 'userPoolId', Name: 'UserPoolName' } } }];
const result = await simplifyUserPool.call(loadOptionsFunctions, items, {
body: {},
headers: {},
statusCode: 200,
});
expect(result).toEqual([{ json: { UserPool: { Id: 'userPoolId', Name: 'UserPoolName' } } }]);
});
});
describe('simplifyUserData', () => {
it('should simplify a single user with UserAttributes when simple is true', async () => {
loadOptionsFunctions.getNodeParameter.mockReturnValue(true);
const items = [
{
json: {
UserAttributes: [{ Name: 'email', Value: 'user@example.com' }],
},
},
];
const result = await simplifyUser.call(loadOptionsFunctions, items, {
body: {},
headers: {},
statusCode: 200,
});
expect(result).toEqual([{ json: { email: 'user@example.com' } }]);
});
it('should simplify multiple users in Users array when simple is true', async () => {
loadOptionsFunctions.getNodeParameter.mockReturnValue(true);
const items = [
{
json: {
Users: [
{
Attributes: [{ Name: 'email', Value: 'user1@example.com' }],
},
],
},
},
];
const result = await simplifyUser.call(loadOptionsFunctions, items, {
body: {},
headers: {},
statusCode: 200,
});
expect(result).toEqual([
{
json: {
Users: [{ email: 'user1@example.com' }],
},
},
]);
});
it('should return original items when simple is false', async () => {
const items = [
{
json: {
UserAttributes: [{ Name: 'email', Value: 'user@example.com' }],
},
},
];
const result = await simplifyUser.call(loadOptionsFunctions, items, {
body: {},
headers: {},
statusCode: 200,
});
expect(result).toEqual(items);
});
});
describe('getUserNameFromExistingUsers', () => {
const userPoolId = 'eu-central-1_KkXQgdCJv';
const userName = '03a438f2-10d1-70f1-f45a-09753ab5c4c3';
it('should return the userName if email or phone is used for authentication', async () => {
const isEmailOrPhone = true;
const result = await getUserNameFromExistingUsers.call(
loadOptionsFunctions,
userName,
userPoolId,
isEmailOrPhone,
);
expect(result).toEqual(userName);
});
it('should return the username from ListUsers API when it is not email or phone authentication', async () => {
const isEmailOrPhone = false;
const mockApiResponse = {
Users: [{ Username: 'existing-user' }],
};
(awsApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
const result = await getUserNameFromExistingUsers.call(
loadOptionsFunctions,
userName,
userPoolId,
isEmailOrPhone,
);
expect(result).toEqual('existing-user');
});
it('should return undefined if no user is found in ListUsers API', async () => {
const isEmailOrPhone = false;
const mockApiResponse = {
Users: [],
};
(awsApiRequest as jest.Mock).mockResolvedValue(mockApiResponse);
const result = await getUserNameFromExistingUsers.call(
loadOptionsFunctions,
userName,
userPoolId,
isEmailOrPhone,
);
expect(result).toBeUndefined();
});
});
describe('preSendUserFields', () => {
beforeEach(() => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'userPool') return 'test-pool-id';
if (name === 'newUserName') return 'test@example.com';
return undefined;
});
});
it('should return the request body with the correct username when operation is "create" and valid email is provided', async () => {
requestOptions = {
body: JSON.stringify({ someField: 'value' }),
method: 'POST',
url: '',
headers: {},
};
(awsApiRequest as jest.Mock).mockResolvedValue({
UserPool: { UsernameAttributes: ['email'] },
});
const result = await preSendUserFields.call(loadOptionsFunctions, requestOptions);
expect(result.body).toEqual(
JSON.stringify({
someField: 'value',
Username: 'test@example.com',
}),
);
});
it('should return the request body with the correct username when operation is "update" and user exists', async () => {
requestOptions = {
body: JSON.stringify({ someField: 'value' }),
method: 'POST',
url: '',
headers: {},
};
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'update';
if (name === 'user') return 'existing-user';
if (name === 'userPool') return 'eu-central-1_KkXQgdCJv';
return undefined;
});
(awsApiRequest as jest.Mock).mockResolvedValue({
UserPool: { UsernameAttributes: ['email'] },
});
(searchUsers as jest.Mock).mockResolvedValue({
results: [{ name: 'existing-user', value: 'existing-user' }],
});
const result = await preSendUserFields.call(loadOptionsFunctions, requestOptions);
expect(result.body).toEqual(
JSON.stringify({
someField: 'value',
Username: 'existing-user',
}),
);
});
it('should return the request body without a username when operation is "update" and no user is found', async () => {
requestOptions = {
body: JSON.stringify({ someField: 'value' }),
method: 'POST',
url: '',
headers: {},
};
loadOptionsFunctions.getNodeParameter.mockImplementationOnce((name: string) => {
if (name === 'operation') return 'update';
if (name === 'user') return 'non-existing-user';
return undefined;
});
(awsApiRequest as jest.Mock).mockResolvedValue({
UserPool: { UsernameAttributes: ['email'] },
});
(searchUsers as jest.Mock).mockResolvedValue({
results: [],
});
const result = await preSendUserFields.call(loadOptionsFunctions, requestOptions);
expect(result.body).toEqual(
JSON.stringify({
someField: 'value',
}),
);
});
});
describe('preSendAttributes', () => {
beforeEach(() => {
requestOptions = {
body: JSON.stringify({ someField: 'value' }),
method: 'POST',
url: '',
headers: {},
};
});
it('should throw an error if no user attributes are provided (update operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'update';
if (name === 'userAttributes.attributes') return [];
return undefined;
});
await expect(
preSendAttributes.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError(
new NodeOperationError(loadOptionsFunctions.getNode(), 'No user attributes provided', {
description: 'At least one user attribute must be provided for the update operation.',
}),
);
});
it('should throw an error if a user attribute is invalid (empty value) (create operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'additionalFields.userAttributes.attributes') {
return [{ attributeType: 'standard', standardName: 'email', value: '' }];
}
return undefined;
});
await expect(
preSendAttributes.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError(
new NodeOperationError(loadOptionsFunctions.getNode(), 'Invalid User Attribute', {
description: 'Each attribute must have a valid name and value.',
}),
);
});
it('should throw an error if email_verified is true but email is missing (create operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'additionalFields.userAttributes.attributes') {
return [{ attributeType: 'standard', standardName: 'email_verified', value: 'true' }];
}
return undefined;
});
await expect(
preSendAttributes.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError(
new NodeOperationError(
loadOptionsFunctions.getNode(),
'Missing required "email" attribute',
{
description:
'"email_verified" is set to true, but the corresponding "email" attribute is not provided.',
},
),
);
});
it('should throw an error if phone_number_verified is true but phone_number is missing (create operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'additionalFields.userAttributes.attributes') {
return [
{ attributeType: 'standard', standardName: 'phone_number_verified', value: 'true' },
];
}
return undefined;
});
await expect(
preSendAttributes.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError(
new NodeOperationError(
loadOptionsFunctions.getNode(),
'Missing required "phone_number" attribute',
{
description:
'"phone_number_verified" is set to true, but the corresponding "phone_number" attribute is not provided.',
},
),
);
});
it('should add the user attribute to the body when valid (create operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'additionalFields.userAttributes.attributes') {
return [
{ attributeType: 'standard', standardName: 'email', value: 'test@example.com' },
{ attributeType: 'standard', standardName: 'phone_number', value: '1234567890' },
];
}
return undefined;
});
const result = await preSendAttributes.call(loadOptionsFunctions, requestOptions);
expect(result.body).toEqual(
JSON.stringify({
someField: 'value',
UserAttributes: [
{ Name: 'email', Value: 'test@example.com' },
{ Name: 'phone_number', Value: '1234567890' },
],
}),
);
});
it('should correctly process custom attributes (create operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'additionalFields.userAttributes.attributes') {
return [
{
attributeType: 'custom',
customName: 'custom_attr',
value: 'custom_value',
},
];
}
return undefined;
});
const result = await preSendAttributes.call(loadOptionsFunctions, requestOptions);
expect(result.body).toEqual(
JSON.stringify({
someField: 'value',
UserAttributes: [{ Name: 'custom:custom_attr', Value: 'custom_value' }],
}),
);
});
it('should throw an error if a custom attribute has no name or value (create operation)', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'operation') return 'create';
if (name === 'additionalFields.userAttributes.attributes') {
return [{ attributeType: 'custom', customName: '', value: '' }];
}
return undefined;
});
await expect(
preSendAttributes.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError(
new NodeOperationError(loadOptionsFunctions.getNode(), 'Invalid User Attribute', {
description: 'Each attribute must have a valid name and value.',
}),
);
});
});
describe('preSendDesiredDeliveryMediums', () => {
beforeEach(() => {
requestOptions = { body: {}, url: '' };
});
it('should not throw an error if EMAIL is selected and email is provided', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.desiredDeliveryMediums') {
return ['EMAIL'];
}
if (name === 'additionalFields.userAttributes.attributes') {
return [
{ standardName: 'email', value: 'test@example.com' },
{ standardName: 'phone_number', value: '1234567890' },
];
}
return undefined;
});
await expect(
preSendDesiredDeliveryMediums.call(loadOptionsFunctions, requestOptions),
).resolves.toEqual(requestOptions);
});
it('should throw an error if EMAIL is selected but email is missing', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.desiredDeliveryMediums') {
return ['EMAIL'];
}
if (name === 'additionalFields.userAttributes.attributes') {
return [{ standardName: 'phone_number', value: '1234567890' }];
}
return undefined;
});
await expect(
preSendDesiredDeliveryMediums.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError('Missing required "email" attribute');
});
it('should not throw an error if SMS is selected and phone number is provided', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.desiredDeliveryMediums') {
return ['SMS'];
}
if (name === 'additionalFields.userAttributes.attributes') {
return [
{ standardName: 'email', value: 'test@example.com' },
{ standardName: 'phone_number', value: '1234567890' },
];
}
return undefined;
});
await expect(
preSendDesiredDeliveryMediums.call(loadOptionsFunctions, requestOptions),
).resolves.toEqual(requestOptions);
});
it('should throw an error if SMS is selected but phone number is missing', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.desiredDeliveryMediums') {
return ['SMS'];
}
if (name === 'additionalFields.userAttributes.attributes') {
return [{ standardName: 'email', value: 'test@example.com' }];
}
return undefined;
});
await expect(
preSendDesiredDeliveryMediums.call(loadOptionsFunctions, requestOptions),
).rejects.toThrowError('Missing required "phone_number" attribute');
});
it('should not throw an error if both EMAIL and SMS are selected and both attributes are provided', async () => {
loadOptionsFunctions.getNodeParameter.mockImplementation((name: string) => {
if (name === 'additionalFields.desiredDeliveryMediums') {
return ['EMAIL', 'SMS'];
}
if (name === 'additionalFields.userAttributes.attributes') {
return [
{ standardName: 'email', value: 'test@example.com' },
{ standardName: 'phone_number', value: '1234567890' },
];
}
return undefined;
});
await expect(
preSendDesiredDeliveryMediums.call(loadOptionsFunctions, requestOptions),
).resolves.toEqual(requestOptions);
});
});
});
@@ -0,0 +1,252 @@
import {
ApplicationError,
type ILoadOptionsFunctions,
type INodeListSearchResult,
} from 'n8n-workflow';
import type { IUserPool } from '../../helpers/interfaces';
import {
searchUsers,
searchGroups,
searchUserPools,
searchGroupsForUser,
} from '../../methods/listSearch';
import { awsApiRequest, awsApiRequestAllItems } from '../../transport/index';
jest.mock('../../transport/index', () => ({
awsApiRequest: jest.fn(),
awsApiRequestAllItems: jest.fn(),
}));
describe('AWS Cognito Functions', () => {
describe('searchUsers', () => {
it('should return user results when users are found', async () => {
const mockDescribeUserPoolResponse = {
UserPool: {
UsernameAttributes: ['email'],
},
};
const mockResponse = {
Users: [
{
Username: 'User1',
Attributes: [
{ Name: 'email', Value: 'user1@example.com' },
{ Name: 'phone_number', Value: '1234567890' },
{ Name: 'sub', Value: 'sub1' },
],
},
{
Username: 'User2',
Attributes: [
{ Name: 'email', Value: 'user2@example.com' },
{ Name: 'phone_number', Value: '9876543210' },
{ Name: 'sub', Value: 'sub2' },
],
},
],
NextToken: 'next-token',
};
(awsApiRequest as jest.Mock)
.mockResolvedValueOnce(mockDescribeUserPoolResponse)
.mockResolvedValueOnce(mockResponse);
const mockContext = {
getNodeParameter: jest.fn((param) => {
if (param === 'userPool') {
return 'user-pool-id';
}
return null;
}),
} as unknown as ILoadOptionsFunctions;
const result = await searchUsers.call(mockContext, '', '');
const expectedResult: INodeListSearchResult = {
results: [
{ name: 'user1@example.com', value: 'sub1' },
{ name: 'user2@example.com', value: 'sub2' },
],
paginationToken: 'next-token',
};
expect(result).toEqual(expectedResult);
expect(awsApiRequest).toHaveBeenCalledWith(
'POST',
'ListUsers',
expect.stringContaining('UserPoolId'),
);
});
it('should throw an error if UserPoolId is missing', async () => {
const mockContext = {
getNodeParameter: jest.fn().mockReturnValue(''),
getNode: jest.fn(),
} as unknown as ILoadOptionsFunctions;
await expect(searchUsers.call(mockContext)).rejects.toThrow(
'User Pool ID is required to search users',
);
});
});
describe('searchGroups', () => {
it('should return group results when groups are found', async () => {
const mockResponse = {
Groups: [
{ GroupName: 'Group1', UserPoolId: 'user-pool-id' },
{ GroupName: 'Group2', UserPoolId: 'user-pool-id' },
],
NextToken: 'next-token',
};
(awsApiRequest as jest.Mock).mockResolvedValue(mockResponse);
const mockContext = {
getNodeParameter: jest.fn((param) => {
if (param === 'userPool') {
return { value: 'user-pool-id' };
}
return null;
}),
} as unknown as ILoadOptionsFunctions;
const result = await searchGroups.call(mockContext, '', '');
const expectedResult: INodeListSearchResult = {
results: [
{ name: 'Group1', value: 'Group1' },
{ name: 'Group2', value: 'Group2' },
],
paginationToken: 'next-token',
};
expect(result).toEqual(expectedResult);
expect(awsApiRequest).toHaveBeenCalledWith(
'POST',
'ListGroups',
expect.stringContaining('UserPoolId'),
);
});
it('should throw an error if UserPoolId is missing', async () => {
const mockContext = {
getNodeParameter: jest.fn().mockReturnValue(null),
getNode: jest.fn(),
} as unknown as ILoadOptionsFunctions;
await expect(searchGroups.call(mockContext)).rejects.toThrow(ApplicationError);
});
});
describe('searchUserPools', () => {
it('should return user pool results when user pools are found', async () => {
const mockResponse = {
UserPools: [
{ Id: 'pool1', Name: 'User Pool 1' },
{ Id: 'pool2', Name: 'User Pool 2' },
],
NextToken: 'next-token',
};
(awsApiRequest as jest.Mock).mockResolvedValue(mockResponse);
const mockContext = {
getNodeParameter: jest.fn((param) => {
if (param === 'userPool') {
return { value: 'user-pool-id' };
}
return null;
}),
} as unknown as ILoadOptionsFunctions;
const result = await searchUserPools.call(mockContext, '', '');
const expectedResult: INodeListSearchResult = {
results: [
{ name: 'UserPool1', value: 'pool1' },
{ name: 'UserPool2', value: 'pool2' },
],
paginationToken: 'next-token',
};
expect(result).toEqual(expectedResult);
expect(awsApiRequest).toHaveBeenCalledWith(
'POST',
'ListUserPools',
expect.stringContaining('Limit'),
);
});
});
describe('searchGroupsForUser', () => {
const userName = '03a438f2-10d1-70f1-f45a-09753ab5c4c3';
const userPoolId = 'eu-central-1_KkXQgdCJv';
const mockContext = {
getNodeParameter: jest.fn((param) => {
if (param === 'user') return userName;
if (param === 'userPool') return userPoolId;
return null;
}),
getNode: jest.fn(() => ({
name: 'mockNode',
})),
} as unknown as ILoadOptionsFunctions;
beforeEach(() => {
(awsApiRequest as jest.Mock).mockResolvedValueOnce({
UserPool: {
Id: userPoolId,
UsernameAttributes: ['email', 'phone_number'],
},
} as { UserPool: IUserPool });
});
it('should handle empty groups response', async () => {
(awsApiRequestAllItems as jest.Mock).mockResolvedValueOnce([]);
const result = await searchGroupsForUser.call(mockContext, '');
const expectedResult: INodeListSearchResult = {
results: [],
};
expect(result).toEqual(expectedResult);
});
it('should return filtered and sorted group list', async () => {
const mockGroups = [
{ GroupName: 'Developers' },
{ GroupName: 'Admins' },
{ GroupName: 'Guests' },
];
(awsApiRequestAllItems as jest.Mock).mockResolvedValueOnce(mockGroups);
const result = await searchGroupsForUser.call(mockContext, 'dev');
expect(result).toEqual({
results: [{ name: 'Developers', value: 'Developers' }],
});
});
it('should return all groups when no filter is passed', async () => {
const mockGroups = [{ GroupName: 'Zeta' }, { GroupName: 'Alpha' }, { GroupName: 'Beta' }];
(awsApiRequestAllItems as jest.Mock).mockResolvedValueOnce(mockGroups);
const result = await searchGroupsForUser.call(mockContext);
expect(result).toEqual({
results: [
{ name: 'Alpha', value: 'Alpha' },
{ name: 'Beta', value: 'Beta' },
{ name: 'Zeta', value: 'Zeta' },
],
});
});
});
});
@@ -0,0 +1,74 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Add User to Group', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_W3WwpiBXV',
CreationDate: 1739530218.869,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 4,
Id: 'eu-central-1_W3WwpiBXV',
LastModifiedDate: 1739530218.869,
MfaConfiguration: 'OFF',
Name: 'UserPoolSimple',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
Filter: 'sub = "0394e8e2-5081-7020-06bd-44bdfc84dd10"',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: '0394e8e2-5081-7020-06bd-44bdfc84dd10',
Attributes: [
{ Name: 'email', Value: 'UserSimple' },
{ Name: 'Sub', Value: '0394e8e2-5081-7020-06bd-44bdfc84dd10' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1736343033.226 },
{ Name: 'UserLastModifiedDate', Value: 1736343033.226 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
Username: '0394e8e2-5081-7020-06bd-44bdfc84dd10',
GroupName: 'MyNewGroupSimple',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminAddUserToGroup')
.reply(200, {});
});
new NodeTestHarness().setupTests({
workflowFiles: ['addToGroup.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,69 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-80, -100],
"id": "7da2ce49-9a9d-4240-b082-ff1b12d101b1",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"operation": "addToGroup",
"userPool": {
"__rl": true,
"value": "eu-central-1_W3WwpiBXV",
"mode": "list",
"cachedResultName": "UserPoolSimple"
},
"user": {
"__rl": true,
"value": "0394e8e2-5081-7020-06bd-44bdfc84dd10",
"mode": "list",
"cachedResultName": "UserSimple"
},
"group": {
"__rl": true,
"value": "MyNewGroupSimple",
"mode": "list",
"cachedResultName": "MyNewGroupSimple"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [100, -100],
"id": "0accb395-3cdb-4c3f-8adc-1a47567c37b5",
"name": "AWS Cognito",
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "AWS Cognito",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"AWS Cognito": [
{
"json": {
"addedToGroup": true
}
}
]
}
}
@@ -0,0 +1,57 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Create User', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Id: 'eu-central-1_W3WwpiBXV',
Name: 'MyUserPool',
CreationDate: 1627891230,
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
Username: 'Johnn12',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminCreateUser')
.reply(200, {
User: {
Username: 'Johnn12',
UserStatus: 'FORCE_CHANGE_PASSWORD',
Attributes: [
{
Name: 'sub',
Value: '03d43812-00c1-7098-075e-8a535fdefc1b',
},
],
UserCreateDate: 1743068750.761,
UserLastModifiedDate: 1743068750.761,
Enabled: true,
},
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['create.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,70 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [260, 360],
"id": "9ed2b86b-7c24-4ea0-a328-92d9e6dba35a",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"operation": "create",
"userPool": {
"__rl": true,
"value": "eu-central-1_W3WwpiBXV",
"mode": "list",
"cachedResultName": "UserPoolSimple"
},
"newUserName": "Johnn12",
"additionalFields": {},
"requestOptions": {}
},
"id": "ea53747b-2354-486c-9a9d-bac3dd88bacb",
"name": "createUser",
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [460, 360],
"alwaysOutputData": true,
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"pinData": {
"createUser": [
{
"json": {
"Attributes": [
{
"Name": "sub",
"Value": "03d43812-00c1-7098-075e-8a535fdefc1b"
}
],
"Enabled": true,
"UserCreateDate": 1743068750.761,
"UserLastModifiedDate": 1743068750.761,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"Username": "Johnn12"
}
}
]
},
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "createUser",
"type": "main",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,74 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Delete User', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_EUZ4iEF1T',
CreationDate: 1739530218.869,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 4,
Id: 'eu-central-1_EUZ4iEF1T',
LastModifiedDate: 1739530218.869,
MfaConfiguration: 'OFF',
Name: 'UserPoolTwo',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Filter: 'sub = "53c4f8c2-c071-707b-debd-d45585618da0"',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: '53c4f8c2-c071-707b-debd-d45585618da0',
Attributes: [
{ Name: 'email', Value: 'UserSimple' },
{ Name: 'Sub', Value: '53c4f8c2-c071-707b-debd-d45585618da0' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1736343033.226 },
{ Name: 'UserLastModifiedDate', Value: 1736343033.226 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Username: '53c4f8c2-c071-707b-debd-d45585618da0',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminDeleteUser')
.reply(200, {
Message: 'User successfully deleted',
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['delete.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,63 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-80, -100],
"id": "7da2ce49-9a9d-4240-b082-ff1b12d101b1",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"operation": "delete",
"userPool": {
"__rl": true,
"value": "eu-central-1_EUZ4iEF1T",
"mode": "list",
"cachedResultName": "UserPoolTwo"
},
"user": {
"__rl": true,
"value": "53c4f8c2-c071-707b-debd-d45585618da0",
"mode": "list",
"cachedResultName": "userName12"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [0, 40],
"id": "bc3483ef-4922-4759-a51d-12e5bd996628",
"name": "AWS Cognito",
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "AWS Cognito",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"AWS Cognito": [
{
"json": {
"deleted": true
}
}
]
}
}
@@ -0,0 +1,83 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Get User', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_EUZ4iEF1T',
CreationDate: 1739530218.869,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 4,
Id: 'eu-central-1_EUZ4iEF1T',
LastModifiedDate: 1739530218.869,
MfaConfiguration: 'OFF',
Name: 'UserPoolSimple',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Filter: 'sub = "b30498c2-d0f1-70a8-4b0c-3da25a3b998f"',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: 'userName10',
UserAttributes: [
{ Name: 'sub', Value: 'b30498c2-d0f1-70a8-4b0c-3da25a3b998f' },
{ Name: 'family_name', Value: 'New FamilyName 2' },
],
UserCreateDate: 1744206331.569,
UserLastModifiedDate: 1744206366.034,
Enabled: true,
UserStatus: 'FORCE_CHANGE_PASSWORD',
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Username: 'userName10',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminGetUser')
.reply(200, {
Username: 'userName10',
UserAttributes: [
{ Name: 'sub', Value: 'b30498c2-d0f1-70a8-4b0c-3da25a3b998f' },
{ Name: 'family_name', Value: 'New FamilyName 2' },
],
UserCreateDate: 1744206331.569,
UserLastModifiedDate: 1744206366.034,
Enabled: true,
UserStatus: 'FORCE_CHANGE_PASSWORD',
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['get.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,70 @@
{
"nodes": [
{
"parameters": {},
"id": "4570d7a2-f10a-495d-8a0e-8520b638649e",
"name": "When clicking Execute workflow",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-780, 380]
},
{
"parameters": {
"operation": "get",
"userPool": {
"__rl": true,
"value": "eu-central-1_EUZ4iEF1T",
"mode": "list",
"cachedResultName": "UserPoolTwo"
},
"user": {
"__rl": true,
"value": "b30498c2-d0f1-70a8-4b0c-3da25a3b998f",
"mode": "list",
"cachedResultName": "userName10"
},
"requestOptions": {}
},
"id": "2105b4ec-0db4-40f5-9d38-78c0fe20708f",
"name": "getUser",
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [-620, 500],
"alwaysOutputData": true,
"credentials": {
"aws": {
"id": "exampleId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "getUser",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"getUser": [
{
"json": {
"Enabled": true,
"UserCreateDate": 1744206331.569,
"UserLastModifiedDate": 1744206366.034,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"Username": "userName10",
"family_name": "New FamilyName 2",
"sub": "b30498c2-d0f1-70a8-4b0c-3da25a3b998f"
}
}
]
}
}
@@ -0,0 +1,64 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Get All Users', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_KkXQgdCJv',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: '034448d2-4011-7079-9474-9a4fccd4247a',
Attributes: [
{ Name: 'email', Value: 'FinalUser@gmail.com' },
{ Name: 'Sub', Value: '034448d2-4011-7079-9474-9a4fccd4247a' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1736343033.226 },
{ Name: 'UserLastModifiedDate', Value: 1736343033.226 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
{
Username: '03a438f2-10d1-70f1-f45a-09753ab5c4c3',
Attributes: [
{ Name: 'email', Value: 'mail.this1@gmail.com' },
{ Name: 'Sub', Value: '03a438f2-10d1-70f1-f45a-09753ab5c4c3' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1733746687.223 },
{ Name: 'UserLastModifiedDate', Value: 1733746687.223 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
{
Username: '03f438d2-b0f1-70bc-04d9-f6dd31f2d878',
Attributes: [
{ Name: 'email', Value: 'test3@gmail.com' },
{ Name: 'Sub', Value: '03f438d2-b0f1-70bc-04d9-f6dd31f2d878' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1742928785.796 },
{ Name: 'UserLastModifiedDate', Value: 1742928785.796 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
],
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['getAll.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,86 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [260, 360],
"id": "9ed2b86b-7c24-4ea0-a328-92d9e6dba35a",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"userPool": {
"__rl": true,
"value": "eu-central-1_KkXQgdCJv",
"mode": "list",
"cachedResultName": "AWS test"
},
"returnAll": true,
"requestOptions": {}
},
"id": "e788623f-5d4a-4e76-b7f6-3e9389e2fe29",
"name": "getAllUsers",
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [460, 360],
"alwaysOutputData": true,
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"pinData": {
"getAllUsers": [
{
"json": {
"Enabled": true,
"UserCreateDate": 1736343033.226,
"UserLastModifiedDate": 1736343033.226,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"Username": "034448d2-4011-7079-9474-9a4fccd4247a",
"email": "FinalUser@gmail.com",
"Sub": "034448d2-4011-7079-9474-9a4fccd4247a"
}
},
{
"json": {
"Enabled": true,
"UserCreateDate": 1733746687.223,
"UserLastModifiedDate": 1733746687.223,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"Username": "03a438f2-10d1-70f1-f45a-09753ab5c4c3",
"email": "mail.this1@gmail.com",
"Sub": "03a438f2-10d1-70f1-f45a-09753ab5c4c3"
}
},
{
"json": {
"Enabled": true,
"UserCreateDate": 1742928785.796,
"UserLastModifiedDate": 1742928785.796,
"UserStatus": "FORCE_CHANGE_PASSWORD",
"Username": "03f438d2-b0f1-70bc-04d9-f6dd31f2d878",
"email": "test3@gmail.com",
"Sub": "03f438d2-b0f1-70bc-04d9-f6dd31f2d878"
}
}
]
},
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "getAllUsers",
"type": "main",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,74 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Remove User From Group', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_W3WwpiBXV',
CreationDate: 1739530218.869,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 4,
Id: 'eu-central-1_W3WwpiBXV',
LastModifiedDate: 1739530218.869,
MfaConfiguration: 'OFF',
Name: 'UserPoolSimple',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
Filter: 'sub = "0394e8e2-5081-7020-06bd-44bdfc84dd10"',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: '0394e8e2-5081-7020-06bd-44bdfc84dd10',
Attributes: [
{ Name: 'email', Value: 'UserSimple' },
{ Name: 'Sub', Value: '0394e8e2-5081-7020-06bd-44bdfc84dd10' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1736343033.226 },
{ Name: 'UserLastModifiedDate', Value: 1736343033.226 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
Username: '0394e8e2-5081-7020-06bd-44bdfc84dd10',
GroupName: 'MyNewGroupSimple',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminRemoveUserFromGroup')
.reply(200, {});
});
new NodeTestHarness().setupTests({
workflowFiles: ['removeFromGroup.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,69 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-80, -100],
"id": "7da2ce49-9a9d-4240-b082-ff1b12d101b1",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"operation": "removeFromGroup",
"userPool": {
"__rl": true,
"value": "eu-central-1_W3WwpiBXV",
"mode": "list",
"cachedResultName": "UserPoolSimple"
},
"user": {
"__rl": true,
"value": "0394e8e2-5081-7020-06bd-44bdfc84dd10",
"mode": "list",
"cachedResultName": "UserSimple"
},
"group": {
"__rl": true,
"value": "MyNewGroupSimple",
"mode": "list",
"cachedResultName": "MyNewGroupSimple"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [100, -100],
"id": "0accb395-3cdb-4c3f-8adc-1a47567c37b5",
"name": "AWS Cognito",
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "AWS Cognito",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"AWS Cognito": [
{
"json": {
"removedFromGroup": true
}
}
]
}
}
@@ -0,0 +1,79 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Update User', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_EUZ4iEF1T',
CreationDate: 1739530218.869,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 4,
Id: 'eu-central-1_EUZ4iEF1T',
LastModifiedDate: 1739530218.869,
MfaConfiguration: 'OFF',
Name: 'UserPoolTwo',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Filter: 'sub = "43045822-80e1-70f6-582d-78ae7992e9d9"',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: '43045822-80e1-70f6-582d-78ae7992e9d9',
Attributes: [
{ Name: 'email', Value: 'UserSimple' },
{ Name: 'Sub', Value: '43045822-80e1-70f6-582d-78ae7992e9d9' },
{ Name: 'Enabled', Value: true },
{ Name: 'UserCreateDate', Value: 1736343033.226 },
{ Name: 'UserLastModifiedDate', Value: 1736343033.226 },
{ Name: 'UserStatus', Value: 'FORCE_CHANGE_PASSWORD' },
],
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Username: '43045822-80e1-70f6-582d-78ae7992e9d9',
UserAttributes: [
{
Name: 'address',
Value: 'New',
},
],
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminUpdateUserAttributes')
.reply(200, {});
});
new NodeTestHarness().setupTests({
workflowFiles: ['update.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,71 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-80, -100],
"id": "7da2ce49-9a9d-4240-b082-ff1b12d101b1",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"operation": "update",
"userPool": {
"__rl": true,
"value": "eu-central-1_EUZ4iEF1T",
"mode": "list",
"cachedResultName": "UserPoolTwo"
},
"user": {
"__rl": true,
"value": "43045822-80e1-70f6-582d-78ae7992e9d9",
"mode": "list",
"cachedResultName": "Johnn"
},
"userAttributes": {
"attributes": [
{
"standardName": "address",
"value": "New"
}
]
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [120, -100],
"id": "4c6bdeea-f863-4974-b3d6-7dfc04f78df3",
"name": "AWS Cognito",
"credentials": {
"aws": {
"id": "exampleId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "AWS Cognito",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"AWS Cognito": [
{
"json": {
"updated": true
}
}
]
}
}
@@ -0,0 +1,83 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
describe('AWS Cognito - Get User Pool', () => {
beforeEach(() => {
const baseUrl = 'https://cognito-idp.eu-central-1.amazonaws.com/';
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_W3WwpiBXV',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.DescribeUserPool')
.reply(200, {
UserPool: {
Arn: 'arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_W3WwpiBXV',
CreationDate: 1739527771.267,
DeletionProtection: 'INACTIVE',
EstimatedNumberOfUsers: 8,
Id: 'eu-central-1_W3WwpiBXV',
LastModifiedDate: 1739527771.267,
MfaConfiguration: 'OFF',
Name: 'UserPoolSimple',
},
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Limit: 50,
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.ListUsers')
.reply(200, {
Users: [
{
Username: 'userName10',
UserAttributes: [
{ Name: 'sub', Value: 'b30498c2-d0f1-70a8-4b0c-3da25a3b998f' },
{ Name: 'family_name', Value: 'New FamilyName 2' },
],
UserCreateDate: 1744206331.569,
UserLastModifiedDate: 1744206366.034,
Enabled: true,
UserStatus: 'FORCE_CHANGE_PASSWORD',
},
],
});
nock(baseUrl)
.persist()
.defaultReplyHeaders({ 'Content-Type': 'application/x-amz-json-1.1' })
.post('/', {
UserPoolId: 'eu-central-1_EUZ4iEF1T',
Username: 'b30498c2-d0f1-70a8-4b0c-3da25a3b998f',
})
.matchHeader('x-amz-target', 'AWSCognitoIdentityProviderService.AdminGetUser')
.reply(200, {
Username: 'userName10',
UserAttributes: [
{ Name: 'sub', Value: 'b30498c2-d0f1-70a8-4b0c-3da25a3b998f' },
{ Name: 'family_name', Value: 'New FamilyName 2' },
],
UserCreateDate: 1744206331.569,
UserLastModifiedDate: 1744206366.034,
Enabled: true,
UserStatus: 'FORCE_CHANGE_PASSWORD',
});
});
new NodeTestHarness().setupTests({
workflowFiles: ['get.workflow.json'],
credentials: {
aws: {
region: 'eu-central-1',
accessKeyId: 'test',
secretAccessKey: 'test',
},
},
});
});
@@ -0,0 +1,64 @@
{
"nodes": [
{
"parameters": {},
"id": "4570d7a2-f10a-495d-8a0e-8520b638649e",
"name": "When clicking Execute workflow",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-700, 320]
},
{
"parameters": {
"resource": "userPool",
"userPool": {
"__rl": true,
"value": "eu-central-1_W3WwpiBXV",
"mode": "list",
"cachedResultName": "UserPoolSimple"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.awsCognito",
"typeVersion": 1,
"position": [-700, 500],
"id": "fc734bb9-acd3-4b7d-a2a3-0a7b664e3c5a",
"name": "AWS Cognito2",
"credentials": {
"aws": {
"id": "testId",
"name": "AWS account Central Europe"
}
}
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "AWS Cognito2",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"AWS Cognito2": [
{
"json": {
"Arn": "arn:aws:cognito-idp:eu-central-1:130450532146:userpool/eu-central-1_W3WwpiBXV",
"CreationDate": 1739527771.267,
"DeletionProtection": "INACTIVE",
"EstimatedNumberOfUsers": 8,
"Id": "eu-central-1_W3WwpiBXV",
"LastModifiedDate": 1739527771.267,
"MfaConfiguration": "OFF",
"Name": "UserPoolSimple"
}
}
]
}
}