Skip to content

Commit

Permalink
CMDCT-4247 - changes import of users
Browse files Browse the repository at this point in the history
  • Loading branch information
peoplespete committed Jan 29, 2025
1 parent 3b257e7 commit f6ae3fd
Show file tree
Hide file tree
Showing 9 changed files with 542 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ jobs:
working-directory: tests/cypress
spec: integration/**/*
browser: chrome
headed: true
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
Expand Down
1 change: 1 addition & 0 deletions services/app-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@aws-sdk/client-ssm": "^3.709.0",
"@aws-sdk/lib-dynamodb": "^3.709.0",
"aws-jwt-verify": "^4.0.1",
"jwt-decode": "^4.0.0",
"kafkajs": "^1.16.0",
"uuid": "^7.0.3"
}
Expand Down
5 changes: 5 additions & 0 deletions services/app-api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,11 @@ has-flag@^3.0.0:
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=

jwt-decode@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-4.0.0.tgz#2270352425fd413785b2faf11f6e755c5151bd4b"
integrity sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==

kafkajs@^1.16.0:
version "1.16.0"
resolved "https://registry.yarnpkg.com/kafkajs/-/kafkajs-1.16.0.tgz#bfcc3ae2b69265ca8435b53a01ee9e8787b9fee5"
Expand Down
2 changes: 1 addition & 1 deletion services/ui-auth/handlers/createUsers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as cognitolib from "../libs/cognito-lib.js";
const userPoolId = process.env.userPoolId;
import users from "../libs/users.json" assert { type: "json" };
import users from "../libs/users.js";

export async function handler(_event, _context, _callback) {
for (let user of users) {
Expand Down
30 changes: 3 additions & 27 deletions services/ui-auth/libs/cognito-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,13 @@ const COGNITO_CLIENT = new CognitoIdentityProviderClient({
});

export async function createUser(params) {
await new Promise((resolve, _reject) => {
try {
COGNITO_CLIENT.send(new AdminCreateUserCommand(params));
resolve({ statusCode: 200, body: { message: "SUCCESS" } });
} catch (err) {
console.log("FAILED ", err, err.stack); // eslint-disable-line no-console
resolve({ statusCode: 500, body: { message: "FAILED", error: err } }); //if user already exists, we still continue and ignore
}
});
await COGNITO_CLIENT.send(new AdminCreateUserCommand(params));
}

export async function setPassword(params) {
await new Promise((resolve, reject) => {
try {
COGNITO_CLIENT.send(new AdminSetUserPasswordCommand(params));
resolve({ statusCode: 200, body: { message: "SUCCESS" } });
} catch (err) {
console.log("FAILED to update password", err, err.stack); // eslint-disable-line no-console
reject({ statusCode: 500, body: { message: "FAILED", error: err } });
}
});
await COGNITO_CLIENT.send(new AdminSetUserPasswordCommand(params));
}

export async function updateUserAttributes(params) {
await new Promise((resolve, reject) => {
try {
COGNITO_CLIENT.send(new AdminUpdateUserAttributesCommand(params));
resolve({ statusCode: 200, body: { message: "SUCCESS" } });
} catch (err) {
console.log("FAILED to update user attributes", err, err.stack); // eslint-disable-line no-console
reject({ statusCode: 500, body: { message: "FAILED", error: err } });
}
});
await COGNITO_CLIENT.send(new AdminUpdateUserAttributesCommand(params));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
const users = [
{
"username": "[email protected]",
"attributes": [
Expand Down Expand Up @@ -100,3 +100,5 @@
]
}
]

export default users;
6 changes: 4 additions & 2 deletions tests/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"dependencies": {
},
"devDependencies": {
"@badeball/cypress-cucumber-preprocessor": "^11.5.1",
"@cypress/webpack-preprocessor": "^6.0.0",
"concurrently": "^6.2.1",
"cypress": "^8.3.1",
"cypress-file-upload": "^5.0.8",
"cypress-xpath": "^1.6.2"
"cypress-xpath": "^1.6.2",
"webpack": "^5.97.1"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true,
Expand Down
Loading

0 comments on commit f6ae3fd

Please sign in to comment.