2021-12-06 10:50:29 +00:00
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import RealmSettingsPage from "../support/pages/admin_console/manage/realm_settings/RealmSettingsPage";
|
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-02-16 16:34:54 +00:00
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2022-02-16 16:34:54 +00:00
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
const masthead = new Masthead();
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
describe("Realm settings client policies tab tests", () => {
|
|
|
|
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
|
2022-01-24 14:17:55 +00:00
|
|
|
const realmSettingsPage = new RealmSettingsPage(realmName);
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-02-16 16:34:54 +00:00
|
|
|
sidebarPage
|
|
|
|
.waitForPageLoad()
|
|
|
|
.goToRealm(realmName)
|
|
|
|
.goToRealmSettings()
|
|
|
|
.waitForPageLoad();
|
|
|
|
realmSettingsPage.goToClientPoliciesTab().goToClientPoliciesList();
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
2022-01-24 14:17:55 +00:00
|
|
|
before(() => {
|
|
|
|
keycloakBefore();
|
2022-02-24 10:31:46 +00:00
|
|
|
adminClient.createRealm(realmName);
|
2022-01-24 14:17:55 +00:00
|
|
|
loginPage.logIn();
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
2022-01-24 14:17:55 +00:00
|
|
|
after(() => {
|
2022-02-24 10:31:46 +00:00
|
|
|
adminClient.deleteRealm(realmName);
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Complete new client form and cancel", () => {
|
2022-02-16 16:34:54 +00:00
|
|
|
realmSettingsPage
|
|
|
|
.checkDisplayPoliciesTab()
|
|
|
|
.createNewClientPolicyFromEmptyState("Test", "Test Description", true)
|
|
|
|
.checkNewClientPolicyForm()
|
|
|
|
.cancelNewClientPolicyCreation()
|
|
|
|
.checkEmptyPolicyList();
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Complete new client form and submit", () => {
|
2022-03-06 15:25:37 +00:00
|
|
|
const url = `/admin/realms/${realmName}/client-policies/policies`;
|
2022-02-16 16:34:54 +00:00
|
|
|
cy.intercept("PUT", url).as("save");
|
|
|
|
|
|
|
|
realmSettingsPage.createNewClientPolicyFromEmptyState(
|
|
|
|
"Test",
|
|
|
|
"Test Description"
|
|
|
|
);
|
|
|
|
masthead.checkNotificationMessage("New policy created");
|
|
|
|
cy.wait("@save");
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should perform client profile search by profile name", () => {
|
2022-02-16 16:34:54 +00:00
|
|
|
realmSettingsPage.searchClientPolicy("Test");
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should not have conditions configured by default", () => {
|
|
|
|
realmSettingsPage.shouldNotHaveConditionsConfigured();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should cancel adding a new condition to a client profile", () => {
|
|
|
|
realmSettingsPage.shouldCancelAddingCondition();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should add a new client-roles condition to a client profile", () => {
|
|
|
|
realmSettingsPage.shouldAddClientRolesCondition();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should add a new client-scopes condition to a client profile", () => {
|
|
|
|
realmSettingsPage.shouldAddClientScopesCondition();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should edit the client-roles condition of a client profile", () => {
|
|
|
|
realmSettingsPage.shouldEditClientRolesCondition();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should edit the client-scopes condition of a client profile", () => {
|
|
|
|
realmSettingsPage.shouldEditClientScopesCondition();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should cancel deleting condition from a client profile", () => {
|
2022-02-16 16:34:54 +00:00
|
|
|
realmSettingsPage.deleteClientRolesCondition();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
modalUtils
|
|
|
|
.checkModalTitle("Delete condition?")
|
|
|
|
.checkModalMessage(
|
|
|
|
"This action will permanently delete client-roles. This cannot be undone."
|
|
|
|
)
|
|
|
|
.checkConfirmButtonText("Delete")
|
|
|
|
.cancelButtonContains("Cancel")
|
|
|
|
.cancelModal();
|
|
|
|
realmSettingsPage.checkConditionsListContains("client-roles");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should delete client-roles condition from a client profile", () => {
|
|
|
|
realmSettingsPage.deleteClientRolesCondition();
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
modalUtils.confirmModal();
|
|
|
|
realmSettingsPage.checkConditionsListContains("client-scopes");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should delete client-scopes condition from a client profile", () => {
|
2021-12-06 10:50:29 +00:00
|
|
|
realmSettingsPage.shouldDeleteClientScopesCondition();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Check cancelling the client policy deletion", () => {
|
2022-02-16 16:34:54 +00:00
|
|
|
realmSettingsPage.deleteClientPolicyItemFromTable("Test");
|
|
|
|
modalUtils
|
|
|
|
.checkModalMessage(
|
|
|
|
"This action will permanently delete the policy Test. This cannot be undone."
|
|
|
|
)
|
|
|
|
.cancelModal();
|
|
|
|
realmSettingsPage.checkElementInList("Test");
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Check deleting the client policy", () => {
|
2022-02-16 16:34:54 +00:00
|
|
|
realmSettingsPage.deleteClientPolicyItemFromTable("Test");
|
|
|
|
|
|
|
|
modalUtils.confirmModal();
|
|
|
|
masthead.checkNotificationMessage("Client policy deleted");
|
|
|
|
realmSettingsPage.checkEmptyPolicyList();
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Check navigating between Form View and JSON editor", () => {
|
|
|
|
realmSettingsPage.shouldNavigateBetweenFormAndJSONViewPolicies();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should not create duplicate client profile", () => {
|
2022-03-06 15:25:37 +00:00
|
|
|
const url = `admin/realms/${realmName}/client-policies/policies`;
|
2022-01-24 14:17:55 +00:00
|
|
|
cy.intercept("PUT", url).as("save");
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
realmSettingsPage.createNewClientPolicyFromEmptyState(
|
|
|
|
"Test",
|
|
|
|
"Test Description"
|
|
|
|
);
|
|
|
|
masthead.checkNotificationMessage("New policy created");
|
2022-01-24 14:17:55 +00:00
|
|
|
cy.wait("@save");
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
sidebarPage.goToRealmSettings();
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
realmSettingsPage.goToClientPoliciesTab().goToClientPoliciesList();
|
|
|
|
|
|
|
|
realmSettingsPage.createNewClientPolicyFromList(
|
|
|
|
"Test",
|
|
|
|
"Test Again Description"
|
|
|
|
);
|
2022-01-24 14:17:55 +00:00
|
|
|
cy.wait("@save");
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
// TODO: UNCOMMENT WHEN THE ISSUE 2050 IS FIXED
|
|
|
|
//realmSettingsPage.checkAlertMessage("Could not create client policy: 'proposed client policy name duplicated.'");
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
realmSettingsPage
|
|
|
|
.goToClientPoliciesTab()
|
|
|
|
.goToClientPoliciesList()
|
|
|
|
.deleteClientPolicyItemFromTable("Test");
|
|
|
|
|
|
|
|
modalUtils.confirmModal();
|
|
|
|
cy.wait("@save");
|
|
|
|
masthead.checkNotificationMessage("Client policy deleted");
|
|
|
|
realmSettingsPage.checkEmptyPolicyList();
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Check deleting newly created client policy from create view via dropdown", () => {
|
2022-03-06 15:25:37 +00:00
|
|
|
const url = `admin/realms/${realmName}/client-policies/policies`;
|
2022-02-16 16:34:54 +00:00
|
|
|
cy.intercept("PUT", url).as("save");
|
|
|
|
realmSettingsPage.createNewClientPolicyFromEmptyState(
|
|
|
|
"Test again",
|
|
|
|
"Test Again Description"
|
|
|
|
);
|
|
|
|
masthead.checkNotificationMessage("New policy created");
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
cy.wait("@save");
|
|
|
|
masthead.closeLastAlertMessage();
|
|
|
|
realmSettingsPage.deleteClientPolicyFromDetails();
|
|
|
|
modalUtils.confirmModal();
|
|
|
|
masthead.checkNotificationMessage("Client policy deleted");
|
|
|
|
sidebarPage.waitForPageLoad();
|
|
|
|
realmSettingsPage.checkEmptyPolicyList();
|
2021-12-06 10:50:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Check reloading JSON policies", () => {
|
|
|
|
realmSettingsPage.shouldReloadJSONPolicies();
|
|
|
|
});
|
|
|
|
});
|