Add Service Account Tests (#2624)
This commit is contained in:
parent
bb853874d8
commit
5fd94d12b8
5 changed files with 134 additions and 13 deletions
|
@ -16,6 +16,7 @@ import ClientDetailsPage, {
|
||||||
ClientsDetailsTab,
|
ClientsDetailsTab,
|
||||||
} from "../support/pages/admin_console/manage/clients/client_details/ClientDetailsPage";
|
} from "../support/pages/admin_console/manage/clients/client_details/ClientDetailsPage";
|
||||||
import CommonPage from "../support/pages/CommonPage";
|
import CommonPage from "../support/pages/CommonPage";
|
||||||
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
||||||
|
|
||||||
let itemId = "client_crud";
|
let itemId = "client_crud";
|
||||||
const loginPage = new LoginPage();
|
const loginPage = new LoginPage();
|
||||||
|
@ -23,6 +24,7 @@ const associatedRolesPage = new AssociatedRolesPage();
|
||||||
const createClientPage = new CreateClientPage();
|
const createClientPage = new CreateClientPage();
|
||||||
const clientDetailsPage = new ClientDetailsPage();
|
const clientDetailsPage = new ClientDetailsPage();
|
||||||
const commonPage = new CommonPage();
|
const commonPage = new CommonPage();
|
||||||
|
const listingPage = new ListingPage();
|
||||||
|
|
||||||
describe("Clients test", () => {
|
describe("Clients test", () => {
|
||||||
describe("Client details - Client scopes subtab", () => {
|
describe("Client details - Client scopes subtab", () => {
|
||||||
|
@ -721,23 +723,122 @@ describe("Clients test", () => {
|
||||||
commonPage.tableUtils().clickRowItemLink(serviceAccountName);
|
commonPage.tableUtils().clickRowItemLink(serviceAccountName);
|
||||||
serviceAccountTab
|
serviceAccountTab
|
||||||
.goToServiceAccountTab()
|
.goToServiceAccountTab()
|
||||||
.checkRoles(["manage-account", "offline_access", "uma_authorization"]);
|
.checkRoles([
|
||||||
|
"default-roles-master",
|
||||||
|
"offline_access",
|
||||||
|
"uma_authorization",
|
||||||
|
"manage-account",
|
||||||
|
"view-profile",
|
||||||
|
"manage-account-links",
|
||||||
|
"uma_protection",
|
||||||
|
])
|
||||||
|
.hideInheritedRoles();
|
||||||
|
|
||||||
|
commonPage.sidebar().waitForPageLoad();
|
||||||
|
|
||||||
|
serviceAccountTab
|
||||||
|
.checkRoles(
|
||||||
|
[
|
||||||
|
"offline_access",
|
||||||
|
"uma_authorization",
|
||||||
|
"manage-account",
|
||||||
|
"view-profile",
|
||||||
|
"manage-account-links",
|
||||||
|
],
|
||||||
|
false
|
||||||
|
)
|
||||||
|
.checkRoles(["default-roles-master", "uma_protection"])
|
||||||
|
.unhideInheritedRoles();
|
||||||
|
|
||||||
|
commonPage.sidebar().waitForPageLoad();
|
||||||
|
|
||||||
|
serviceAccountTab.checkRoles([
|
||||||
|
"default-roles-master",
|
||||||
|
"offline_access",
|
||||||
|
"uma_authorization",
|
||||||
|
"manage-account",
|
||||||
|
"view-profile",
|
||||||
|
"manage-account-links",
|
||||||
|
"uma_protection",
|
||||||
|
]);
|
||||||
|
|
||||||
|
listingPage
|
||||||
|
.searchItem("testing", false)
|
||||||
|
.checkEmptyList()
|
||||||
|
.searchItem("", false);
|
||||||
|
|
||||||
|
serviceAccountTab.checkRoles([
|
||||||
|
"default-roles-master",
|
||||||
|
"offline_access",
|
||||||
|
"uma_authorization",
|
||||||
|
"manage-account",
|
||||||
|
"view-profile",
|
||||||
|
"manage-account-links",
|
||||||
|
"uma_protection",
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip("Assign", () => {
|
it("Assign", () => {
|
||||||
commonPage.tableUtils().clickRowItemLink(serviceAccountName);
|
commonPage.tableUtils().clickRowItemLink(serviceAccountName);
|
||||||
serviceAccountTab
|
serviceAccountTab
|
||||||
.goToServiceAccountTab()
|
.goToServiceAccountTab()
|
||||||
.assignRole(false)
|
.assignRole(false)
|
||||||
.selectRow("create-realm")
|
.selectRow("create-realm", true)
|
||||||
.assign();
|
.assign();
|
||||||
commonPage.masthead().checkNotificationMessage("Role mapping updated");
|
commonPage.masthead().checkNotificationMessage("Role mapping updated");
|
||||||
|
|
||||||
serviceAccountTab.selectRow("create-realm").unAssign();
|
serviceAccountTab.selectRow("create-realm").unAssign();
|
||||||
|
|
||||||
commonPage.sidebar().waitForPageLoad();
|
commonPage.sidebar().waitForPageLoad();
|
||||||
commonPage.modalUtils().checkModalTitle("Remove mapping?").confirmModal();
|
commonPage.modalUtils().checkModalTitle("Remove mapping?").confirmModal();
|
||||||
commonPage
|
commonPage
|
||||||
.masthead()
|
.masthead()
|
||||||
.checkNotificationMessage("Scope mapping successfully removed");
|
.checkNotificationMessage("Scope mapping successfully removed");
|
||||||
|
|
||||||
|
cy.intercept("/admin/realms/master/clients").as("assignRoles");
|
||||||
|
serviceAccountTab.checkRoles(["create-realm"], false).assignRole(false);
|
||||||
|
|
||||||
|
cy.wait("@assignRoles");
|
||||||
|
commonPage.sidebar().waitForPageLoad();
|
||||||
|
|
||||||
|
serviceAccountTab
|
||||||
|
.selectRow("offline_access", true)
|
||||||
|
.selectRow("admin", true)
|
||||||
|
.selectRow("create-realm", true)
|
||||||
|
.assign();
|
||||||
|
|
||||||
|
commonPage.masthead().checkNotificationMessage("Role mapping updated");
|
||||||
|
commonPage.sidebar().waitForPageLoad();
|
||||||
|
|
||||||
|
serviceAccountTab
|
||||||
|
.selectRow("offline_access")
|
||||||
|
.selectRow("admin")
|
||||||
|
.unAssign();
|
||||||
|
|
||||||
|
commonPage.modalUtils().confirmModal();
|
||||||
|
|
||||||
|
serviceAccountTab
|
||||||
|
.checkRoles(["admin"], false)
|
||||||
|
.checkRoles(["create-realm"]);
|
||||||
|
|
||||||
|
listingPage.clickRowDetails("create-realm");
|
||||||
|
serviceAccountTab.unAssignFromDropdown();
|
||||||
|
|
||||||
|
commonPage.modalUtils().confirmModal();
|
||||||
|
|
||||||
|
commonPage.sidebar().waitForPageLoad();
|
||||||
|
|
||||||
|
serviceAccountTab
|
||||||
|
.checkRoles(["create-realm"], false)
|
||||||
|
.checkRoles([
|
||||||
|
"default-roles-master",
|
||||||
|
"offline_access",
|
||||||
|
"uma_authorization",
|
||||||
|
"manage-account",
|
||||||
|
"view-profile",
|
||||||
|
"manage-account-links",
|
||||||
|
"uma_protection",
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,10 @@ describe("Realm settings client policies tab tests", () => {
|
||||||
"Test again",
|
"Test again",
|
||||||
"Test Again Description"
|
"Test Again Description"
|
||||||
);
|
);
|
||||||
masthead.checkNotificationMessage("New policy created");
|
masthead.checkNotificationMessage("New policy created", true);
|
||||||
sidebarPage.waitForPageLoad();
|
sidebarPage.waitForPageLoad();
|
||||||
cy.wait("@save");
|
cy.wait("@save");
|
||||||
masthead.closeLastAlertMessage();
|
masthead.closeAllAlertMessages();
|
||||||
realmSettingsPage.deleteClientPolicyFromDetails();
|
realmSettingsPage.deleteClientPolicyFromDetails();
|
||||||
modalUtils.confirmModal();
|
modalUtils.confirmModal();
|
||||||
masthead.checkNotificationMessage("Client policy deleted");
|
masthead.checkNotificationMessage("Client policy deleted");
|
||||||
|
|
|
@ -56,7 +56,7 @@ export default class Masthead extends CommonElements {
|
||||||
cy.get(this.alertMessage).should("contain.text", message);
|
cy.get(this.alertMessage).should("contain.text", message);
|
||||||
|
|
||||||
if (closeNotification) {
|
if (closeNotification) {
|
||||||
cy.get(`button[title="${message}"]`).click();
|
cy.get(`button[title="${message}"]`).last().click({ force: true });
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ export default class Masthead extends CommonElements {
|
||||||
}
|
}
|
||||||
|
|
||||||
closeAllAlertMessages() {
|
closeAllAlertMessages() {
|
||||||
cy.get(this.closeAlertMessageBtn).click({ multiple: true });
|
cy.get(this.closeAlertMessageBtn).click({ force: true, multiple: true });
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,12 @@ export default class RoleMappingTab {
|
||||||
`no-roles-for-this-${type}-empty-action`;
|
`no-roles-for-this-${type}-empty-action`;
|
||||||
private assignRoleBtn = "assignRole";
|
private assignRoleBtn = "assignRole";
|
||||||
private unAssignBtn = "unAssignRole";
|
private unAssignBtn = "unAssignRole";
|
||||||
|
private unAssignDrpDwnBtn = '.pf-c-table__action li[role="menuitem"] button';
|
||||||
private assignBtn = "assign";
|
private assignBtn = "assign";
|
||||||
private hideInheritedRolesBtn = "#hideInheritedRoles";
|
private hideInheritedRolesBtn = "#hideInheritedRoles";
|
||||||
private assignedRolesTable = "assigned-roles";
|
private assignedRolesTable = "assigned-roles";
|
||||||
private namesColumn = 'td[data-label="Name"]:visible';
|
private namesColumn = 'td[data-label="Name"]:visible';
|
||||||
|
private actionBtn = 'button[aria-label="Actions"]';
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -43,13 +45,23 @@ export default class RoleMappingTab {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unAssignFromDropdown() {
|
||||||
|
cy.get(this.unAssignDrpDwnBtn).click();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
hideInheritedRoles() {
|
hideInheritedRoles() {
|
||||||
cy.get(this.hideInheritedRolesBtn).check();
|
cy.get(this.hideInheritedRolesBtn).check();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectRow(name: string) {
|
unhideInheritedRoles() {
|
||||||
cy.get(this.namesColumn)
|
cy.get(this.hideInheritedRolesBtn).uncheck();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectRow(name: string, modal = false) {
|
||||||
|
cy.get(modal ? ".pf-c-modal-box " : "" + this.namesColumn)
|
||||||
.contains(name)
|
.contains(name)
|
||||||
.parent()
|
.parent()
|
||||||
.within(() => {
|
.within(() => {
|
||||||
|
@ -58,14 +70,19 @@ export default class RoleMappingTab {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRoles(roleNames: string[]) {
|
checkRoles(roleNames: string[], exist = true) {
|
||||||
if (roleNames.length) {
|
if (roleNames.length) {
|
||||||
cy.findByTestId(this.assignedRolesTable)
|
cy.findByTestId(this.assignedRolesTable)
|
||||||
.get(this.namesColumn)
|
.get(this.namesColumn)
|
||||||
.should((roles) => {
|
.should((roles) => {
|
||||||
for (let index = 0; index < roleNames.length; index++) {
|
for (let index = 0; index < roleNames.length; index++) {
|
||||||
const roleName = roleNames[index];
|
const roleName = roleNames[index];
|
||||||
|
|
||||||
|
if (exist) {
|
||||||
expect(roles).to.contain(roleName);
|
expect(roles).to.contain(roleName);
|
||||||
|
} else {
|
||||||
|
expect(roles).not.to.contain(roleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -258,7 +258,7 @@ export const ClientScopes = ({
|
||||||
|
|
||||||
setKebabOpen(false);
|
setKebabOpen(false);
|
||||||
addAlert(
|
addAlert(
|
||||||
t("clientScopeRemoveSuccess"),
|
t("clients:clientScopeRemoveSuccess"),
|
||||||
AlertVariant.success
|
AlertVariant.success
|
||||||
);
|
);
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -307,7 +307,10 @@ export const ClientScopes = ({
|
||||||
row,
|
row,
|
||||||
row.type as ClientScope
|
row.type as ClientScope
|
||||||
);
|
);
|
||||||
addAlert(t("clientScopeRemoveSuccess"), AlertVariant.success);
|
addAlert(
|
||||||
|
t("clients:clientScopeRemoveSuccess"),
|
||||||
|
AlertVariant.success
|
||||||
|
);
|
||||||
refresh();
|
refresh();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addError("clients:clientScopeRemoveError", error);
|
addError("clients:clientScopeRemoveError", error);
|
||||||
|
|
Loading…
Reference in a new issue