From e5e05e8ebf102b47044dae17a1cbc63ad92332bd Mon Sep 17 00:00:00 2001 From: Igor Braginsky Date: Mon, 20 Nov 2023 14:32:14 +0200 Subject: [PATCH] Refactored RBAC tests to adopt UI changes Signed-off-by: Igor Braginsky --- .../applicationinventory/analysis.ts | 10 ++-- .../applicationinventory/application.ts | 48 +++++-------------- cypress/e2e/tests/rbac/architect.test.ts | 39 ++++++++------- cypress/e2e/tests/rbac/migrator.test.ts | 38 ++++++++------- cypress/e2e/types/types.ts | 19 ++++---- cypress/fixtures/rbac.json | 42 +++++++--------- 6 files changed, 86 insertions(+), 110 deletions(-) diff --git a/cypress/e2e/models/migration/applicationinventory/analysis.ts b/cypress/e2e/models/migration/applicationinventory/analysis.ts index efe14c339..dbc0d9dfc 100644 --- a/cypress/e2e/models/migration/applicationinventory/analysis.ts +++ b/cypress/e2e/models/migration/applicationinventory/analysis.ts @@ -425,7 +425,7 @@ export class Analysis extends Application { static validateTopActionMenu(rbacRules: RbacValidationRules) { Application.open(); - if (rbacRules["Action menu"]["Not available"]) { + if (rbacRules["Top action menu"]["Not available"]) { cy.get(".pf-v5-c-page__main-section") .eq(1) .within(() => { @@ -439,10 +439,10 @@ export class Analysis extends Application { .within(() => { clickWithin(kebabTopMenuButton, button); }); - doesExistText("Import", rbacRules["Action menu"]["Import"]); - doesExistText("Manage imports", rbacRules["Action menu"]["Manage imports"]); - doesExistText("Manage credentials", rbacRules["Action menu"]["Manage credentials"]); - doesExistText("Delete", rbacRules["Action menu"]["Delete"]); + doesExistText("Import", rbacRules["Top action menu"]["Import"]); + doesExistText("Manage imports", rbacRules["Top action menu"]["Manage imports"]); + doesExistText("Manage credentials", rbacRules["Top action menu"]["Manage credentials"]); + doesExistText("Delete", rbacRules["Top action menu"]["Delete"]); } } diff --git a/cypress/e2e/models/migration/applicationinventory/application.ts b/cypress/e2e/models/migration/applicationinventory/application.ts index 62a8ef8a5..64266072e 100644 --- a/cypress/e2e/models/migration/applicationinventory/application.ts +++ b/cypress/e2e/models/migration/applicationinventory/application.ts @@ -382,7 +382,7 @@ export class Application { doesExistSelector(createAppButton, rbacRules["Create new"]); } - validateAnalysisAvailableActions(rbacRules: RbacValidationRules): void { + validateAppContextMenu(rbacRules: RbacValidationRules): void { Application.open(); selectItemsPerPage(100); cy.wait(SEC); @@ -391,51 +391,29 @@ export class Application { .closest(trTag) .within(() => { clickWithin("#row-actions", button); - doesExistButton(assessAppButton, rbacRules["Assess"]); + doesExistButton(assessAppButton, rbacRules["Application actions"]["Assess"]); + doesExistButton(reviewAppButton, rbacRules["Application actions"]["Review"]); doesExistText( - "Analysis details", - rbacRules["analysis applicable options"]["Analysis details"] - ); - // doesExistText( - // "Cancel analysis", - // rbacRules["analysis applicable options"]["Cancel analysis"] - // ); - doesExistText( - "Manage credentials", - rbacRules["analysis applicable options"]["Manage credentials"] - ); - doesExistText("Delete", rbacRules["analysis applicable options"]["Delete"]); - doesExistText( - "Discard review", - rbacRules["assessment applicable options"]["Discard assessment"] + "Discard assessment", + rbacRules["Application actions"]["Discard assessment"] ); + doesExistText("Discard review", rbacRules["Application actions"]["Discard review"]); + doesExistText("Delete", rbacRules["Application actions"]["Delete"]); doesExistText( "Manage dependencies", - rbacRules["assessment applicable options"]["Manage dependencies"] + rbacRules["Application actions"]["Manage dependencies"] ); - }); - } - - validateAssessmentAvailableOptions(rbacRules: RbacValidationRules): void { - Application.open(); - selectItemsPerPage(100); - cy.get(tdTag) - .contains(this.name) - .closest(trTag) - .within(() => { - click(selectBox); - cy.wait(SEC); - click(kebabButton); doesExistText( - "Discard review", - rbacRules["assessment applicable options"]["Discard assessment"] + "Manage credentials", + rbacRules["Application actions"]["Manage credentials"] ); doesExistText( - "Manage dependencies", - rbacRules["assessment applicable options"]["Manage dependencies"] + "Analysis details", + rbacRules["Application actions"]["Analysis details"] ); }); } + validateUploadBinary(rbacRules: RbacValidationRules): void { Application.open(); selectItemsPerPage(100); diff --git a/cypress/e2e/tests/rbac/architect.test.ts b/cypress/e2e/tests/rbac/architect.test.ts index 830614afe..27ea2f366 100644 --- a/cypress/e2e/tests/rbac/architect.test.ts +++ b/cypress/e2e/tests/rbac/architect.test.ts @@ -18,18 +18,19 @@ limitations under the License. import { User } from "../../models/keycloak/users/user"; import { getRandomCredentialsData, getRandomUserData } from "../../../utils/data_utils"; import { UserArchitect } from "../../models/keycloak/users/userArchitect"; -import { - createMultipleStakeholders, - getRandomApplicationData, - login, - logout, -} from "../../../utils/utils"; +import { deleteByList, getRandomApplicationData, login, logout } from "../../../utils/utils"; import { Analysis } from "../../models/migration/applicationinventory/analysis"; import { CredentialsSourceControlUsername } from "../../models/administration/credentials/credentialsSourceControlUsername"; -import { CredentialType } from "../../types/constants"; +import { CredentialType, SEC } from "../../types/constants"; import { Application } from "../../models/migration/applicationinventory/application"; import { Assessment } from "../../models/migration/applicationinventory/assessment"; import { Stakeholders } from "../../models/migration/controls/stakeholders"; +import { AssessmentQuestionnaire } from "../../models/administration/assessment_questionnaire/assessment_questionnaire"; +import * as data from "../../../utils/data_utils"; + +const stakeholdersList: Array = []; +const stakeholdersNameList: Array = []; +const fileName = "Legacy Pathfinder"; describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { let userArchitect = new UserArchitect(getRandomUserData()); @@ -41,9 +42,20 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { before("Creating RBAC users, adding roles for them", function () { login(); + AssessmentQuestionnaire.enable(fileName); + // Navigate to stakeholders control tab and create new stakeholder + const stakeholder = new Stakeholders(data.getEmail(), data.getFullName()); + stakeholder.create(); + cy.wait(2 * SEC); + + stakeholdersList.push(stakeholder); + stakeholdersNameList.push(stakeholder.name); + appCredentials.create(); application.create(); application.perform_review("low"); + application.perform_assessment("low", stakeholdersNameList); + logout(); User.loginKeycloakAdmin(); userArchitect.create(); @@ -63,16 +75,6 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { Application.validateCreateAppButton(this.rbacRules); }); - it("Architect, validate assess application button", function () { - //Architect is allowed to create applications - application.validateAssessButton(this.rbacRules); - }); - - it("Architect, validate review application button", function () { - //Architect is allowed to review applications - application.validateReviewButton(this.rbacRules); - }); - it("Architect, validate presence of import and manage imports", function () { //Architect is allowed to import applications Analysis.validateTopActionMenu(this.rbacRules); @@ -84,7 +86,7 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { }); it("Architect, validate analysis and assessment context menu buttons presence", function () { - application.validateAnalysisAvailableActions(this.rbacRules); + application.validateAppContextMenu(this.rbacRules); }); it("Architect, validate availability of binary upload functionality", function () { @@ -95,6 +97,7 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { userArchitect.logout(); login(); appCredentials.delete(); + deleteByList(stakeholdersList); application.delete(); logout(); User.loginKeycloakAdmin(); diff --git a/cypress/e2e/tests/rbac/migrator.test.ts b/cypress/e2e/tests/rbac/migrator.test.ts index 48ed4ffc0..0ff11a2a3 100644 --- a/cypress/e2e/tests/rbac/migrator.test.ts +++ b/cypress/e2e/tests/rbac/migrator.test.ts @@ -18,12 +18,19 @@ limitations under the License. import { User } from "../../models/keycloak/users/user"; import { getRandomCredentialsData, getRandomUserData } from "../../../utils/data_utils"; import { UserMigrator } from "../../models/keycloak/users/userMigrator"; -import { getRandomApplicationData, login, logout } from "../../../utils/utils"; +import { deleteByList, getRandomApplicationData, login, logout } from "../../../utils/utils"; import { Analysis } from "../../models/migration/applicationinventory/analysis"; import { CredentialsSourceControlUsername } from "../../models/administration/credentials/credentialsSourceControlUsername"; -import { CredentialType } from "../../types/constants"; +import { CredentialType, SEC } from "../../types/constants"; import { Application } from "../../models/migration/applicationinventory/application"; import { Assessment } from "../../models/migration/applicationinventory/assessment"; +import { Stakeholders } from "../../models/migration/controls/stakeholders"; +import { AssessmentQuestionnaire } from "../../models/administration/assessment_questionnaire/assessment_questionnaire"; +import * as data from "../../../utils/data_utils"; + +const stakeholdersList: Array = []; +const stakeholdersNameList: Array = []; +const fileName = "Legacy Pathfinder"; describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => { let userMigrator = new UserMigrator(getRandomUserData()); @@ -36,6 +43,15 @@ describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => { before("Creating RBAC users, adding roles for them", () => { //Need to log in as admin and create simple app with known name to use it for tests login(); + AssessmentQuestionnaire.enable(fileName); + // Navigate to stakeholders control tab and create new stakeholder + const stakeholder = new Stakeholders(data.getEmail(), data.getFullName()); + stakeholder.create(); + cy.wait(2 * SEC); + + stakeholdersList.push(stakeholder); + stakeholdersNameList.push(stakeholder.name); + appCredentials.create(); application.create(); application.perform_review("low"); @@ -59,16 +75,6 @@ describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => { Application.validateCreateAppButton(this.rbacRules); }); - it("Migrator, validate assess application button", function () { - //Migrator is not allowed to create applications - application.validateAssessButton(this.rbacRules); - }); - - it("Migrator, validate review application button", function () { - //Migrator is not allowed to review applications - application.validateReviewButton(this.rbacRules); - }); - it("Migrator, validate presence of import and manage imports", function () { //migrator is allowed to import applications Analysis.validateTopActionMenu(this.rbacRules); @@ -79,13 +85,10 @@ describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => { Analysis.validateAnalyzeButton(this.rbacRules); }); - it("Migrator, validate analysis details and cancel analysis buttons presence", function () { - application.validateAnalysisAvailableActions(this.rbacRules); + it("BUG MTA-1640 - Migrator, validate analysis details and cancel analysis buttons presence", function () { + application.validateAppContextMenu(this.rbacRules); }); - it("Migrator, validate assessment context menu buttons presence", function () { - application.validateAssessmentAvailableOptions(this.rbacRules); - }); it("Migrator, validate availability of binary upload functionality", function () { application.validateUploadBinary(this.rbacRules); }); @@ -94,6 +97,7 @@ describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => { userMigrator.logout(); login(); appCredentials.delete(); + deleteByList(stakeholdersList); application.delete(); logout(); User.loginKeycloakAdmin(); diff --git a/cypress/e2e/types/types.ts b/cypress/e2e/types/types.ts index 7085f5a0e..1d0500bf8 100644 --- a/cypress/e2e/types/types.ts +++ b/cypress/e2e/types/types.ts @@ -139,26 +139,23 @@ export type RbacValidationRules = { "Create new"?: boolean; Analyze?: boolean; "Upload binary"?: boolean; - Assess?: boolean; - Review?: boolean; Import?: boolean; - "Action menu"?: { + "Top action menu"?: { "Not available": boolean; Import?: boolean; "Manage imports"?: boolean; "Manage credentials"?: boolean; Delete?: boolean; }; - "analysis applicable options"?: { - "Analysis details"?: boolean; - "Cancel analysis"?: boolean; - "Manage credentials"?: boolean; - Delete?: boolean; - }; - "assessment applicable options"?: { + "Application actions"?: { + Assess?: boolean; + Review?: boolean; "Discard assessment"?: boolean; - "Copy assessment"?: boolean; + "Discard review"?: boolean; + Delete?: boolean; "Manage dependencies"?: boolean; + "Manage credentials"?: boolean; + "Analysis details"?: boolean; }; }; diff --git a/cypress/fixtures/rbac.json b/cypress/fixtures/rbac.json index 8d15f8fa4..455edced7 100644 --- a/cypress/fixtures/rbac.json +++ b/cypress/fixtures/rbac.json @@ -3,50 +3,44 @@ "Create new": true, "Analyze": true, "Upload binary": true, - "Assess": true, - "Review": true, - "Action menu": { + "Top action menu": { "Not available": false, "Import": true, "Manage imports": true, "Manage credentials": true, "Delete": true }, - "analysis applicable options": { - "Analysis details": true, - "Cancel analysis": true, - "Manage credentials": true, - "Delete": true - }, - "assessment applicable options": { + "Application actions": { + "Assess": true, + "Review": true, "Discard assessment": true, - "Copy assessment": true, - "Manage dependencies": true + "Discard review": true, + "Delete": true, + "Manage dependencies": true, + "Manage credentials": true, + "Analysis details": true } }, "migrator": { "Create new": false, "Analyze": true, "Upload binary": true, - "Assess": false, - "Review": false, - "Action menu": { + "Top action menu": { "Not available": true, "Import": false, "Manage imports": false, "Manage credentials": false, "Delete": false }, - "analysis applicable options": { - "Analysis details": true, - "Cancel analysis": true, - "Manage credentials": false, - "Delete": false - }, - "assessment applicable options": { + "Application actions": { + "Assess": false, + "Review": false, "Discard assessment": false, - "Copy assessment": false, - "Manage dependencies": true + "Discard review": false, + "Delete": false, + "Manage dependencies": true, + "Manage credentials": false, + "Analysis details": true } } }