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";
|
|
|
|
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";
|
2021-03-18 12:48:14 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
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();
|
|
|
|
const createRealmRolePage = new CreateRealmRolePage();
|
2021-03-03 14:55:19 +00:00
|
|
|
const associatedRolesPage = new AssociatedRolesPage();
|
2021-01-27 12:47:57 +00:00
|
|
|
|
2021-01-21 12:09:50 +00:00
|
|
|
describe("Realm roles test", function () {
|
|
|
|
describe("Realm roles creation", function () {
|
|
|
|
beforeEach(function () {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-01-21 12:09:50 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToRealmRoles();
|
2021-01-25 17:17:59 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-01-25 17:17:59 +00:00
|
|
|
it("should fail creating realm role", function () {
|
2021-01-21 12:09:50 +00:00
|
|
|
listingPage.goToCreateItem();
|
|
|
|
|
|
|
|
createRealmRolePage.save().checkRealmRoleNameRequiredMessage();
|
|
|
|
|
|
|
|
createRealmRolePage.fillRealmRoleData("admin").save();
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-07-23 10:58:39 +00:00
|
|
|
it("Realm role CRUD test", function () {
|
2021-01-25 17:17:59 +00:00
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-01-25 17:17:59 +00:00
|
|
|
// Create
|
2021-01-27 12:56:28 +00:00
|
|
|
listingPage.itemExist(itemId, false).goToCreateItem();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
createRealmRolePage.fillRealmRoleData(itemId).save();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Role created");
|
|
|
|
|
|
|
|
sidebarPage.goToRealmRoles();
|
|
|
|
|
2021-01-27 12:56:28 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-07-23 10:58:39 +00:00
|
|
|
const fetchUrl = "/auth/admin/realms/master/roles?first=0&max=11";
|
|
|
|
cy.intercept(fetchUrl).as("fetch");
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
listingPage.deleteItem(itemId);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2021-07-23 10:58:39 +00:00
|
|
|
cy.wait(["@fetch"]);
|
2021-01-21 12:09:50 +00:00
|
|
|
modalUtils.checkModalTitle("Delete role?").confirmModal();
|
|
|
|
masthead.checkNotificationMessage("The role has been deleted");
|
|
|
|
|
|
|
|
listingPage.itemExist(itemId, false);
|
2021-07-23 10:58:39 +00:00
|
|
|
});
|
2021-02-04 20:50:13 +00:00
|
|
|
|
2021-02-17 07:17:04 +00:00
|
|
|
it("Associated roles test", function () {
|
2021-02-04 20:50:13 +00:00
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
// Create
|
|
|
|
listingPage.itemExist(itemId, false).goToCreateItem();
|
|
|
|
|
|
|
|
createRealmRolePage.fillRealmRoleData(itemId).save();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Role created");
|
|
|
|
|
2021-03-03 14:55:19 +00:00
|
|
|
// Add associated realm role
|
2021-02-23 13:36:37 +00:00
|
|
|
|
2021-03-03 14:55:19 +00:00
|
|
|
associatedRolesPage.addAssociatedRealmRole();
|
2021-02-25 09:10:28 +00:00
|
|
|
|
2021-02-23 13:36:37 +00:00
|
|
|
// Add associated client role
|
|
|
|
|
2021-03-03 14:55:19 +00:00
|
|
|
associatedRolesPage.addAssociatedClientRole();
|
2021-02-04 20:50:13 +00:00
|
|
|
});
|
2021-01-21 12:09:50 +00:00
|
|
|
});
|
|
|
|
});
|