2021-04-19 11:41:07 +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";
|
2021-06-08 05:29:56 +00:00
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2021-04-19 11:41:07 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
2021-05-06 05:31:40 +00:00
|
|
|
import AdminClient from "../support/util/AdminClient";
|
2021-06-08 05:29:56 +00:00
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
2021-04-19 11:41:07 +00:00
|
|
|
|
2021-06-03 18:31:47 +00:00
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2021-06-08 05:29:56 +00:00
|
|
|
const masthead = new Masthead();
|
|
|
|
const modalUtils = new ModalUtils();
|
2021-06-03 18:31:47 +00:00
|
|
|
const realmSettingsPage = new RealmSettingsPage();
|
|
|
|
|
|
|
|
describe("Realm settings", () => {
|
|
|
|
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToRealm(realmName);
|
|
|
|
});
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
await new AdminClient().createRealm(realmName);
|
|
|
|
});
|
|
|
|
|
2021-06-08 05:29:56 +00:00
|
|
|
after(async () => {
|
|
|
|
await new AdminClient().deleteRealm(realmName);
|
|
|
|
});
|
2021-06-03 18:31:47 +00:00
|
|
|
|
2021-06-08 15:45:37 +00:00
|
|
|
const goToKeys = () => {
|
2021-07-09 14:23:49 +00:00
|
|
|
const keysUrl = `/auth/admin/realms/${realmName}/keys`;
|
2021-06-08 15:45:37 +00:00
|
|
|
cy.intercept(keysUrl).as("keysFetch");
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
cy.getId("rs-keys-list-tab").click();
|
2021-07-09 14:23:49 +00:00
|
|
|
cy.wait(["@keysFetch"]);
|
2021-06-08 15:45:37 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2021-07-12 18:19:50 +00:00
|
|
|
const goToDetails = () => {
|
|
|
|
const keysUrl = `/auth/admin/realms/${realmName}/keys`;
|
|
|
|
cy.intercept(keysUrl).as("keysFetch");
|
|
|
|
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
cy.getId("rs-providers-tab").click();
|
|
|
|
cy.getId("provider-name-link").contains("test_aes-generated").click();
|
|
|
|
cy.wait(["@keysFetch"]);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2021-07-01 06:48:30 +00:00
|
|
|
const addBundle = () => {
|
2021-07-09 14:23:49 +00:00
|
|
|
const localizationUrl = `/auth/admin/realms/${realmName}/localization/en`;
|
2021-07-01 06:48:30 +00:00
|
|
|
cy.intercept(localizationUrl).as("localizationFetch");
|
|
|
|
|
|
|
|
realmSettingsPage.addKeyValuePair(
|
|
|
|
"key_" + (Math.random() + 1).toString(36).substring(7),
|
|
|
|
"value_" + (Math.random() + 1).toString(36).substring(7)
|
|
|
|
);
|
|
|
|
|
2021-07-09 14:23:49 +00:00
|
|
|
cy.wait(["@localizationFetch"]);
|
|
|
|
|
2021-07-01 06:48:30 +00:00
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2021-06-08 15:45:37 +00:00
|
|
|
it("Go to general tab", function () {
|
2021-06-03 18:31:47 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
|
|
|
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
2021-07-09 14:23:49 +00:00
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
2021-06-03 18:31:47 +00:00
|
|
|
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
|
|
|
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
2021-07-09 14:23:49 +00:00
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
2021-06-03 18:31:47 +00:00
|
|
|
});
|
|
|
|
|
2021-06-08 05:29:56 +00:00
|
|
|
it("Go to login tab", () => {
|
2021-06-03 18:31:47 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.getId("rs-login-tab").click();
|
|
|
|
realmSettingsPage.toggleSwitch(realmSettingsPage.userRegSwitch);
|
|
|
|
realmSettingsPage.toggleSwitch(realmSettingsPage.forgotPwdSwitch);
|
|
|
|
realmSettingsPage.toggleSwitch(realmSettingsPage.rememberMeSwitch);
|
|
|
|
realmSettingsPage.toggleSwitch(realmSettingsPage.verifyEmailSwitch);
|
|
|
|
});
|
|
|
|
|
2021-06-08 05:29:56 +00:00
|
|
|
it("Go to email tab", () => {
|
2021-06-03 18:31:47 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.getId("rs-email-tab").click();
|
|
|
|
|
|
|
|
cy.wait(1000);
|
|
|
|
|
|
|
|
realmSettingsPage.addSenderEmail("example@example.com");
|
|
|
|
|
|
|
|
realmSettingsPage.toggleCheck(realmSettingsPage.enableSslCheck);
|
|
|
|
realmSettingsPage.toggleCheck(realmSettingsPage.enableStartTlsCheck);
|
|
|
|
|
|
|
|
realmSettingsPage.save(realmSettingsPage.emailSaveBtn);
|
2021-06-22 12:48:12 +00:00
|
|
|
|
2021-06-22 17:16:35 +00:00
|
|
|
realmSettingsPage.fillHostField("localhost");
|
2021-06-22 18:49:41 +00:00
|
|
|
cy.getId(realmSettingsPage.testConnectionButton).click();
|
2021-06-22 12:48:12 +00:00
|
|
|
|
2021-06-22 19:42:38 +00:00
|
|
|
realmSettingsPage.fillEmailField(
|
|
|
|
"example" + (Math.random() + 1).toString(36).substring(7) + "@example.com"
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.modalTestConnectionButton).click();
|
|
|
|
|
2021-06-10 20:00:14 +00:00
|
|
|
masthead.checkNotificationMessage("Error! Failed to send email.");
|
2021-06-03 18:31:47 +00:00
|
|
|
});
|
|
|
|
|
2021-06-08 05:29:56 +00:00
|
|
|
it("Go to themes tab", () => {
|
2021-06-03 18:31:47 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
2021-07-09 14:23:49 +00:00
|
|
|
cy.intercept(`/auth/admin/realms/${realmName}/keys`).as("load");
|
|
|
|
|
2021-06-03 18:31:47 +00:00
|
|
|
cy.getId("rs-themes-tab").click();
|
2021-07-09 14:23:49 +00:00
|
|
|
cy.wait(["@load"]);
|
|
|
|
|
2021-06-03 18:31:47 +00:00
|
|
|
realmSettingsPage.selectLoginThemeType("keycloak");
|
|
|
|
realmSettingsPage.selectAccountThemeType("keycloak");
|
|
|
|
realmSettingsPage.selectAdminThemeType("base");
|
|
|
|
realmSettingsPage.selectEmailThemeType("base");
|
|
|
|
|
|
|
|
realmSettingsPage.saveThemes();
|
|
|
|
});
|
|
|
|
|
2021-06-08 05:29:56 +00:00
|
|
|
describe("Events tab", () => {
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
|
|
|
|
it("Enable user events", () => {
|
2021-07-09 14:23:49 +00:00
|
|
|
cy.intercept("GET", `/auth/admin/realms/${realmName}/keys`).as("load");
|
2021-06-08 05:29:56 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.getId("rs-realm-events-tab").click();
|
2021-07-09 14:23:49 +00:00
|
|
|
cy.wait(["@load"]);
|
2021-06-08 05:29:56 +00:00
|
|
|
|
|
|
|
realmSettingsPage
|
|
|
|
.toggleSwitch(realmSettingsPage.enableEvents)
|
|
|
|
.save(realmSettingsPage.eventsUserSave);
|
|
|
|
masthead.checkNotificationMessage("Successfully saved configuration");
|
|
|
|
|
|
|
|
realmSettingsPage.clearEvents("user");
|
|
|
|
|
|
|
|
modalUtils
|
|
|
|
.checkModalMessage(
|
|
|
|
"If you clear all events of this realm, all records will be permanently cleared in the database"
|
|
|
|
)
|
|
|
|
.confirmModal();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user events have been cleared");
|
|
|
|
|
|
|
|
const events = ["Client info", "Client info error"];
|
|
|
|
|
|
|
|
cy.intercept("GET", `/auth/admin/realms/${realmName}/events/config`).as(
|
|
|
|
"fetchConfig"
|
|
|
|
);
|
|
|
|
realmSettingsPage.addUserEvents(events).clickAdd();
|
|
|
|
masthead.checkNotificationMessage("Successfully saved configuration");
|
|
|
|
cy.wait(["@fetchConfig"]);
|
|
|
|
cy.get(".pf-c-spinner__tail-ball").should("not.exist");
|
|
|
|
|
|
|
|
for (const event of events) {
|
|
|
|
listingPage.searchItem(event, false).itemExist(event);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Go to keys tab", () => {
|
2021-06-03 18:31:47 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
});
|
|
|
|
|
2021-06-08 05:29:56 +00:00
|
|
|
it("add Providers", () => {
|
2021-06-03 18:31:47 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
|
|
|
|
cy.getId("rs-providers-tab").click();
|
|
|
|
|
|
|
|
realmSettingsPage.toggleAddProviderDropdown();
|
|
|
|
|
|
|
|
cy.getId("option-aes-generated").click();
|
|
|
|
realmSettingsPage.enterConsoleDisplayName("test_aes-generated");
|
|
|
|
realmSettingsPage.addProvider();
|
|
|
|
|
|
|
|
realmSettingsPage.toggleAddProviderDropdown();
|
|
|
|
|
|
|
|
cy.getId("option-ecdsa-generated").click();
|
|
|
|
realmSettingsPage.enterConsoleDisplayName("test_ecdsa-generated");
|
|
|
|
realmSettingsPage.addProvider();
|
|
|
|
|
|
|
|
realmSettingsPage.toggleAddProviderDropdown();
|
|
|
|
|
|
|
|
cy.getId("option-hmac-generated").click();
|
|
|
|
realmSettingsPage.enterConsoleDisplayName("test_hmac-generated");
|
|
|
|
realmSettingsPage.addProvider();
|
|
|
|
|
|
|
|
realmSettingsPage.toggleAddProviderDropdown();
|
|
|
|
|
|
|
|
cy.getId("option-rsa-generated").click();
|
|
|
|
realmSettingsPage.enterConsoleDisplayName("test_rsa-generated");
|
|
|
|
realmSettingsPage.addProvider();
|
2021-04-19 11:41:07 +00:00
|
|
|
});
|
2021-06-08 15:45:37 +00:00
|
|
|
|
2021-07-12 18:19:50 +00:00
|
|
|
it("go to details", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
goToDetails();
|
|
|
|
});
|
|
|
|
|
2021-06-16 11:35:03 +00:00
|
|
|
it("Test keys", () => {
|
2021-06-08 15:45:37 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
goToKeys();
|
|
|
|
|
|
|
|
realmSettingsPage.testSelectFilter();
|
|
|
|
});
|
2021-07-01 06:48:30 +00:00
|
|
|
|
|
|
|
it("add locale", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-localization-tab").click();
|
|
|
|
|
|
|
|
addBundle();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Success! The localization text has been created."
|
|
|
|
);
|
|
|
|
});
|
2021-07-09 14:23:49 +00:00
|
|
|
|
|
|
|
it("Realm header settings", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
cy.get("#pf-tab-securityDefences-securityDefences").click();
|
|
|
|
cy.getId("headers-form-tab-save").should("be.disabled");
|
|
|
|
cy.get("#xFrameOptions").clear().type("DENY");
|
|
|
|
cy.getId("headers-form-tab-save").should("be.enabled").click();
|
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
|
|
|
});
|
2021-04-19 11:41:07 +00:00
|
|
|
});
|