2021-01-27 12:56:28 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
2022-04-20 09:29:35 +00:00
|
|
|
import createRealmRolePage from "../support/pages/admin_console/manage/realm_roles/CreateRealmRolePage";
|
2021-03-03 14:55:19 +00:00
|
|
|
import AssociatedRolesPage from "../support/pages/admin_console/manage/realm_roles/AssociatedRolesPage";
|
2022-03-09 16:42:51 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2022-02-24 10:31:46 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
2022-03-29 10:39:32 +00:00
|
|
|
import ClientRolesTab from "../support/pages/admin_console/manage/clients/ClientRolesTab";
|
2022-04-20 09:29:35 +00:00
|
|
|
import KeyValueInput from "../support/pages/admin_console/manage/KeyValueInput";
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-01-27 12:47:57 +00:00
|
|
|
let itemId = "realm_role_crud";
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const listingPage = new ListingPage();
|
2021-03-03 14:55:19 +00:00
|
|
|
const associatedRolesPage = new AssociatedRolesPage();
|
2022-03-29 10:39:32 +00:00
|
|
|
const rolesTab = new ClientRolesTab();
|
2021-01-27 12:47:57 +00:00
|
|
|
|
2021-10-04 06:03:19 +00:00
|
|
|
describe("Realm roles test", () => {
|
2022-02-23 11:05:38 +00:00
|
|
|
before(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
sidebarPage.goToRealmRoles();
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
it("should fail creating realm role", () => {
|
|
|
|
listingPage.goToCreateItem();
|
|
|
|
createRealmRolePage.save().checkRealmRoleNameRequiredMessage();
|
|
|
|
createRealmRolePage.fillRealmRoleData("admin").save();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
// The error should inform about duplicated name/id (THIS MESSAGE DOES NOT HAVE QUOTES AS THE OTHERS)
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Could not create role: Role with name admin already exists",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
it("shouldn't create a realm role based with only whitespace name", () => {
|
|
|
|
listingPage.goToCreateItem();
|
|
|
|
createRealmRolePage
|
|
|
|
.fillRealmRoleData(" ")
|
|
|
|
.checkRealmRoleNameRequiredMessage();
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
it("Realm role CRUD test", () => {
|
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
// Create
|
|
|
|
listingPage.itemExist(itemId, false).goToCreateItem();
|
|
|
|
createRealmRolePage.fillRealmRoleData(itemId).save();
|
|
|
|
masthead.checkNotificationMessage("Role created", true);
|
|
|
|
sidebarPage.goToRealmRoles();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-03-06 15:25:37 +00:00
|
|
|
const fetchUrl = "/admin/realms/master/roles?first=0&max=11";
|
2022-02-23 11:05:38 +00:00
|
|
|
cy.intercept(fetchUrl).as("fetch");
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
listingPage.deleteItem(itemId);
|
2021-01-27 12:56:28 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
cy.wait(["@fetch"]);
|
|
|
|
modalUtils.checkModalTitle("Delete role?").confirmModal();
|
|
|
|
masthead.checkNotificationMessage("The role has been deleted", true);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
listingPage.itemExist(itemId, false);
|
2022-03-29 10:39:32 +00:00
|
|
|
|
|
|
|
itemId = "realm_role_crud";
|
2022-02-23 11:05:38 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
it("should delete role from details action", () => {
|
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
listingPage.goToCreateItem();
|
|
|
|
createRealmRolePage.fillRealmRoleData(itemId).save();
|
|
|
|
masthead.checkNotificationMessage("Role created", true);
|
|
|
|
createRealmRolePage.clickActionMenu("Delete this role");
|
|
|
|
modalUtils.confirmModal();
|
|
|
|
masthead.checkNotificationMessage("The role has been deleted", true);
|
2022-03-29 10:39:32 +00:00
|
|
|
itemId = "realm_role_crud";
|
2022-02-23 11:05:38 +00:00
|
|
|
});
|
2021-02-04 20:50:13 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
it("should not be able to delete default role", () => {
|
|
|
|
const defaultRole = "default-roles-master";
|
|
|
|
listingPage.itemExist(defaultRole).deleteItem(defaultRole);
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"You cannot delete a default role.",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
});
|
2021-02-04 20:50:13 +00:00
|
|
|
|
2022-03-29 10:39:32 +00:00
|
|
|
it("Add associated roles test", () => {
|
2022-02-23 11:05:38 +00:00
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
2021-02-04 20:50:13 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
// Create
|
|
|
|
listingPage.itemExist(itemId, false).goToCreateItem();
|
|
|
|
createRealmRolePage.fillRealmRoleData(itemId).save();
|
|
|
|
masthead.checkNotificationMessage("Role created", true);
|
2021-02-04 20:50:13 +00:00
|
|
|
|
2022-03-29 10:39:32 +00:00
|
|
|
// Add associated realm role from action dropdown
|
2022-03-09 16:41:45 +00:00
|
|
|
associatedRolesPage.addAssociatedRealmRole("create-realm");
|
2022-02-23 11:05:38 +00:00
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
2021-02-04 20:50:13 +00:00
|
|
|
|
2022-03-29 10:39:32 +00:00
|
|
|
// Add associated realm role from search bar
|
|
|
|
associatedRolesPage.addAssociatedRoleFromSearchBar("offline_access");
|
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
|
|
|
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
|
|
|
|
// Add associated client role from search bar
|
|
|
|
associatedRolesPage.addAssociatedRoleFromSearchBar("manage-account", true);
|
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
|
|
|
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
// Add associated client role
|
2022-03-29 10:39:32 +00:00
|
|
|
associatedRolesPage.addAssociatedRoleFromSearchBar("manage-consent", true);
|
2022-02-23 11:05:38 +00:00
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
2022-03-29 10:39:32 +00:00
|
|
|
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
|
|
|
|
// Add associated client role
|
2022-08-20 08:10:36 +00:00
|
|
|
associatedRolesPage.addAssociatedRoleFromSearchBar(
|
|
|
|
"manage-account-links",
|
|
|
|
true
|
|
|
|
);
|
2022-03-29 10:39:32 +00:00
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should search existing associated role by name", () => {
|
|
|
|
listingPage.searchItem("create-realm", false).itemExist("create-realm");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should search non-existent associated role by name", () => {
|
|
|
|
const itemName = "non-existent-associated-role";
|
|
|
|
listingPage.searchItem(itemName, false);
|
|
|
|
cy.findByTestId(listingPage.emptyState).should("exist");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should hide inherited roles test", () => {
|
|
|
|
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
rolesTab.hideInheritedRoles();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should fail to remove role when all unchecked from search bar", () => {
|
|
|
|
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
associatedRolesPage.isRemoveAssociatedRolesBtnDisabled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should delete single non-inherited role item", () => {
|
|
|
|
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
listingPage.removeItem("create-realm");
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
modalUtils.checkModalTitle("Remove associated role?").confirmModal();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Associated roles have been removed",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should delete all roles from search bar", () => {
|
|
|
|
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
|
|
|
|
cy.get('input[name="check-all"]').check();
|
|
|
|
|
|
|
|
associatedRolesPage.removeAssociatedRoles();
|
|
|
|
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
modalUtils.checkModalTitle("Remove associated roles?").confirmModal();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Associated roles have been removed",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should delete associated roles from list test", () => {
|
|
|
|
itemId = "realm_role_crud";
|
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
// Create
|
|
|
|
listingPage.itemExist(itemId, false).goToCreateItem();
|
|
|
|
createRealmRolePage.fillRealmRoleData(itemId).save();
|
|
|
|
masthead.checkNotificationMessage("Role created", true);
|
|
|
|
|
|
|
|
// Add associated realm role from action dropdown
|
|
|
|
associatedRolesPage.addAssociatedRealmRole("create-realm");
|
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
|
|
|
|
|
|
|
// Add associated realm role from search bar
|
|
|
|
associatedRolesPage.addAssociatedRoleFromSearchBar("offline_access");
|
|
|
|
masthead.checkNotificationMessage("Associated roles have been added", true);
|
|
|
|
|
|
|
|
rolesTab.goToAssociatedRolesTab();
|
|
|
|
|
|
|
|
// delete associated roles from list
|
|
|
|
listingPage.removeItem("create-realm");
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
modalUtils.checkModalTitle("Remove associated role?").confirmModal();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Associated roles have been removed",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
listingPage.removeItem("offline_access");
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
modalUtils.checkModalTitle("Remove associated role?").confirmModal();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Associated roles have been removed",
|
|
|
|
true
|
|
|
|
);
|
2022-02-23 11:05:38 +00:00
|
|
|
});
|
2021-02-23 13:36:37 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
describe("edit role details", () => {
|
|
|
|
const editRoleName = "going to edit";
|
|
|
|
const description = "some description";
|
2022-04-20 09:29:35 +00:00
|
|
|
const updateDescription = "updated description";
|
|
|
|
|
2022-03-03 07:45:44 +00:00
|
|
|
before(() =>
|
2022-02-23 11:05:38 +00:00
|
|
|
adminClient.createRealmRole({
|
|
|
|
name: editRoleName,
|
|
|
|
description,
|
2022-03-03 07:45:44 +00:00
|
|
|
})
|
|
|
|
);
|
2021-02-25 09:10:28 +00:00
|
|
|
|
2022-03-03 07:45:44 +00:00
|
|
|
after(() => adminClient.deleteRealmRole(editRoleName));
|
2021-02-23 13:36:37 +00:00
|
|
|
|
2022-02-23 11:05:38 +00:00
|
|
|
it("should edit realm role details", () => {
|
|
|
|
listingPage.itemExist(editRoleName).goToItemDetails(editRoleName);
|
|
|
|
createRealmRolePage.checkNameDisabled().checkDescription(description);
|
|
|
|
createRealmRolePage.updateDescription(updateDescription).save();
|
|
|
|
masthead.checkNotificationMessage("The role has been saved", true);
|
|
|
|
createRealmRolePage.checkDescription(updateDescription);
|
2021-02-04 20:50:13 +00:00
|
|
|
});
|
2022-04-20 09:29:35 +00:00
|
|
|
|
|
|
|
it("should revert realm role", () => {
|
|
|
|
listingPage.itemExist(editRoleName).goToItemDetails(editRoleName);
|
|
|
|
createRealmRolePage.checkDescription(updateDescription);
|
|
|
|
createRealmRolePage.updateDescription("going to revert").cancel();
|
|
|
|
createRealmRolePage.checkDescription(updateDescription);
|
|
|
|
});
|
|
|
|
|
2022-04-20 17:11:46 +00:00
|
|
|
const keyValue = new KeyValueInput("attributes");
|
2022-04-21 14:00:31 +00:00
|
|
|
it.skip("should add attribute", () => {
|
2022-04-20 09:29:35 +00:00
|
|
|
listingPage.itemExist(editRoleName).goToItemDetails(editRoleName);
|
|
|
|
|
|
|
|
createRealmRolePage.goToAttributesTab();
|
|
|
|
keyValue.fillKeyValue({ key: "one", value: "1" }).validateRows(2);
|
|
|
|
keyValue.save();
|
|
|
|
masthead.checkNotificationMessage("The role has been saved", true);
|
|
|
|
keyValue.validateRows(1);
|
|
|
|
});
|
|
|
|
|
2022-04-21 14:00:31 +00:00
|
|
|
it.skip("should add attribute multiple", () => {
|
2022-04-20 09:29:35 +00:00
|
|
|
listingPage.itemExist(editRoleName).goToItemDetails(editRoleName);
|
|
|
|
|
|
|
|
createRealmRolePage.goToAttributesTab();
|
|
|
|
keyValue
|
|
|
|
.fillKeyValue({ key: "two", value: "2" }, 1)
|
|
|
|
.fillKeyValue({ key: "three", value: "3" }, 2)
|
|
|
|
.save()
|
|
|
|
.validateRows(3);
|
|
|
|
});
|
|
|
|
|
2022-04-21 14:00:31 +00:00
|
|
|
it.skip("should delete attribute", () => {
|
2022-04-20 09:29:35 +00:00
|
|
|
listingPage.itemExist(editRoleName).goToItemDetails(editRoleName);
|
|
|
|
createRealmRolePage.goToAttributesTab();
|
|
|
|
|
|
|
|
keyValue.deleteRow(1).save().validateRows(2);
|
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|
|
|
|
});
|