Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] [JF] Refactored RBAC tests to adopt UI changes #823

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
46 changes: 16 additions & 30 deletions cypress/e2e/models/migration/applicationinventory/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 })
Expand Down
42 changes: 23 additions & 19 deletions cypress/e2e/tests/rbac/architect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stakeholders> = [];
const stakeholdersNameList: Array<string> = [];

describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () {
let userArchitect = new UserArchitect(getRandomUserData());
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not needed.

const stakeholder = new Stakeholders(data.getEmail(), data.getFullName());
stakeholder.create();
cy.wait(2 * SEC);

stakeholdersList.push(stakeholder);
stakeholdersNameList.push(stakeholder.name);

abrugaro marked this conversation as resolved.
Show resolved Hide resolved
appCredentials.create();
application.create();
application.perform_review("low");
application.perform_assessment("low", stakeholdersNameList);

logout();
User.loginKeycloakAdmin();
userArchitect.create();
Expand All @@ -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);
});
Expand All @@ -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 () {
Expand All @@ -93,6 +96,7 @@ describe(["@tier2", "@rhsso"], "Architect RBAC operations", function () {
userArchitect.logout();
login();
appCredentials.delete();
deleteByList(stakeholdersList);
application.delete();
logout();
User.loginKeycloakAdmin();
Expand Down
39 changes: 21 additions & 18 deletions cypress/e2e/tests/rbac/migrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stakeholders> = [];
const stakeholdersNameList: Array<string> = [];

describe(["@tier2", "@rhsso"], "Migrator RBAC operations", () => {
let userMigrator = new UserMigrator(getRandomUserData());
Expand All @@ -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);
abrugaro marked this conversation as resolved.
Show resolved Hide resolved

appCredentials.create();
application.create();
application.perform_review("low");
Expand All @@ -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);
});
Expand All @@ -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);
});
Expand All @@ -94,6 +96,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
}
}
}
Loading