1
import { v4 as uuid } from "uuid";
2
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
3
import LoginPage from "../support/pages/LoginPage";
4
import RealmSettingsPage from "../support/pages/admin-ui/manage/realm_settings/RealmSettingsPage";
5
import Masthead from "../support/pages/admin-ui/Masthead";
6
import ModalUtils from "../support/util/ModalUtils";
7
import { keycloakBefore } from "../support/util/keycloak_hooks";
8
import ListingPage from "../support/pages/admin-ui/ListingPage";
9
import adminClient from "../support/util/AdminClient";
10
import KeysTab from "../support/pages/admin-ui/manage/realm_settings/KeysTab";
12
const loginPage = new LoginPage();
13
const sidebarPage = new SidebarPage();
14
const masthead = new Masthead();
15
const modalUtils = new ModalUtils();
16
const realmSettingsPage = new RealmSettingsPage();
17
const keysTab = new KeysTab();
19
describe("Realm settings events tab tests", () => {
20
const realmName = "Realm_" + uuid();
21
const listingPage = new ListingPage();
26
sidebarPage.goToRealm(realmName);
30
await adminClient.createRealm(realmName);
34
await adminClient.deleteRealm(realmName);
37
const goToDetails = () => {
38
const keysUrl = `/admin/realms/${realmName}/keys`;
39
cy.intercept(keysUrl).as("keysFetch");
41
keysTab.goToKeysTab();
42
cy.findByTestId("rs-providers-tab").click();
43
cy.findAllByTestId("provider-name-link")
44
.contains("test_aes-generated")
47
sidebarPage.goToRealmSettings();
49
keysTab.goToKeysTab();
50
cy.findByTestId("rs-providers-tab").click();
51
cy.findAllByTestId("provider-name-link")
52
.contains("test_hmac-generated")
55
sidebarPage.goToRealmSettings();
57
keysTab.goToKeysTab();
58
cy.findByTestId("rs-providers-tab").click();
59
cy.findAllByTestId("provider-name-link").contains("test_rsa").click();
61
sidebarPage.goToRealmSettings();
63
keysTab.goToKeysTab();
64
cy.findByTestId("rs-providers-tab").click();
65
cy.findAllByTestId("provider-name-link")
66
.contains("test_rsa-generated")
69
sidebarPage.goToRealmSettings();
71
keysTab.goToKeysTab();
72
cy.findByTestId("rs-providers-tab").click();
73
cy.findAllByTestId("provider-name-link")
74
.contains("test_rsa-enc-generated")
77
cy.wait(["@keysFetch"]);
82
const goToKeys = () => {
83
const keysUrl = `/admin/realms/${realmName}/keys`;
84
cy.intercept(keysUrl).as("keysFetch");
85
keysTab.goToKeysTab();
86
cy.findByTestId("rs-keys-list-tab").click();
87
cy.wait(["@keysFetch"]);
92
it("Enable user events", () => {
93
cy.intercept("GET", `/admin/realms/${realmName}/events/config`).as("load");
94
sidebarPage.goToRealmSettings();
95
cy.findByTestId("rs-realm-events-tab").click();
96
cy.findByTestId("rs-events-tab").click();
99
.toggleSwitch(realmSettingsPage.enableEvents, false)
100
.save(realmSettingsPage.eventsUserSave);
101
masthead.checkNotificationMessage("Successfully saved configuration");
102
realmSettingsPage.clearEvents("user");
105
"If you clear all events of this realm, all records will be permanently cleared in the database",
108
masthead.checkNotificationMessage("The user events have been cleared");
109
const events = ["Client info", "Client info error"];
110
cy.intercept("GET", `/admin/realms/${realmName}/events/config`).as(
113
realmSettingsPage.addUserEvents(events).clickAdd();
114
masthead.checkNotificationMessage("Successfully saved configuration");
115
cy.wait(["@fetchConfig"]);
116
sidebarPage.waitForPageLoad();
118
for (const event of events) {
119
listingPage.searchItem(event, false).itemExist(event);
123
it("Go to keys tab", () => {
124
sidebarPage.goToRealmSettings();
126
keysTab.goToKeysTab();
129
it("add Providers", () => {
130
sidebarPage.goToRealmSettings();
132
keysTab.goToKeysTab();
134
cy.findByTestId("rs-providers-tab").click();
136
realmSettingsPage.toggleAddProviderDropdown();
138
cy.findByTestId("option-aes-generated").click();
139
realmSettingsPage.enterUIDisplayName("test_aes-generated");
140
realmSettingsPage.addProvider();
142
realmSettingsPage.toggleAddProviderDropdown();
144
cy.findByTestId("option-ecdsa-generated").click();
145
realmSettingsPage.enterUIDisplayName("test_ecdsa-generated");
146
realmSettingsPage.toggleSwitch("active", false);
147
realmSettingsPage.addProvider();
149
realmSettingsPage.toggleAddProviderDropdown();
151
cy.findByTestId("option-hmac-generated").click();
152
realmSettingsPage.enterUIDisplayName("test_hmac-generated");
153
realmSettingsPage.toggleSwitch("enabled", false);
154
realmSettingsPage.addProvider();
156
realmSettingsPage.toggleAddProviderDropdown();
158
cy.findByTestId("option-rsa-generated").click();
159
realmSettingsPage.enterUIDisplayName("test_rsa-generated");
160
realmSettingsPage.addProvider();
162
realmSettingsPage.toggleAddProviderDropdown();
164
cy.findByTestId("option-rsa-enc-generated").click();
165
realmSettingsPage.enterUIDisplayName("test_rsa-enc-generated");
166
realmSettingsPage.addProvider();
169
it("search providers", () => {
170
sidebarPage.goToRealmSettings();
172
keysTab.goToKeysTab();
174
cy.findByTestId("rs-providers-tab").click();
177
cy.findByTestId("provider-search-input").type("rsa{enter}");
178
listingPage.checkTableLength(4, "kc-draggable-table");
179
cy.findByTestId("provider-search-input").clear().type("{enter}");
182
it("go to details", () => {
183
sidebarPage.goToRealmSettings();
187
it("Test keys", () => {
188
sidebarPage.goToRealmSettings();
191
realmSettingsPage.testSelectFilter();
194
it.skip("Should search active keys", () => {
195
sidebarPage.goToRealmSettings();
198
realmSettingsPage.switchToActiveFilter();
199
listingPage.searchItem("rs", false);
200
listingPage.checkTableLength(3, "kc-keys-list");
203
it("Should search passive keys", () => {
204
sidebarPage.goToRealmSettings();
207
realmSettingsPage.switchToPassiveFilter();
208
listingPage.searchItem("ec", false);
209
listingPage.checkTableLength(1, "kc-keys-list");
212
it("Should search disabled keys", () => {
213
sidebarPage.goToRealmSettings();
216
realmSettingsPage.switchToDisabledFilter();
217
listingPage.searchItem("hs", false);
218
listingPage.checkTableLength(1, "kc-keys-list");
221
it("delete provider", () => {
222
sidebarPage.goToRealmSettings();
224
keysTab.goToKeysTab();
226
cy.findByTestId("rs-providers-tab").click();
228
realmSettingsPage.deleteProvider("test_aes-generated");
231
it("list keys", () => {
232
sidebarPage.goToRealmSettings();
233
keysTab.goToKeysTab();
234
realmSettingsPage.checkKeyPublic();
237
it("Realm header settings", () => {
238
sidebarPage.goToRealmSettings();
239
cy.findByTestId("rs-security-defenses-tab").click();
240
cy.findByTestId("headers-form-tab-save").should("be.disabled");
241
cy.get("#xFrameOptions").clear().type("DENY");
242
cy.findByTestId("headers-form-tab-save").should("be.enabled").click();
244
masthead.checkNotificationMessage("Realm successfully updated");
247
it("Brute force detection", () => {
248
sidebarPage.goToRealmSettings();
249
cy.findAllByTestId("rs-security-defenses-tab").click();
250
cy.get("#pf-tab-20-bruteForce").click();
252
cy.findByTestId("brute-force-tab-save").should("be.disabled");
254
cy.get("#kc-brute-force-mode").click();
255
cy.findByTestId("select-brute-force-mode")
256
.contains("Lockout temporarily")
258
cy.findByTestId("waitIncrementSeconds").type("1");
259
cy.findByTestId("maxFailureWaitSeconds").type("1");
260
cy.findByTestId("maxDeltaTimeSeconds").type("1");
261
cy.findByTestId("minimumQuickLoginWaitSeconds").type("1");
263
cy.findByTestId("brute-force-tab-save").should("be.enabled").click();
264
masthead.checkNotificationMessage("Realm successfully updated");
267
it("add session data", () => {
268
sidebarPage.goToRealmSettings();
270
cy.findByTestId("rs-sessions-tab").click();
272
realmSettingsPage.populateSessionsPage();
273
realmSettingsPage.save("sessions-tab-save");
275
masthead.checkNotificationMessage("Realm successfully updated");
278
it("check that sessions data was saved", () => {
279
sidebarPage.goToAuthentication();
280
sidebarPage.goToRealmSettings();
282
cy.findByTestId("rs-sessions-tab").click();
284
cy.findByTestId(realmSettingsPage.ssoSessionIdleInput).should(
288
cy.findByTestId(realmSettingsPage.ssoSessionMaxInput).should(
292
cy.findByTestId(realmSettingsPage.ssoSessionIdleRememberMeInput).should(
296
cy.findByTestId(realmSettingsPage.ssoSessionMaxRememberMeInput).should(
301
cy.findByTestId(realmSettingsPage.clientSessionIdleInput).should(
305
cy.findByTestId(realmSettingsPage.clientSessionMaxInput).should(
310
cy.findByTestId(realmSettingsPage.offlineSessionIdleInput).should(
314
cy.findByTestId(realmSettingsPage.offlineSessionMaxSwitch).should(
319
cy.findByTestId(realmSettingsPage.loginTimeoutInput).should(
323
cy.findByTestId(realmSettingsPage.loginActionTimeoutInput).should(
329
it("add token data", () => {
330
sidebarPage.goToRealmSettings();
332
cy.findByTestId("rs-tokens-tab").click();
334
realmSettingsPage.populateTokensPage();
335
realmSettingsPage.save("tokens-tab-save");
337
masthead.checkNotificationMessage("Realm successfully updated");
340
it("check that token data was saved", () => {
341
sidebarPage.goToRealmSettings();
343
cy.findByTestId("rs-tokens-tab").click();
345
cy.findByTestId(realmSettingsPage.accessTokenLifespanInput).should(
349
cy.findByTestId(realmSettingsPage.accessTokenLifespanImplicitInput).should(
353
cy.findByTestId(realmSettingsPage.clientLoginTimeoutInput).should(
357
cy.findByTestId(realmSettingsPage.userInitiatedActionLifespanInput).should(
362
cy.findByTestId(realmSettingsPage.defaultAdminInitatedInput).should(
366
cy.findByTestId(realmSettingsPage.emailVerificationInput).should(
371
cy.findByTestId(realmSettingsPage.idpEmailVerificationInput).should(
375
cy.findByTestId(realmSettingsPage.forgotPasswordInput).should(
380
cy.findByTestId(realmSettingsPage.executeActionsInput).should(
387
describe("Realm settings events tab tests", () => {
391
sidebarPage.goToRealmSettings();
392
cy.findByTestId("rs-realm-events-tab").click();
393
cy.findByTestId("rs-event-listeners-tab").click();
396
it("Should display event listeners form", () => {
397
realmSettingsPage.shouldDisplayEventListenersForm();
400
it("Should revert saving event listener", () => {
401
realmSettingsPage.shouldRevertSavingEventListener();
404
it("Should save event listener", () => {
405
realmSettingsPage.shouldSaveEventListener();
408
it("Should remove event from event listener", () => {
409
realmSettingsPage.shouldRemoveEventFromEventListener();
412
it("Should remove all events from event listener and re-save original", () => {
413
realmSettingsPage.shouldSaveEventListener();
414
realmSettingsPage.shouldRemoveAllEventListeners();
415
realmSettingsPage.shouldReSaveEventListener();