From 2370bdf647602e7b81913838f5fef8988256f458 Mon Sep 17 00:00:00 2001 From: Maayan Hadasi <60384172+mguetta1@users.noreply.github.com> Date: Mon, 19 Aug 2024 17:54:03 +0300 Subject: [PATCH] [RFR]Added admin user to perform post-upgrade tests (#1194) * Adding admin user to perform post-upgrade tests Signed-off-by: Maayan Hadasi * Changes after review Signed-off-by: Maayan Hadasi --------- Signed-off-by: Maayan Hadasi --- cypress/e2e/tests/upgrade/after_upgrade.test.ts | 14 +++++++++++--- .../e2e/tests/upgrade/create_upgrade_data.test.ts | 15 +++++++++++++++ cypress/fixtures/upgrade-data.json | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/tests/upgrade/after_upgrade.test.ts b/cypress/e2e/tests/upgrade/after_upgrade.test.ts index 99c08b055..84a5e926f 100644 --- a/cypress/e2e/tests/upgrade/after_upgrade.test.ts +++ b/cypress/e2e/tests/upgrade/after_upgrade.test.ts @@ -45,12 +45,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); }); diff --git a/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts b/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts index fd2b0d3b3..10e4947f5 100644 --- a/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts +++ b/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts @@ -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; @@ -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(); + }); }); diff --git a/cypress/fixtures/upgrade-data.json b/cypress/fixtures/upgrade-data.json index 53f29c56a..267ff1c6f 100644 --- a/cypress/fixtures/upgrade-data.json +++ b/cypress/fixtures/upgrade-data.json @@ -12,5 +12,6 @@ "uploadBinaryApplicationName": "upgrade-uploadBinaryApp", "assessmentApplicationName": "upgrade-assessmentApplication", "archetypeName": "upgrade-archetype", - "importedQuestionnaireAppName": "upgrade-questionnaireApplication" + "importedQuestionnaireAppName": "upgrade-questionnaireApplication", + "adminUser": "upgrade-admin-user" }