Skip to content

Commit

Permalink
[RFR]Added admin user to perform post-upgrade tests (#1194)
Browse files Browse the repository at this point in the history
* Adding admin user to perform post-upgrade tests

Signed-off-by: Maayan Hadasi <[email protected]>

* Changes after review

Signed-off-by: Maayan Hadasi <[email protected]>

---------

Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 authored Aug 19, 2024
1 parent 22a761a commit bcdc7c0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 11 additions & 3 deletions cypress/e2e/tests/upgrade/after_upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@ import { AssessmentQuestionnaire } from "../../models/administration/assessment_
import { cloudReadinessQuestionnaire, legacyPathfinder } from "../../types/constants";
import { Application } from "../../models/migration/applicationinventory/application";
import { Archetype } from "../../models/migration/archetypes/archetype";
import { UserAdmin } from "../../models/keycloak/users/userAdmin";
import { getRandomUserData } from "../../../utils/data_utils";

describe(["@post-upgrade"], "Performing post-upgrade validations", () => {
const expectedMtaVersion = Cypress.env("mtaVersion");
before("Login", function () {
// Perform login
login();
before("Login as created admin user", function () {
cy.fixture("upgrade-data").then((upgradeData: UpgradeData) => {
this.upgradeData = upgradeData;
const userAdmin = new UserAdmin(getRandomUserData());
userAdmin.username = this.upgradeData.adminUser;
userAdmin.password = Cypress.env("pass");
userAdmin.login();
});

AssessmentQuestionnaire.enable(legacyPathfinder);
});

Expand Down
15 changes: 15 additions & 0 deletions cypress/e2e/tests/upgrade/create_upgrade_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import { UpgradeData } from "../../types/types";
import { CredentialsMaven } from "../../models/administration/credentials/credentialsMaven";
import { AssessmentQuestionnaire } from "../../models/administration/assessment_questionnaire/assessment_questionnaire";
import { Archetype } from "../../models/migration/archetypes/archetype";
import { UserAdmin } from "../../models/keycloak/users/userAdmin";
import { User } from "../../models/keycloak/users/user";
import { getRandomUserData } from "../../../utils/data_utils";

describe(["@pre-upgrade"], "Creating pre-requisites before an upgrade", () => {
let mavenCredentialsUsername: CredentialsMaven;
Expand Down Expand Up @@ -231,4 +234,16 @@ describe(["@pre-upgrade"], "Creating pre-requisites before an upgrade", () => {
AssessmentQuestionnaire.enable(legacyPathfinder);
AssessmentQuestionnaire.disable(cloudReadinessQuestionnaire);
});

it("Create new admin user to use after upgrade", function () {
const user = this.upgradeData.adminUser;
const password = Cypress.env("pass");
const userAdmin = new UserAdmin(getRandomUserData());
userAdmin.username = this.upgradeData.adminUser;
userAdmin.password = Cypress.env("pass");

//Logging in as keycloak admin to create new user
User.loginKeycloakAdmin();
userAdmin.create();
});
});
3 changes: 2 additions & 1 deletion cypress/fixtures/upgrade-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"uploadBinaryApplicationName": "upgrade-uploadBinaryApp",
"assessmentApplicationName": "upgrade-assessmentApplication",
"archetypeName": "upgrade-archetype",
"importedQuestionnaireAppName": "upgrade-questionnaireApplication"
"importedQuestionnaireAppName": "upgrade-questionnaireApplication",
"adminUser": "upgrade-admin-user"
}

0 comments on commit bcdc7c0

Please sign in to comment.