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();
|
2021-07-16 08:22:08 +00:00
|
|
|
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
cy.getId("rs-providers-tab").click();
|
|
|
|
cy.getId("provider-name-link").contains("test_hmac-generated").click();
|
2021-07-19 18:35:06 +00:00
|
|
|
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
cy.getId("rs-providers-tab").click();
|
|
|
|
cy.getId("provider-name-link").contains("test_rsa").click();
|
2021-07-16 08:22:08 +00:00
|
|
|
|
2021-07-19 15:07:19 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
cy.getId("rs-providers-tab").click();
|
|
|
|
cy.getId("provider-name-link").contains("test_rsa-generated").click();
|
|
|
|
|
2021-07-12 18:19:50 +00:00
|
|
|
cy.wait(["@keysFetch"]);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2021-09-01 13:45:46 +00:00
|
|
|
/*const deleteProvider = (providerName: string) => {
|
2021-07-26 09:21:56 +00:00
|
|
|
const url = `/auth/admin/realms/${realmName}/users/*`;
|
|
|
|
cy.intercept(url).as("reload");
|
|
|
|
cy.getId("provider-name")
|
2021-07-19 13:58:35 +00:00
|
|
|
.contains(providerName)
|
2021-07-26 09:21:56 +00:00
|
|
|
.parentsUntil(".pf-c-data-list__item-row")
|
|
|
|
.find(".pf-c-dropdown__toggle")
|
2021-07-19 13:58:35 +00:00
|
|
|
.click()
|
|
|
|
.getId(realmSettingsPage.deleteAction)
|
|
|
|
.click();
|
2021-07-23 10:58:39 +00:00
|
|
|
cy.getId(realmSettingsPage.modalConfirm).click();
|
2021-07-19 13:58:35 +00:00
|
|
|
|
2021-07-26 09:21:56 +00:00
|
|
|
cy.wait(["@reload"]);
|
2021-07-19 13:58:35 +00:00
|
|
|
return this;
|
2021-09-01 13:45:46 +00:00
|
|
|
};*/
|
2021-07-19 13:58:35 +00:00
|
|
|
|
2021-08-04 10:50:25 +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-08-04 10:50:25 +00:00
|
|
|
};
|
2021-07-01 06:48:30 +00:00
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
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"]);
|
2021-09-15 09:45:56 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2021-06-08 05:29:56 +00:00
|
|
|
|
|
|
|
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-09-01 13:45:46 +00:00
|
|
|
/*it("delete providers", () => {
|
2021-07-19 13:58:35 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
2021-07-26 09:21:56 +00:00
|
|
|
const url = `/auth/admin/realms/${realmName}/keys`;
|
|
|
|
cy.intercept(url).as("load");
|
|
|
|
|
2021-07-19 13:58:35 +00:00
|
|
|
cy.getId("rs-keys-tab").click();
|
|
|
|
cy.getId("rs-providers-tab").click();
|
|
|
|
|
2021-07-26 09:21:56 +00:00
|
|
|
cy.wait("@load");
|
2021-07-23 10:58:39 +00:00
|
|
|
|
2021-07-19 13:58:35 +00:00
|
|
|
deleteProvider("test_aes-generated");
|
|
|
|
deleteProvider("test_ecdsa-generated");
|
|
|
|
deleteProvider("test_hmac-generated");
|
|
|
|
deleteProvider("test_rsa-generated");
|
2021-09-01 13:45:46 +00:00
|
|
|
});*/
|
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
|
|
|
|
2021-08-04 10:50:25 +00:00
|
|
|
it("add locale", () => {
|
2021-07-01 06:48:30 +00:00
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-localization-tab").click();
|
|
|
|
|
|
|
|
addBundle();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Success! The localization text has been created."
|
|
|
|
);
|
2021-08-04 10:50:25 +00:00
|
|
|
});
|
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();
|
2021-07-15 14:25:22 +00:00
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("add session data", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-sessions-tab").click();
|
|
|
|
|
|
|
|
realmSettingsPage.populateSessionsPage();
|
|
|
|
realmSettingsPage.save("sessions-tab-save");
|
|
|
|
|
2021-07-09 14:23:49 +00:00
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
|
|
|
});
|
2021-07-15 14:25:22 +00:00
|
|
|
|
|
|
|
it("check that sessions data was saved", () => {
|
|
|
|
sidebarPage.goToAuthentication();
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-sessions-tab").click();
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.ssoSessionIdleInput).should("have.value", 1);
|
|
|
|
cy.getId(realmSettingsPage.ssoSessionMaxInput).should("have.value", 2);
|
|
|
|
cy.getId(realmSettingsPage.ssoSessionIdleRememberMeInput).should(
|
|
|
|
"have.value",
|
|
|
|
3
|
|
|
|
);
|
|
|
|
cy.getId(realmSettingsPage.ssoSessionMaxRememberMeInput).should(
|
|
|
|
"have.value",
|
|
|
|
4
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.clientSessionIdleInput).should("have.value", 5);
|
|
|
|
cy.getId(realmSettingsPage.clientSessionMaxInput).should("have.value", 6);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.offlineSessionIdleInput).should("have.value", 7);
|
|
|
|
cy.getId(realmSettingsPage.offlineSessionMaxSwitch).should(
|
|
|
|
"have.value",
|
|
|
|
"on"
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.loginTimeoutInput).should("have.value", 9);
|
|
|
|
cy.getId(realmSettingsPage.loginActionTimeoutInput).should(
|
|
|
|
"have.value",
|
|
|
|
10
|
|
|
|
);
|
|
|
|
});
|
2021-08-09 19:28:24 +00:00
|
|
|
|
|
|
|
it("add token data", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-tokens-tab").click();
|
|
|
|
|
|
|
|
realmSettingsPage.populateTokensPage();
|
|
|
|
realmSettingsPage.save("tokens-tab-save");
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Realm successfully updated");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("check that token data was saved", () => {
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
|
|
|
|
cy.getId("rs-tokens-tab").click();
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.accessTokenLifespanInput).should(
|
|
|
|
"have.value",
|
|
|
|
1
|
|
|
|
);
|
|
|
|
cy.getId(realmSettingsPage.accessTokenLifespanImplicitInput).should(
|
|
|
|
"have.value",
|
|
|
|
2
|
|
|
|
);
|
|
|
|
cy.getId(realmSettingsPage.clientLoginTimeoutInput).should("have.value", 3);
|
|
|
|
cy.getId(realmSettingsPage.userInitiatedActionLifespanInput).should(
|
|
|
|
"have.value",
|
|
|
|
4
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.defaultAdminInitatedInput).should(
|
|
|
|
"have.value",
|
|
|
|
5
|
|
|
|
);
|
|
|
|
cy.getId(realmSettingsPage.emailVerificationInput).should("have.value", 6);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.idpEmailVerificationInput).should(
|
|
|
|
"have.value",
|
|
|
|
7
|
|
|
|
);
|
|
|
|
cy.getId(realmSettingsPage.forgotPasswordInput).should("have.value", 8);
|
|
|
|
|
|
|
|
cy.getId(realmSettingsPage.executeActionsInput).should("have.value", 9);
|
|
|
|
});
|
2021-04-19 11:41:07 +00:00
|
|
|
});
|