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 8787176a1..64266072e 100644 --- a/cypress/e2e/models/migration/applicationinventory/application.ts +++ b/cypress/e2e/models/migration/applicationinventory/application.ts @@ -67,6 +67,7 @@ import { doesExistButton, validateTextPresence, validateNumberPresence, + clickWithin, } from "../../../../utils/utils"; import { AppIssue, applicationData, RbacValidationRules } from "../../../types/types"; import { kebabButton, rightSideMenu, sourceDropdown } from "../../../views/analysis.view"; @@ -381,55 +382,40 @@ export class Application { doesExistSelector(createAppButton, rbacRules["Create new"]); } - validateAnalysisAvailableActions(rbacRules: RbacValidationRules): void { + validateAppContextMenu(rbacRules: RbacValidationRules): void { Application.open(); - clickByText(navTab, analysis); selectItemsPerPage(100); - cy.wait(5 * SEC); + cy.wait(SEC); cy.get(tdTag) .contains(this.name) .closest(trTag) .within(() => { - click(`${kebabMenu} > button`); + clickWithin("#row-actions", button); + doesExistButton(assessAppButton, rbacRules["Application actions"]["Assess"]); + doesExistButton(reviewAppButton, rbacRules["Application actions"]["Review"]); doesExistText( - "Analysis details", - rbacRules["analysis applicable options"]["Analysis details"] + "Discard assessment", + rbacRules["Application actions"]["Discard assessment"] ); + doesExistText("Discard review", rbacRules["Application actions"]["Discard review"]); + doesExistText("Delete", rbacRules["Application actions"]["Delete"]); doesExistText( - "Cancel analysis", - rbacRules["analysis applicable options"]["Cancel analysis"] + "Manage dependencies", + rbacRules["Application actions"]["Manage dependencies"] ); doesExistText( "Manage credentials", - rbacRules["analysis applicable options"]["Manage credentials"] - ); - doesExistText("Delete", rbacRules["analysis applicable options"]["Delete"]); - }); - } - - 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 assessment/review", - rbacRules["assessment applicable options"]["Discard assessment"] + 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(); - clickByText(button, analysis); selectItemsPerPage(100); this.selectApplication(); cy.contains("button", analyzeButton, { timeout: 20 * SEC }) diff --git a/cypress/e2e/tests/rbac/architect.test.ts b/cypress/e2e/tests/rbac/architect.test.ts index aef668bcd..d6bc238d4 100644 --- a/cypress/e2e/tests/rbac/architect.test.ts +++ b/cypress/e2e/tests/rbac/architect.test.ts @@ -18,12 +18,18 @@ 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 { 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, legacyPathfinder, 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 = []; describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { let userArchitect = new UserArchitect(getRandomUserData()); @@ -35,9 +41,20 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { before("Creating RBAC users, adding roles for them", function () { login(); + AssessmentQuestionnaire.enable(legacyPathfinder); + // 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(); @@ -57,17 +74,7 @@ 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 () { + it("Architect, validate content of top kebab menu", function () { //Architect is allowed to import applications Analysis.validateTopActionMenu(this.rbacRules); }); @@ -77,12 +84,8 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () { Analysis.validateAnalyzeButton(this.rbacRules); }); - it("Architect, validate analysis details and cancel analysis buttons presence", function () { - application.validateAnalysisAvailableActions(this.rbacRules); - }); - - it("Architect, validate assessment context menu buttons presence", function () { - application.validateAssessmentAvailableOptions(this.rbacRules); + it("Architect, validate content of application kebab menu", function () { + application.validateAppContextMenu(this.rbacRules); }); it("Architect, validate availability of binary upload functionality", function () { @@ -93,6 +96,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..d87ce4a79 100644 --- a/cypress/e2e/tests/rbac/migrator.test.ts +++ b/cypress/e2e/tests/rbac/migrator.test.ts @@ -18,12 +18,18 @@ 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, legacyPathfinder, 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 = []; describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => { let userMigrator = new UserMigrator(getRandomUserData()); @@ -36,6 +42,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(legacyPathfinder); + // 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,17 +74,7 @@ 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 () { + it("Migrator, validate content of top kebab menu", function () { //migrator is allowed to import applications Analysis.validateTopActionMenu(this.rbacRules); }); @@ -79,13 +84,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 content of application kebab menu", 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 +96,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 } } }