Keycloak

Форк
0
/
clients_saml_test.spec.ts 
195 строк · 5.7 Кб
1
import LoginPage from "../support/pages/LoginPage";
2
import Masthead from "../support/pages/admin-ui/Masthead";
3
import ListingPage from "../support/pages/admin-ui/ListingPage";
4
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
5
import ModalUtils from "../support/util/ModalUtils";
6
import adminClient from "../support/util/AdminClient";
7
import { keycloakBefore } from "../support/util/keycloak_hooks";
8
import SettingsTab from "../support/pages/admin-ui/manage/clients/client_details/tabs/SettingsTab";
9

10
const loginPage = new LoginPage();
11
const masthead = new Masthead();
12
const sidebarPage = new SidebarPage();
13
const listingPage = new ListingPage();
14
const modalUtils = new ModalUtils();
15

16
describe("Clients SAML tests", () => {
17
  describe("SAML test", () => {
18
    const samlClientName = "saml";
19

20
    before(() => {
21
      adminClient.createClient({
22
        protocol: "saml",
23
        clientId: samlClientName,
24
        publicClient: false,
25
      });
26
    });
27

28
    after(() => {
29
      adminClient.deleteClient(samlClientName);
30
    });
31

32
    beforeEach(() => {
33
      loginPage.logIn();
34
      keycloakBefore();
35
      sidebarPage.goToClients();
36
      listingPage.searchItem(samlClientName).goToItemDetails(samlClientName);
37
    });
38

39
    it("should display the saml sections on details screen", () => {
40
      cy.get(".pf-c-jump-links__list").should(($ul) => {
41
        expect($ul)
42
          .to.contain("SAML capabilities")
43
          .to.contain("Signature and Encryption");
44
      });
45
    });
46

47
    it("should save force name id format", () => {
48
      cy.get(".pf-c-jump-links__list").contains("SAML capabilities").click();
49

50
      cy.findByTestId("forceNameIdFormat").click({
51
        force: true,
52
      });
53
      cy.findByTestId("settings-save").click();
54
      masthead.checkNotificationMessage("Client successfully updated");
55
    });
56
  });
57

58
  describe("SAML keys tab", () => {
59
    const clientId = "saml-keys";
60

61
    before(() => {
62
      adminClient.createClient({
63
        clientId,
64
        protocol: "saml",
65
      });
66
    });
67

68
    after(() => {
69
      adminClient.deleteClient(clientId);
70
    });
71

72
    beforeEach(() => {
73
      loginPage.logIn();
74
      keycloakBefore();
75
      sidebarPage.goToClients();
76
      listingPage.searchItem(clientId).goToItemDetails(clientId);
77
      cy.findByTestId("keysTab").click();
78
    });
79

80
    it("should doesn't disable signature when cancel", () => {
81
      cy.findByTestId("clientSignature").click({ force: true });
82

83
      modalUtils
84
        .checkModalTitle('Disable "Client signature required"')
85
        .cancelModal();
86

87
      cy.findAllByTestId("certificate").should("have.length", 1);
88
    });
89

90
    it("should disable client signature", () => {
91
      cy.intercept(
92
        "admin/realms/master/clients/*/certificates/saml.signing",
93
      ).as("load");
94
      cy.findByTestId("clientSignature").click({ force: true });
95

96
      modalUtils
97
        .checkModalTitle('Disable "Client signature required"')
98
        .confirmModal();
99

100
      masthead.checkNotificationMessage("Client successfully updated");
101
      cy.findAllByTestId("certificate").should("have.length", 0);
102
    });
103

104
    it("should enable Encryption keys config", () => {
105
      cy.findByTestId("encryptAssertions").click({ force: true });
106

107
      cy.findByTestId("generate").click();
108
      masthead.checkNotificationMessage(
109
        "New key pair and certificate generated successfully",
110
      );
111

112
      modalUtils.confirmModal();
113
      cy.findAllByTestId("certificate").should("have.length", 1);
114
    });
115
  });
116

117
  describe("SAML settings tab", () => {
118
    const clientId = "saml-settings";
119
    const settingsTab = new SettingsTab();
120

121
    before(() => {
122
      adminClient.createClient({
123
        clientId,
124
        protocol: "saml",
125
      });
126
    });
127

128
    after(() => {
129
      adminClient.deleteClient(clientId);
130
    });
131

132
    beforeEach(() => {
133
      loginPage.logIn();
134
      keycloakBefore();
135
      sidebarPage.goToClients();
136
      listingPage.searchItem(clientId).goToItemDetails(clientId);
137
    });
138

139
    it("should check SAML capabilities", () => {
140
      cy.get(".pf-c-jump-links__list").contains("SAML capabilities").click();
141

142
      settingsTab.assertNameIdFormatDropdown();
143
      settingsTab.assertSAMLCapabilitiesSwitches();
144
    });
145

146
    it("should check signature and encryption", () => {
147
      cy.get(".pf-c-jump-links__list")
148
        .contains("Signature and Encryption")
149
        .click();
150

151
      settingsTab.assertSignatureAlgorithmDropdown();
152
      settingsTab.assertSignatureKeyNameDropdown();
153
      settingsTab.assertCanonicalizationDropdown();
154

155
      settingsTab.assertSignatureEncryptionSwitches();
156
    });
157

158
    it("should check access settings", () => {
159
      cy.get(".pf-c-jump-links__list").contains("Access settings").click();
160

161
      const validUrl =
162
        "http://localhost:8180/realms/master/protocol/" +
163
        clientId +
164
        "/clients/";
165
      const rootUrlError =
166
        "Client could not be updated: Root URL is not a valid URL";
167
      const homeUrlError =
168
        "Client could not be updated: Base URL is not a valid URL";
169

170
      cy.get("#kc-root-url").type("Invalid URL");
171
      settingsTab.clickSaveBtn();
172
      masthead.checkNotificationMessage(rootUrlError);
173
      cy.get("#kc-root-url").clear();
174

175
      cy.get("#kc-home-url").type("Invalid URL");
176
      settingsTab.clickSaveBtn();
177
      masthead.checkNotificationMessage(homeUrlError);
178
      cy.get("#kc-home-url").clear();
179

180
      cy.get("#kc-root-url").type(validUrl);
181
      cy.get("#kc-home-url").type(validUrl);
182
      settingsTab.clickSaveBtn();
183
      masthead.checkNotificationMessage("Client successfully updated");
184

185
      settingsTab.assertAccessSettings();
186
    });
187

188
    it("should check login settings", () => {
189
      cy.get(".pf-c-jump-links__list").contains("Login settings").click();
190

191
      settingsTab.assertLoginThemeDropdown();
192
      settingsTab.assertLoginSettings();
193
    });
194
  });
195
});
196

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

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

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

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