Keycloak

Форк
0
/
realm_settings_general_tab_test.spec.ts 
191 строка · 6.3 Кб
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";
8

9
const loginPage = new LoginPage();
10
const sidebarPage = new SidebarPage();
11
const masthead = new Masthead();
12
const realmSettingsPage = new RealmSettingsPage();
13

14
describe("Realm settings general tab tests", () => {
15
  const realmName = "Realm_" + uuid();
16

17
  beforeEach(() => {
18
    loginPage.logIn();
19
    keycloakBefore();
20
    sidebarPage.goToRealm(realmName);
21
  });
22

23
  before(async () => {
24
    await adminClient.createRealm(realmName);
25
  });
26

27
  after(async () => {
28
    await adminClient.deleteRealm(realmName);
29
  });
30

31
  it("Test all general tab switches", () => {
32
    sidebarPage.goToRealmSettings();
33
    realmSettingsPage.toggleSwitch(
34
      realmSettingsPage.managedAccessSwitch,
35
      false,
36
    );
37
    realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
38
    masthead.checkNotificationMessage("Realm successfully updated", true);
39
    realmSettingsPage.toggleSwitch(
40
      realmSettingsPage.managedAccessSwitch,
41
      false,
42
    );
43
    realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
44
    masthead.checkNotificationMessage("Realm successfully updated", true);
45

46
    // Enable realm
47
    realmSettingsPage.toggleSwitch(`${realmName}-switch`);
48
    masthead.checkNotificationMessage("Realm successfully updated", true);
49

50
    // Disable realm
51
    realmSettingsPage.toggleSwitch(`${realmName}-switch`);
52
    realmSettingsPage.disableRealm();
53
    masthead.checkNotificationMessage("Realm successfully updated", true);
54

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.
57
    cy.wait(1000);
58

59
    // Re-enable realm
60
    realmSettingsPage.toggleSwitch(`${realmName}-switch`);
61
    masthead.checkNotificationMessage("Realm successfully updated");
62
  });
63

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");
69
  });
70

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);
76
  });
77

78
  it("Check Display name value", () => {
79
    sidebarPage.goToRealmSettings();
80
    realmSettingsPage.getDisplayName("display_name");
81
  });
82

83
  it("Modify front end URL", () => {
84
    sidebarPage.goToRealmSettings();
85
    realmSettingsPage.fillFrontendURL("www.example.com");
86

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);
90

91
    realmSettingsPage.getFrontendURL("www.example.com");
92
    realmSettingsPage.clearFrontendURL();
93
  });
94

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);
100
  });
101

102
  it("Verify SSL all requests displays", () => {
103
    sidebarPage.goToRealmSettings();
104
    realmSettingsPage.getRequireSSL("All requests");
105
  });
106

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);
112
  });
113

114
  it("Verify SSL external requests displays", () => {
115
    sidebarPage.goToRealmSettings();
116
    realmSettingsPage.getRequireSSL("External requests");
117
  });
118

119
  it("Select SSL None", () => {
120
    sidebarPage.goToRealmSettings();
121
    realmSettingsPage.fillRequireSSL("None");
122
    realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
123
    masthead.checkNotificationMessage("Realm successfully updated", true);
124
  });
125

126
  it("Verify SSL None displays", () => {
127
    sidebarPage.goToRealmSettings();
128
    realmSettingsPage.getRequireSSL("None");
129
  });
130

131
  it("Check Access Endpoints OpenID Endpoint Configuration link", () => {
132
    sidebarPage.goToRealmSettings();
133

134
    // Check link exists
135
    cy.get("a")
136
      .contains("OpenID Endpoint Configuration")
137
      .should(
138
        "have.attr",
139
        "href",
140
        `${Cypress.env(
141
          "KEYCLOAK_SERVER",
142
        )}/realms/${realmName}/.well-known/openid-configuration`,
143
      )
144
      .should("have.attr", "target", "_blank")
145
      .should("have.attr", "rel", "noreferrer noopener");
146
  });
147

148
  it("Access Endpoints OpenID Endpoint Configuration link", () => {
149
    sidebarPage.goToRealmSettings();
150
    // Check the link is live
151
    cy.get("a")
152
      .contains("OpenID Endpoint Configuration")
153
      .then((link) => {
154
        cy.request(link.prop("href")).its("status").should("eq", 200);
155
      });
156
  });
157

158
  it("Check if Access Endpoints SAML 2.0 Identity Provider Metadata link exists", () => {
159
    sidebarPage.goToRealmSettings();
160
    cy.get("a")
161
      .contains("SAML 2.0 Identity Provider Metadata")
162
      .should(
163
        "have.attr",
164
        "href",
165
        `${Cypress.env(
166
          "KEYCLOAK_SERVER",
167
        )}/realms/${realmName}/protocol/saml/descriptor`,
168
      )
169
      .should("have.attr", "target", "_blank")
170
      .should("have.attr", "rel", "noreferrer noopener");
171
  });
172

173
  it("Access Endpoints SAML 2.0 Identity Provider Metadata link", () => {
174
    sidebarPage.goToRealmSettings();
175

176
    // Check the link is live
177
    cy.get("a")
178
      .contains("SAML 2.0 Identity Provider Metadata ")
179
      .then((link) => {
180
        cy.request(link.prop("href")).its("status").should("eq", 200);
181
      });
182
  });
183

184
  it("Verify 'Revert' button works", () => {
185
    sidebarPage.goToRealmSettings();
186

187
    realmSettingsPage.fillDisplayName("should_be_reverted");
188
    realmSettingsPage.revert(realmSettingsPage.generalRevertBtn);
189
    realmSettingsPage.getDisplayName("display_name");
190
  });
191
});
192

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.