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 { keycloakBefore } from "../support/util/keycloak_hooks";
7
import adminClient from "../support/util/AdminClient";
9
const loginPage = new LoginPage();
10
const sidebarPage = new SidebarPage();
11
const masthead = new Masthead();
12
const realmSettingsPage = new RealmSettingsPage();
14
describe("Realm settings general tab tests", () => {
15
const realmName = "Realm_" + uuid();
20
sidebarPage.goToRealm(realmName);
24
await adminClient.createRealm(realmName);
28
await adminClient.deleteRealm(realmName);
31
it("Test all general tab switches", () => {
32
sidebarPage.goToRealmSettings();
33
realmSettingsPage.toggleSwitch(
34
realmSettingsPage.managedAccessSwitch,
37
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
38
masthead.checkNotificationMessage("Realm successfully updated", true);
39
realmSettingsPage.toggleSwitch(
40
realmSettingsPage.managedAccessSwitch,
43
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
44
masthead.checkNotificationMessage("Realm successfully updated", true);
47
realmSettingsPage.toggleSwitch(`${realmName}-switch`);
48
masthead.checkNotificationMessage("Realm successfully updated", true);
51
realmSettingsPage.toggleSwitch(`${realmName}-switch`);
52
realmSettingsPage.disableRealm();
53
masthead.checkNotificationMessage("Realm successfully updated", true);
55
// Sometimes it takes the Keycloak server a while to disable the realm, even though the notification message has been displayed.
56
// To prevent flaky tests, we wait a second before continuing.
60
realmSettingsPage.toggleSwitch(`${realmName}-switch`);
61
masthead.checkNotificationMessage("Realm successfully updated");
64
it("Fail to set Realm ID to empty", () => {
65
sidebarPage.goToRealmSettings();
66
realmSettingsPage.clearRealmId();
67
realmSettingsPage.saveGeneral();
68
cy.get("#kc-realm-id-helper").should("have.text", "Required field");
71
it("Modify Display name", () => {
72
sidebarPage.goToRealmSettings();
73
realmSettingsPage.fillDisplayName("display_name");
74
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
75
masthead.checkNotificationMessage("Realm successfully updated", true);
78
it("Check Display name value", () => {
79
sidebarPage.goToRealmSettings();
80
realmSettingsPage.getDisplayName("display_name");
83
it("Modify front end URL", () => {
84
sidebarPage.goToRealmSettings();
85
realmSettingsPage.fillFrontendURL("www.example.com");
87
// TODO: Fix internal server error 500 when front-end URL is saved
88
// realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
89
// masthead.checkNotificationMessage("Realm successfully updated", true);
91
realmSettingsPage.getFrontendURL("www.example.com");
92
realmSettingsPage.clearFrontendURL();
95
it("Select SSL all requests", () => {
96
sidebarPage.goToRealmSettings();
97
realmSettingsPage.fillRequireSSL("All requests");
98
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
99
masthead.checkNotificationMessage("Realm successfully updated", true);
102
it("Verify SSL all requests displays", () => {
103
sidebarPage.goToRealmSettings();
104
realmSettingsPage.getRequireSSL("All requests");
107
it("Select SSL external requests", () => {
108
sidebarPage.goToRealmSettings();
109
realmSettingsPage.fillRequireSSL("External requests");
110
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
111
masthead.checkNotificationMessage("Realm successfully updated", true);
114
it("Verify SSL external requests displays", () => {
115
sidebarPage.goToRealmSettings();
116
realmSettingsPage.getRequireSSL("External requests");
119
it("Select SSL None", () => {
120
sidebarPage.goToRealmSettings();
121
realmSettingsPage.fillRequireSSL("None");
122
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
123
masthead.checkNotificationMessage("Realm successfully updated", true);
126
it("Verify SSL None displays", () => {
127
sidebarPage.goToRealmSettings();
128
realmSettingsPage.getRequireSSL("None");
131
it("Check Access Endpoints OpenID Endpoint Configuration link", () => {
132
sidebarPage.goToRealmSettings();
136
.contains("OpenID Endpoint Configuration")
142
)}/realms/${realmName}/.well-known/openid-configuration`,
144
.should("have.attr", "target", "_blank")
145
.should("have.attr", "rel", "noreferrer noopener");
148
it("Access Endpoints OpenID Endpoint Configuration link", () => {
149
sidebarPage.goToRealmSettings();
150
// Check the link is live
152
.contains("OpenID Endpoint Configuration")
154
cy.request(link.prop("href")).its("status").should("eq", 200);
158
it("Check if Access Endpoints SAML 2.0 Identity Provider Metadata link exists", () => {
159
sidebarPage.goToRealmSettings();
161
.contains("SAML 2.0 Identity Provider Metadata")
167
)}/realms/${realmName}/protocol/saml/descriptor`,
169
.should("have.attr", "target", "_blank")
170
.should("have.attr", "rel", "noreferrer noopener");
173
it("Access Endpoints SAML 2.0 Identity Provider Metadata link", () => {
174
sidebarPage.goToRealmSettings();
176
// Check the link is live
178
.contains("SAML 2.0 Identity Provider Metadata ")
180
cy.request(link.prop("href")).its("status").should("eq", 200);
184
it("Verify 'Revert' button works", () => {
185
sidebarPage.goToRealmSettings();
187
realmSettingsPage.fillDisplayName("should_be_reverted");
188
realmSettingsPage.revert(realmSettingsPage.generalRevertBtn);
189
realmSettingsPage.getDisplayName("display_name");