keycloak-scim/cypress/integration/realm_settings_client_policies_test.spec.ts

129 lines
4.3 KiB
TypeScript
Raw Normal View History

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-01-24 14:17:55 +00:00
import {
keycloakBefore,
keycloakBeforeEach,
} from "../support/util/keycloak_hooks";
2021-12-06 10:50:29 +00:00
import AdminClient from "../support/util/AdminClient";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
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-01-24 14:17:55 +00:00
keycloakBeforeEach();
sidebarPage.goToRealm(realmName);
2021-12-06 10:50:29 +00:00
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientPolicies-tab").click();
});
2022-01-24 14:17:55 +00:00
before(() => {
keycloakBefore();
new AdminClient().createRealm(realmName);
loginPage.logIn();
2021-12-06 10:50:29 +00:00
});
2022-01-24 14:17:55 +00:00
after(() => {
new AdminClient().deleteRealm(realmName);
2021-12-06 10:50:29 +00:00
});
it("Go to client policies tab", () => {
realmSettingsPage.shouldDisplayPoliciesTab();
});
it("Check new client form is displaying", () => {
realmSettingsPage.shouldDisplayNewClientPolicyForm();
});
it("Complete new client form and cancel", () => {
realmSettingsPage.shouldCompleteAndCancelCreateNewClientPolicy();
});
it("Complete new client form and submit", () => {
realmSettingsPage.shouldCompleteAndCreateNewClientPolicyFromEmptyState();
});
it("Should perform client profile search by profile name", () => {
realmSettingsPage.shouldSearchClientPolicy();
});
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", () => {
realmSettingsPage.shouldCancelDeletingCondition();
});
it("Should delete client-roles condition from a client profile", () => {
realmSettingsPage.shouldDeleteClientRolesCondition();
});
it("Should delete client-scopes condition from a client profile", () => {
realmSettingsPage.shouldDeleteClientScopesCondition();
});
it("Check cancelling the client policy deletion", () => {
realmSettingsPage.shouldDisplayDeleteClientPolicyDialog();
});
it("Check deleting the client policy", () => {
realmSettingsPage.shouldDeleteClientPolicyDialog();
});
it("Check navigating between Form View and JSON editor", () => {
realmSettingsPage.shouldNavigateBetweenFormAndJSONViewPolicies();
});
it("Should not create duplicate client profile", () => {
2022-01-24 14:17:55 +00:00
const url = `/auth/admin/realms/${realmName}/client-policies/policies`;
cy.intercept("PUT", url).as("save");
2021-12-06 10:50:29 +00:00
realmSettingsPage.shouldCompleteAndCreateNewClientPolicyFromEmptyState();
2022-01-24 14:17:55 +00:00
cy.wait("@save");
2021-12-06 10:50:29 +00:00
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientPolicies-tab").click();
realmSettingsPage.shouldCompleteAndCreateNewClientPolicy();
2022-01-24 14:17:55 +00:00
cy.wait("@save");
2021-12-06 10:50:29 +00:00
realmSettingsPage.shouldNotCreateDuplicateClientPolicy();
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-clientPolicies-tab").click();
cy.findByTestId("rs-policies-clientPolicies-tab").click();
realmSettingsPage.shouldDeleteClientProfileDialog();
});
it("Check deleting newly created client policy from create view via dropdown", () => {
realmSettingsPage.shouldRemoveClientPolicyFromCreateView();
});
it("Check reloading JSON policies", () => {
realmSettingsPage.shouldReloadJSONPolicies();
});
});