Skip to content

Commit

Permalink
Refactored RBAC tests to adopt UI changes
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Braginsky <ibragins@redhat.com>
  • Loading branch information
ibragins committed Nov 20, 2023
1 parent 24a7adc commit e5e05e8
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 110 deletions.
10 changes: 5 additions & 5 deletions cypress/e2e/models/migration/applicationinventory/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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"]);
}
}

Expand Down
48 changes: 13 additions & 35 deletions cypress/e2e/models/migration/applicationinventory/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
39 changes: 21 additions & 18 deletions cypress/e2e/tests/rbac/architect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stakeholders> = [];
const stakeholdersNameList: Array<string> = [];
const fileName = "Legacy Pathfinder";

describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () {
let userArchitect = new UserArchitect(getRandomUserData());
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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 () {
Expand All @@ -95,6 +97,7 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () {
userArchitect.logout();
login();
appCredentials.delete();
deleteByList(stakeholdersList);
application.delete();
logout();
User.loginKeycloakAdmin();
Expand Down
38 changes: 21 additions & 17 deletions cypress/e2e/tests/rbac/migrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stakeholders> = [];
const stakeholdersNameList: Array<string> = [];
const fileName = "Legacy Pathfinder";

describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => {
let userMigrator = new UserMigrator(getRandomUserData());
Expand All @@ -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");
Expand All @@ -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);
Expand All @@ -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);
});
Expand All @@ -94,6 +97,7 @@ describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => {
userMigrator.logout();
login();
appCredentials.delete();
deleteByList(stakeholdersList);
application.delete();
logout();
User.loginKeycloakAdmin();
Expand Down
19 changes: 8 additions & 11 deletions cypress/e2e/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};

Expand Down
42 changes: 18 additions & 24 deletions cypress/fixtures/rbac.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit e5e05e8

Please sign in to comment.