Keycloak

Форк
0
/
clients_test.spec.ts 
1238 строк · 40.8 Кб
1
import { v4 as uuid } from "uuid";
2
import LoginPage from "../support/pages/LoginPage";
3
import ListingPage, {
4
  Filter,
5
  FilterAssignedType,
6
} from "../support/pages/admin-ui/ListingPage";
7
import CreateClientPage from "../support/pages/admin-ui/manage/clients/CreateClientPage";
8
import adminClient from "../support/util/AdminClient";
9
import { keycloakBefore } from "../support/util/keycloak_hooks";
10
import RoleMappingTab from "../support/pages/admin-ui/manage/RoleMappingTab";
11
import createRealmRolePage from "../support/pages/admin-ui/manage/realm_roles/CreateRealmRolePage";
12
import AssociatedRolesPage from "../support/pages/admin-ui/manage/realm_roles/AssociatedRolesPage";
13
import ClientRolesTab from "../support/pages/admin-ui/manage/clients/ClientRolesTab";
14
import InitialAccessTokenTab from "../support/pages/admin-ui/manage/clients/tabs/InitialAccessTokenTab";
15
import AdvancedTab from "../support/pages/admin-ui/manage/clients/client_details/tabs/AdvancedTab";
16
import ClientDetailsPage, {
17
  ClientsDetailsTab,
18
} from "../support/pages/admin-ui/manage/clients/client_details/ClientDetailsPage";
19
import CommonPage from "../support/pages/CommonPage";
20
import AttributesTab from "../support/pages/admin-ui/manage/AttributesTab";
21
import DedicatedScopesMappersTab from "../support/pages/admin-ui/manage/clients/client_details/DedicatedScopesMappersTab";
22
import { ClientRegistrationPage } from "../support/pages/admin-ui/manage/clients/ClientRegistrationPage";
23

24
let itemId = "client_crud";
25
const loginPage = new LoginPage();
26
const associatedRolesPage = new AssociatedRolesPage();
27
const createClientPage = new CreateClientPage();
28
const clientDetailsPage = new ClientDetailsPage();
29
const commonPage = new CommonPage();
30
const listingPage = new ListingPage();
31
const attributesTab = new AttributesTab();
32
const dedicatedScopesMappersTab = new DedicatedScopesMappersTab();
33

34
describe("Clients test", () => {
35
  describe("Client details - Client scopes subtab", () => {
36
    const clientId = "client-scopes-subtab-test";
37
    const clientScopeName = "client-scope-test";
38
    const clientScopeNameDefaultType = "client-scope-test-default-type";
39
    const clientScopeNameOptionalType = "client-scope-test-optional-type";
40
    const clientScope = {
41
      name: clientScopeName,
42
      description: "",
43
      protocol: "openid-connect",
44
      attributes: {
45
        "include.in.token.scope": "true",
46
        "display.on.consent.screen": "true",
47
        "gui.order": "1",
48
        "consent.screen.text": "",
49
      },
50
    };
51
    const msgScopeMappingRemoved = "Scope mapping successfully removed";
52

53
    before(async () => {
54
      adminClient.createClient({
55
        clientId,
56
        protocol: "openid-connect",
57
        publicClient: false,
58
      });
59
      for (let i = 0; i < 5; i++) {
60
        clientScope.name = clientScopeName + i;
61
        await adminClient.createClientScope(clientScope);
62
        await adminClient.addDefaultClientScopeInClient(
63
          clientScopeName + i,
64
          clientId,
65
        );
66
      }
67
      clientScope.name = clientScopeNameDefaultType;
68
      await adminClient.createClientScope(clientScope);
69
      clientScope.name = clientScopeNameOptionalType;
70
      await adminClient.createClientScope(clientScope);
71
    });
72

73
    beforeEach(() => {
74
      loginPage.logIn();
75
      keycloakBefore();
76
      commonPage.sidebar().goToClients();
77
      commonPage.tableToolbarUtils().searchItem(clientId);
78
      cy.intercept("/admin/realms/master/clients/*").as("fetchClient");
79
      commonPage.tableUtils().clickRowItemLink(clientId);
80
      cy.wait("@fetchClient");
81
      clientDetailsPage.goToClientScopesTab();
82
    });
83

84
    after(async () => {
85
      adminClient.deleteClient(clientId);
86
      for (let i = 0; i < 5; i++) {
87
        await adminClient.deleteClientScope(clientScopeName + i);
88
      }
89
      await adminClient.deleteClientScope(clientScopeNameDefaultType);
90
      await adminClient.deleteClientScope(clientScopeNameOptionalType);
91
    });
92

93
    it("Should list client scopes", () => {
94
      commonPage
95
        .tableUtils()
96
        .checkRowItemsGreaterThan(1)
97
        .checkRowItemExists(clientScopeName + 0);
98
    });
99

100
    it("Should search existing client scope by name", () => {
101
      commonPage.tableToolbarUtils().searchItem(clientScopeName + 0, false);
102
      commonPage
103
        .tableUtils()
104
        .checkRowItemExists(clientScopeName + 0)
105
        .checkRowItemsEqualTo(2);
106
    });
107

108
    it("Should search non-existent client scope by name", () => {
109
      commonPage.tableToolbarUtils().searchItem("non-existent-item", false);
110
      commonPage.tableUtils().checkIfExists(false);
111
      commonPage.emptyState().checkIfExists(true);
112
    });
113

114
    it("Should search existing client scope by assigned type", () => {
115
      commonPage
116
        .tableToolbarUtils()
117
        .selectSearchType(Filter.AssignedType)
118
        .selectSecondarySearchType(FilterAssignedType.Default);
119
      commonPage
120
        .tableUtils()
121
        .checkRowItemExists(FilterAssignedType.Default)
122
        .checkRowItemExists(FilterAssignedType.Optional, false);
123
      commonPage
124
        .tableToolbarUtils()
125
        .selectSecondarySearchType(FilterAssignedType.Optional);
126
      commonPage
127
        .tableUtils()
128
        .checkRowItemExists(FilterAssignedType.Default, false)
129
        .checkRowItemExists(FilterAssignedType.Optional);
130
      commonPage
131
        .tableToolbarUtils()
132
        .selectSecondarySearchType(FilterAssignedType.AllTypes);
133
      commonPage
134
        .tableUtils()
135
        .checkRowItemExists(FilterAssignedType.Default)
136
        .checkRowItemExists(FilterAssignedType.Optional);
137
    });
138

139
    const newItemsWithExpectedAssignedTypes = [
140
      [clientScopeNameOptionalType, FilterAssignedType.Optional],
141
      [clientScopeNameDefaultType, FilterAssignedType.Default],
142
    ];
143
    newItemsWithExpectedAssignedTypes.forEach(($type) => {
144
      const [itemName, assignedType] = $type;
145
      it(`Should add client scope ${itemName} with ${assignedType} assigned type`, () => {
146
        commonPage.tableToolbarUtils().addClientScope();
147
        commonPage
148
          .modalUtils()
149
          .checkModalTitle("Add client scopes to " + clientId);
150
        commonPage.tableUtils().selectRowItemCheckbox(itemName);
151
        commonPage.modalUtils().confirmModalWithItem(assignedType);
152
        commonPage.masthead().checkNotificationMessage("Scope mapping updated");
153
        commonPage.tableToolbarUtils().searchItem(itemName, false);
154
        commonPage
155
          .tableUtils()
156
          .checkRowItemExists(itemName)
157
          .checkRowItemExists(assignedType);
158
      });
159
    });
160

161
    const expectedItemAssignedTypes = [
162
      FilterAssignedType.Optional,
163
      FilterAssignedType.Default,
164
    ];
165
    expectedItemAssignedTypes.forEach(($assignedType) => {
166
      const itemName = clientScopeName + 0;
167
      it(`Should change item ${itemName} AssignedType to ${$assignedType} from search bar`, () => {
168
        commonPage.tableToolbarUtils().searchItem(itemName, false);
169
        commonPage.tableUtils().selectRowItemCheckbox(itemName);
170
        commonPage.tableToolbarUtils().changeTypeTo($assignedType);
171
        commonPage.masthead().checkNotificationMessage("Scope mapping updated");
172
        commonPage.tableToolbarUtils().searchItem(itemName, false);
173
        commonPage.tableUtils().checkRowItemExists($assignedType);
174
      });
175
    });
176

177
    it("Should show items on next page are more than 11", () => {
178
      commonPage.sidebar().waitForPageLoad();
179
      commonPage.tableToolbarUtils().clickNextPageButton();
180
      commonPage.tableUtils().checkRowItemsGreaterThan(1);
181
    });
182

183
    it("Should remove client scope from item bar", () => {
184
      const itemName = clientScopeName + 0;
185
      commonPage.tableToolbarUtils().searchItem(itemName, false);
186
      commonPage.tableUtils().selectRowItemAction(itemName, "Remove");
187
      commonPage.modalUtils().confirmModal();
188
      commonPage.masthead().checkNotificationMessage(msgScopeMappingRemoved);
189
      commonPage.tableToolbarUtils().searchItem(itemName, false);
190
      commonPage.tableUtils().checkRowItemExists(itemName, false);
191
    });
192

193
    it("Should remove multiple client scopes from search bar", () => {
194
      const itemName1 = clientScopeName + 1;
195
      const itemName2 = clientScopeName + 2;
196
      cy.intercept("/admin/realms/master/client-scopes").as("load");
197
      commonPage.tableToolbarUtils().clickSearchButton();
198
      cy.wait("@load");
199
      cy.wait(1000);
200
      commonPage.tableToolbarUtils().checkActionItemIsEnabled("Remove", false);
201
      commonPage.tableToolbarUtils().searchItem(clientScopeName, false);
202
      commonPage
203
        .tableUtils()
204
        .selectRowItemCheckbox(itemName1)
205
        .selectRowItemCheckbox(itemName2);
206
      cy.intercept("/admin/realms/master/client-scopes").as("load");
207
      commonPage.tableToolbarUtils().clickSearchButton();
208
      cy.wait("@load");
209
      cy.wait(1000);
210
      commonPage.tableToolbarUtils().clickActionItem("Remove");
211
      commonPage.masthead().checkNotificationMessage(msgScopeMappingRemoved);
212
      commonPage.tableToolbarUtils().searchItem(clientScopeName, false);
213
      commonPage
214
        .tableUtils()
215
        .checkRowItemExists(itemName1, false)
216
        .checkRowItemExists(itemName2, false);
217
      commonPage.tableToolbarUtils().clickSearchButton();
218
    });
219

220
    //fails, issue https://github.com/keycloak/keycloak-admin-ui/issues/1874
221
    it("Should show initial items after filtering", () => {
222
      commonPage
223
        .tableToolbarUtils()
224
        .selectSearchType(Filter.AssignedType)
225
        .selectSecondarySearchType(FilterAssignedType.Optional)
226
        .selectSearchType(Filter.Name);
227
      commonPage
228
        .tableUtils()
229
        .checkRowItemExists(FilterAssignedType.Default, false)
230
        .checkRowItemExists(FilterAssignedType.Optional);
231
    });
232
  });
233

234
  describe("Client scopes evaluate subtab", () => {
235
    const clientName = "testClient";
236

237
    beforeEach(() => {
238
      loginPage.logIn();
239
      keycloakBefore();
240
      commonPage.sidebar().goToClients();
241
    });
242

243
    before(async () => {
244
      await adminClient.createClient({
245
        protocol: "openid-connect",
246
        clientId: clientName,
247
        publicClient: false,
248
      });
249
    });
250

251
    after(async () => {
252
      await adminClient.deleteClient(clientName);
253
    });
254

255
    it("check effective protocol mappers list is not empty and find effective protocol mapper locale", () => {
256
      commonPage.tableToolbarUtils().searchItem(clientName);
257
      commonPage.tableUtils().clickRowItemLink(clientName);
258

259
      clientDetailsPage.goToClientScopesEvaluateTab();
260

261
      cy.findByTestId("effective-protocol-mappers")
262
        .find("tr")
263
        .should("have.length.gt", 0);
264
    });
265

266
    it("check role scope mappings list list is not empty and find role scope mapping admin", () => {
267
      commonPage.tableToolbarUtils().searchItem(clientName);
268
      commonPage.tableUtils().clickRowItemLink(clientName);
269

270
      clientDetailsPage.goToClientScopesEvaluateTab();
271
      clientDetailsPage.goToClientScopesEvaluateEffectiveRoleScopeMappingsTab();
272

273
      cy.findByTestId("effective-role-scope-mappings")
274
        .find("tr")
275
        .should("have.length.gt", 0);
276
    });
277

278
    it("check generated id token and user info", () => {
279
      commonPage.tableToolbarUtils().searchItem(clientName);
280
      commonPage.tableUtils().clickRowItemLink(clientName);
281

282
      clientDetailsPage.goToClientScopesEvaluateTab();
283
      cy.get("div#generatedAccessToken").contains("No generated access token");
284

285
      clientDetailsPage.goToClientScopesEvaluateGeneratedIdTokenTab();
286
      cy.get("div#generatedIdToken").contains("No generated id token");
287

288
      clientDetailsPage.goToClientScopesEvaluateGeneratedUserInfoTab();
289
      cy.get("div#generatedUserInfo").contains("No generated user info");
290

291
      cy.get("input#user-select-typeahead").type("admin");
292
      cy.get("li[id*=select-option-] > button:first-child").click();
293

294
      clientDetailsPage.goToClientScopesEvaluateGeneratedAccessTokenTab();
295
      cy.get("div#generatedAccessToken").contains(
296
        '"preferred_username": "admin"',
297
      );
298
      cy.get("div#generatedAccessToken").contains('"scope": "');
299

300
      clientDetailsPage.goToClientScopesEvaluateGeneratedIdTokenTab();
301
      cy.get("div#generatedIdToken").contains('"preferred_username": "admin"');
302

303
      clientDetailsPage.goToClientScopesEvaluateGeneratedUserInfoTab();
304
      cy.get("div#generatedIdToken").contains('"preferred_username": "admin"');
305
      cy.get("div#generatedIdToken").contains('"session_state"');
306
    });
307
  });
308

309
  describe("Client creation", () => {
310
    beforeEach(() => {
311
      loginPage.logIn();
312
      keycloakBefore();
313
      commonPage.sidebar().goToClients();
314
    });
315

316
    it("Should cancel creating client", () => {
317
      commonPage.tableToolbarUtils().createClient();
318

319
      createClientPage.continue().checkClientIdRequiredMessage();
320

321
      createClientPage
322
        .fillClientData("")
323
        .selectClientType("openid-connect")
324
        .cancel();
325

326
      cy.url().should("not.include", "/add-client");
327
    });
328

329
    it("Should check settings elements", () => {
330
      commonPage.tableToolbarUtils().clickPrimaryButton();
331
      const clientId = "Test settings";
332

333
      createClientPage
334
        .fillClientData(clientId)
335
        .continue()
336
        .checkCapabilityConfigElements()
337
        .continue()
338
        .save();
339

340
      commonPage
341
        .masthead()
342
        .checkNotificationMessage("Client created successfully");
343
      commonPage.sidebar().waitForPageLoad();
344

345
      createClientPage
346
        .checkCapabilityConfigElements()
347
        .checkAccessSettingsElements()
348
        .checkLoginSettingsElements()
349
        .checkLogoutSettingsElements()
350
        .deleteClientFromActionDropdown();
351

352
      commonPage.modalUtils().confirmModal();
353
      commonPage.tableUtils().checkRowItemExists(clientId, false);
354
    });
355

356
    it("Should navigate to previous using 'back' button", () => {
357
      commonPage.tableToolbarUtils().createClient();
358

359
      createClientPage.continue().checkClientIdRequiredMessage();
360

361
      createClientPage
362
        .fillClientData("test_client")
363
        .selectClientType("openid-connect")
364
        .continue()
365
        .back()
366
        .checkGeneralSettingsStepActive();
367
    });
368

369
    it("Should fail creating client", () => {
370
      commonPage.tableToolbarUtils().createClient();
371

372
      createClientPage.continue().checkClientIdRequiredMessage();
373

374
      createClientPage
375
        .fillClientData("")
376
        .selectClientType("openid-connect")
377
        .continue()
378
        .checkClientIdRequiredMessage();
379

380
      createClientPage.fillClientData("account").continue().continue().save();
381

382
      // The error should inform about duplicated name/id
383
      commonPage
384
        .masthead()
385
        .checkNotificationMessage(
386
          "Could not create client: 'Client account already exists'",
387
        );
388
    });
389

390
    it("Client CRUD test", () => {
391
      itemId += "_" + uuid();
392

393
      // Create
394
      commonPage.tableUtils().checkRowItemExists(itemId, false);
395
      commonPage.tableToolbarUtils().clickPrimaryButton();
396
      createClientPage.cancel();
397
      commonPage.tableUtils().checkRowItemExists(itemId, false);
398
      commonPage.tableToolbarUtils().clickPrimaryButton();
399

400
      createClientPage
401
        .selectClientType("openid-connect")
402
        .fillClientData(itemId)
403
        .continue()
404
        .switchClientAuthentication()
405
        .clickDirectAccess()
406
        .clickImplicitFlow()
407
        .clickOAuthDeviceAuthorizationGrant()
408
        .clickOidcCibaGrant()
409
        .clickServiceAccountRoles()
410
        .clickStandardFlow()
411
        .continue()
412
        .save();
413

414
      commonPage
415
        .masthead()
416
        .checkNotificationMessage("Client created successfully");
417

418
      commonPage.sidebar().goToClients();
419

420
      commonPage.tableToolbarUtils().searchItem("John Doe", false);
421
      commonPage.emptyState().checkIfExists(true);
422
      commonPage.tableToolbarUtils().searchItem("");
423
      commonPage.tableUtils().checkRowItemExists("account");
424
      commonPage.tableToolbarUtils().searchItem(itemId);
425
      commonPage.tableUtils().checkRowItemExists(itemId);
426

427
      // Delete
428
      commonPage.tableUtils().selectRowItemAction(itemId, "Delete");
429
      commonPage.sidebar().waitForPageLoad();
430
      commonPage
431
        .modalUtils()
432
        .checkModalTitle(`Delete ${itemId} ?`)
433
        .confirmModal();
434
      commonPage
435
        .masthead()
436
        .checkNotificationMessage("The client has been deleted");
437
      commonPage.tableUtils().checkRowItemExists(itemId, false);
438
    });
439

440
    it("Initial access token can't be created with 0 days and count", () => {
441
      const initialAccessTokenTab = new InitialAccessTokenTab();
442
      initialAccessTokenTab
443
        .goToInitialAccessTokenTab()
444
        .shouldBeEmpty()
445
        .goToCreateFromEmptyList()
446
        .fillNewTokenData(0, 0)
447
        .checkExpirationGreaterThanZeroError()
448
        .checkCountValue(1)
449
        .checkSaveButtonIsDisabled();
450
    });
451

452
    it("Initial access token", () => {
453
      const initialAccessTokenTab = new InitialAccessTokenTab();
454
      initialAccessTokenTab
455
        .goToInitialAccessTokenTab()
456
        .shouldBeEmpty()
457
        .goToCreateFromEmptyList()
458
        .fillNewTokenData(1, 3)
459
        .save();
460

461
      commonPage
462
        .modalUtils()
463
        .checkModalTitle("Initial access token details")
464
        .closeModal();
465

466
      commonPage
467
        .masthead()
468
        .checkNotificationMessage("New initial access token has been created");
469

470
      initialAccessTokenTab.shouldNotBeEmpty();
471

472
      commonPage.tableToolbarUtils().searchItem("John Doe", false);
473
      commonPage.emptyState().checkIfExists(true);
474
      commonPage.tableToolbarUtils().searchItem("", false);
475

476
      initialAccessTokenTab.getFirstId((id) => {
477
        commonPage
478
          .tableUtils()
479
          .checkRowItemValueByItemName(id, 4, "4")
480
          .checkRowItemValueByItemName(id, 5, "4")
481
          .checkRowItemExists(id);
482
      });
483

484
      commonPage.tableToolbarUtils().clickPrimaryButton("Create");
485
      initialAccessTokenTab.fillNewTokenData(1, 3).save();
486

487
      commonPage.modalUtils().closeModal();
488

489
      initialAccessTokenTab.getFirstId((id) => {
490
        commonPage.tableUtils().selectRowItemAction(id, "Delete");
491
        commonPage.sidebar().waitForPageLoad();
492
        commonPage
493
          .modalUtils()
494
          .checkModalTitle("Delete initial access token?")
495
          .confirmModal();
496
      });
497

498
      commonPage
499
        .masthead()
500
        .checkNotificationMessage("Initial access token deleted successfully");
501
      initialAccessTokenTab.shouldNotBeEmpty();
502

503
      initialAccessTokenTab.getFirstId((id) => {
504
        commonPage.tableUtils().selectRowItemAction(id, "Delete");
505
        commonPage.sidebar().waitForPageLoad();
506
        commonPage.modalUtils().confirmModal();
507
      });
508
      initialAccessTokenTab.shouldBeEmpty();
509
    });
510

511
    it("Should fail to create imported client with empty ID", () => {
512
      commonPage.sidebar().goToClients();
513
      cy.findByTestId("importClient").click();
514
      cy.findByTestId("clientId").click();
515
      cy.findByText("Save").click();
516
      cy.findByText("Required field");
517
    });
518

519
    const identicalClientId = "identical";
520

521
    it("Should fail to create client with same ID", () => {
522
      commonPage.sidebar().goToClients();
523
      commonPage.tableToolbarUtils().createClient();
524

525
      createClientPage
526
        .fillClientData(identicalClientId)
527
        .continue()
528
        .continue()
529
        .save();
530

531
      commonPage.masthead().closeAllAlertMessages();
532
      commonPage.sidebar().goToClients();
533
      cy.findByTestId("importClient").click();
534
      cy.findByTestId("realm-file").selectFile(
535
        "cypress/fixtures/partial-import-test-data/import-identical-client.json",
536
        { action: "drag-drop" },
537
      );
538

539
      cy.wait(1000);
540
      //cy.findByTestId("realm-file").contains('"clientId": "identical"')
541
      cy.findByTestId("clientId").click();
542
      cy.findByText("Save").click();
543
      commonPage
544
        .masthead()
545
        .checkNotificationMessage(
546
          "Could not import client: Client identical already exists",
547
          true,
548
        );
549
    });
550

551
    it("should delete 'identical' client id", () => {
552
      commonPage.sidebar().goToClients();
553
      adminClient.deleteClient(identicalClientId);
554
    });
555
  });
556

557
  describe("Roles tab test", () => {
558
    const rolesTab = new ClientRolesTab();
559
    const client = "client_" + uuid();
560

561
    before(() =>
562
      adminClient.createClient({
563
        clientId: client,
564
        protocol: "openid-connect",
565
        publicClient: false,
566
      }),
567
    );
568

569
    beforeEach(() => {
570
      loginPage.logIn();
571
      keycloakBefore();
572
      commonPage.sidebar().goToClients();
573
      commonPage.tableToolbarUtils().searchItem(client);
574
      commonPage.tableUtils().clickRowItemLink(client);
575
      rolesTab.goToRolesTab();
576
    });
577

578
    after(() => {
579
      adminClient.deleteClient(client);
580
    });
581

582
    it("Should fail to create client role with empty name", () => {
583
      rolesTab.goToCreateRoleFromEmptyState();
584
      createRealmRolePage.fillRealmRoleData("").save();
585
      createRealmRolePage.checkRealmRoleNameRequiredMessage();
586
    });
587

588
    it("Should create client role", () => {
589
      rolesTab.goToCreateRoleFromEmptyState();
590
      createRealmRolePage.fillRealmRoleData(itemId).save();
591
      commonPage.masthead().checkNotificationMessage("Role created", true);
592
    });
593

594
    it("Should update client role description", () => {
595
      const updateDescription = "updated description";
596
      commonPage.tableToolbarUtils().searchItem(itemId, false);
597
      commonPage.tableUtils().clickRowItemLink(itemId);
598
      createRealmRolePage.updateDescription(updateDescription).save();
599
      commonPage
600
        .masthead()
601
        .checkNotificationMessage("The role has been saved", true);
602
      createRealmRolePage.checkDescription(updateDescription);
603
    });
604

605
    it("Should add attribute to client role", () => {
606
      commonPage.tableUtils().clickRowItemLink(itemId);
607
      rolesTab.goToAttributesTab();
608
      attributesTab
609
        .addAttribute("crud_attribute_key", "crud_attribute_value")
610
        .save();
611
      attributesTab.assertRowItemsEqualTo(1);
612
      commonPage
613
        .masthead()
614
        .checkNotificationMessage("The role has been saved", true);
615
    });
616

617
    it("Should delete attribute from client role", () => {
618
      commonPage.tableUtils().clickRowItemLink(itemId);
619
      rolesTab.goToAttributesTab();
620
      attributesTab.deleteAttribute(0);
621
      attributesTab.assertEmpty();
622
      commonPage
623
        .masthead()
624
        .checkNotificationMessage("The role has been saved", true);
625
    });
626

627
    it("Should create client role to be deleted", () => {
628
      rolesTab.goToCreateRoleFromToolbar();
629
      createRealmRolePage.fillRealmRoleData("client_role_to_be_deleted").save();
630
      commonPage.masthead().checkNotificationMessage("Role created", true);
631
    });
632

633
    it("Should fail to create duplicate client role", () => {
634
      rolesTab.goToCreateRoleFromToolbar();
635
      createRealmRolePage.fillRealmRoleData(itemId).save();
636
      commonPage
637
        .masthead()
638
        .checkNotificationMessage(
639
          `Could not create role: Role with name ${itemId} already exists`,
640
          true,
641
        );
642
    });
643

644
    it("Should search existing client role", () => {
645
      commonPage.tableToolbarUtils().searchItem(itemId, false);
646
      commonPage.tableUtils().checkRowItemExists(itemId);
647
    });
648

649
    it("Should search non-existing role test", () => {
650
      commonPage.tableToolbarUtils().searchItem("role_DNE", false);
651
      commonPage.emptyState().checkIfExists(true);
652
    });
653

654
    it("roles empty search test", () => {
655
      commonPage.tableToolbarUtils().searchItem("", false);
656
      commonPage.tableUtils().checkIfExists(true);
657
    });
658

659
    it("Add associated roles test", () => {
660
      commonPage.tableToolbarUtils().searchItem(itemId, false);
661
      commonPage.tableUtils().clickRowItemLink(itemId);
662

663
      // Add associated realm role
664
      associatedRolesPage.addAssociatedRealmRole("create-realm");
665
      commonPage
666
        .masthead()
667
        .checkNotificationMessage("Associated roles have been added", true);
668

669
      // Add associated client role
670
      associatedRolesPage.addAssociatedRoleFromSearchBar(
671
        "manage-account",
672
        true,
673
      );
674
      commonPage
675
        .masthead()
676
        .checkNotificationMessage("Associated roles have been added", true);
677

678
      rolesTab.goToAssociatedRolesTab();
679

680
      // Add associated client role
681
      associatedRolesPage.addAssociatedRoleFromSearchBar(
682
        "manage-consent",
683
        true,
684
      );
685
      commonPage
686
        .masthead()
687
        .checkNotificationMessage("Associated roles have been added", true);
688
    });
689

690
    it("Should hide inherited roles test", () => {
691
      commonPage.tableToolbarUtils().searchItem(itemId, false);
692
      commonPage.tableUtils().clickRowItemLink(itemId);
693
      rolesTab.goToAssociatedRolesTab().hideInheritedRoles();
694
    });
695

696
    it("Should delete associated roles test", () => {
697
      commonPage.tableToolbarUtils().searchItem(itemId, false);
698
      commonPage.tableUtils().clickRowItemLink(itemId);
699
      rolesTab.goToAssociatedRolesTab();
700
      commonPage.tableUtils().selectRowItemAction("create-realm", "Unassign");
701
      commonPage.sidebar().waitForPageLoad();
702
      commonPage.modalUtils().checkModalTitle("Remove role?").confirmModal();
703
      commonPage.sidebar().waitForPageLoad();
704

705
      commonPage
706
        .masthead()
707
        .checkNotificationMessage("Scope mapping successfully removed", true);
708

709
      commonPage.tableUtils().selectRowItemAction("manage-consent", "Unassign");
710
      commonPage.sidebar().waitForPageLoad();
711
      commonPage.modalUtils().checkModalTitle("Remove role?").confirmModal();
712
    });
713

714
    it("Should delete associated role from search bar test", () => {
715
      commonPage.tableToolbarUtils().searchItem(itemId, false);
716
      commonPage.tableUtils().clickRowItemLink(itemId);
717
      commonPage.sidebar().waitForPageLoad();
718
      rolesTab.goToAssociatedRolesTab();
719

720
      cy.get('td[data-label="Name"]')
721
        .contains("manage-account")
722
        .parent()
723
        .within(() => {
724
          cy.get("input").click();
725
        });
726

727
      associatedRolesPage.removeAssociatedRoles();
728

729
      commonPage.sidebar().waitForPageLoad();
730
      commonPage.modalUtils().checkModalTitle("Remove role?").confirmModal();
731
      commonPage.sidebar().waitForPageLoad();
732

733
      commonPage
734
        .masthead()
735
        .checkNotificationMessage("Scope mapping successfully removed", true);
736
    });
737

738
    it("Should delete client role test", () => {
739
      commonPage.tableUtils().selectRowItemAction(itemId, "Delete");
740
      commonPage.sidebar().waitForPageLoad();
741
      commonPage.modalUtils().checkModalTitle("Delete role?").confirmModal();
742
    });
743

744
    it("Should delete client role from role details test", () => {
745
      commonPage
746
        .tableToolbarUtils()
747
        .searchItem("client_role_to_be_deleted", false);
748
      commonPage.tableUtils().clickRowItemLink("client_role_to_be_deleted");
749
      createRealmRolePage.clickActionMenu("Delete this role");
750
      commonPage.modalUtils().confirmModal();
751
      commonPage
752
        .masthead()
753
        .checkNotificationMessage("The role has been deleted", true);
754
    });
755
  });
756

757
  describe("Advanced tab test", () => {
758
    const advancedTab = new AdvancedTab();
759
    let client: string;
760

761
    beforeEach(() => {
762
      loginPage.logIn();
763
      keycloakBefore();
764
      commonPage.sidebar().goToClients();
765
      client = "client_" + uuid();
766
      commonPage.tableToolbarUtils().createClient();
767
      createClientPage
768
        .selectClientType("openid-connect")
769
        .fillClientData(client)
770
        .continue();
771

772
      commonPage.sidebar().waitForPageLoad();
773

774
      createClientPage.continue().save();
775
      commonPage
776
        .masthead()
777
        .checkNotificationMessage("Client created successfully");
778
      clientDetailsPage.goToAdvancedTab();
779
    });
780

781
    afterEach(() => {
782
      adminClient.deleteClient(client);
783
    });
784

785
    it("Clustering", () => {
786
      advancedTab.expandClusterNode();
787

788
      advancedTab.checkEmptyClusterNode();
789

790
      advancedTab.registerNodeManually().fillHost("localhost").saveHost();
791
      advancedTab.checkTestClusterAvailability(true);
792
      commonPage.masthead().checkNotificationMessage("Node successfully added");
793
      advancedTab.deleteClusterNode();
794
      commonPage.modalUtils().confirmModal();
795
      commonPage
796
        .masthead()
797
        .checkNotificationMessage("Node successfully removed");
798
      advancedTab.checkEmptyClusterNode();
799
    });
800

801
    it("Fine grain OpenID connect configuration", () => {
802
      const algorithm = "ES384";
803
      advancedTab
804
        .selectAccessTokenSignatureAlgorithm(algorithm)
805
        .saveFineGrain();
806

807
      advancedTab
808
        .selectAccessTokenSignatureAlgorithm("HS384")
809
        .revertFineGrain();
810
      advancedTab.checkAccessTokenSignatureAlgorithm(algorithm);
811
    });
812

813
    it("OIDC Compatibility Modes configuration", () => {
814
      advancedTab.clickAllCompatibilitySwitch();
815
      advancedTab.saveCompatibility();
816
      advancedTab.jumpToCompatability();
817
      advancedTab.clickExcludeSessionStateSwitch();
818
      advancedTab.clickUseRefreshTokenForClientCredentialsGrantSwitch();
819
      advancedTab.revertCompatibility();
820
    });
821

822
    it("Advanced settings", () => {
823
      advancedTab.jumpToAdvanced();
824

825
      advancedTab.clickAdvancedSwitches();
826
      advancedTab.jumpToAdvanced();
827
      advancedTab.selectKeyForCodeExchangeInput("S256");
828

829
      advancedTab.saveAdvanced();
830
      advancedTab.jumpToAdvanced();
831
      advancedTab.checkAdvancedSwitchesOn();
832
      advancedTab.checkKeyForCodeExchangeInput("S256");
833

834
      advancedTab.selectKeyForCodeExchangeInput("plain");
835
      advancedTab.checkKeyForCodeExchangeInput("plain");
836

837
      advancedTab.jumpToAdvanced();
838
      advancedTab.clickAdvancedSwitches();
839

840
      advancedTab.revertAdvanced();
841
      advancedTab.jumpToAdvanced();
842
      advancedTab.checkKeyForCodeExchangeInput("S256");
843
      //uncomment when revert button reverts all switches
844
      //and ACR to LoA Mapping + Default ACR Values
845
      //advancedTab.checkAdvancedSwitchesOn();
846
    });
847

848
    it("Authentication flow override", () => {
849
      advancedTab.jumpToAuthFlow();
850
      advancedTab.selectBrowserFlowInput("browser");
851
      advancedTab.selectDirectGrantInput("docker auth");
852
      advancedTab.checkBrowserFlowInput("browser");
853
      advancedTab.checkDirectGrantInput("docker auth");
854

855
      advancedTab.revertAuthFlowOverride();
856
      advancedTab.jumpToAuthFlow();
857
      advancedTab.checkBrowserFlowInput("");
858
      advancedTab.checkDirectGrantInput("");
859
      advancedTab.selectBrowserFlowInput("browser");
860
      advancedTab.selectDirectGrantInput("docker auth");
861

862
      advancedTab.saveAuthFlowOverride();
863
      advancedTab.selectBrowserFlowInput("first broker login");
864
      advancedTab.selectDirectGrantInput("first broker login");
865
      advancedTab.revertAuthFlowOverride();
866
      //revert doesn't work after saving.
867
      //advancedTab.CheckBrowserFlowInput("browser");
868
      //advancedTab.CheckDirectGrantInput("docker auth");
869
    });
870
  });
871

872
  describe("Service account tab test", () => {
873
    const serviceAccountTab = new RoleMappingTab("user");
874
    const serviceAccountName = "service-account-client";
875

876
    before(() =>
877
      adminClient.createClient({
878
        protocol: "openid-connect",
879
        clientId: serviceAccountName,
880
        publicClient: false,
881
        authorizationServicesEnabled: true,
882
        serviceAccountsEnabled: true,
883
        standardFlowEnabled: true,
884
      }),
885
    );
886

887
    beforeEach(() => {
888
      loginPage.logIn();
889
      keycloakBefore();
890
      commonPage.sidebar().goToClients();
891
    });
892

893
    after(() => {
894
      adminClient.deleteClient(serviceAccountName);
895
    });
896

897
    it("List", () => {
898
      commonPage.tableToolbarUtils().searchItem(serviceAccountName);
899
      commonPage.tableUtils().clickRowItemLink(serviceAccountName);
900
      serviceAccountTab
901
        .goToServiceAccountTab()
902
        .checkRoles(["offline_access", "uma_authorization"], false)
903
        .checkRoles(["default-roles-master", "uma_protection"])
904
        .unhideInheritedRoles();
905

906
      commonPage.sidebar().waitForPageLoad();
907

908
      serviceAccountTab
909
        .checkRoles([
910
          "default-roles-master",
911
          "offline_access",
912
          "uma_authorization",
913
          "uma_protection",
914
        ])
915
        .hideInheritedRoles();
916

917
      commonPage.sidebar().waitForPageLoad();
918

919
      serviceAccountTab
920
        .checkRoles(["offline_access", "uma_authorization"], false)
921
        .checkRoles(["default-roles-master", "uma_protection"]);
922

923
      listingPage
924
        .searchItem("testing", false)
925
        .checkEmptyList()
926
        .searchItem("", false);
927

928
      serviceAccountTab
929
        .checkRoles(["offline_access", "uma_authorization"], false)
930
        .checkRoles(["default-roles-master", "uma_protection"]);
931
    });
932

933
    it("Assign", () => {
934
      commonPage.tableUtils().clickRowItemLink(serviceAccountName);
935
      serviceAccountTab
936
        .goToServiceAccountTab()
937
        .assignRole(false)
938
        .selectRow("create-realm", true)
939
        .assign();
940
      commonPage.masthead().checkNotificationMessage("Role mapping updated");
941

942
      serviceAccountTab.selectRow("create-realm").unAssign();
943

944
      commonPage.sidebar().waitForPageLoad();
945
      commonPage.modalUtils().checkModalTitle("Remove role?").confirmModal();
946
      commonPage
947
        .masthead()
948
        .checkNotificationMessage("Scope mapping successfully removed");
949

950
      //cy.intercept("/admin/realms/master/users").as("assignRoles");
951
      serviceAccountTab.checkRoles(["create-realm"], false).assignRole(false);
952

953
      //cy.wait("@assignRoles");
954
      commonPage.sidebar().waitForPageLoad();
955

956
      serviceAccountTab
957
        .selectRow("offline_access", true)
958
        .selectRow("admin", true)
959
        .selectRow("create-realm", true)
960
        .assign();
961

962
      commonPage.masthead().checkNotificationMessage("Role mapping updated");
963
      commonPage.sidebar().waitForPageLoad();
964

965
      serviceAccountTab.unhideInheritedRoles();
966

967
      commonPage.sidebar().waitForPageLoad();
968

969
      serviceAccountTab.hideInheritedRoles();
970

971
      serviceAccountTab
972
        .selectRow("offline_access")
973
        .selectRow("admin")
974
        .unAssign();
975

976
      commonPage.modalUtils().confirmModal();
977

978
      serviceAccountTab
979
        .checkRoles(["admin"], false)
980
        .checkRoles(["create-realm"]);
981

982
      listingPage.clickRowDetails("create-realm");
983
      serviceAccountTab.unAssignFromDropdown();
984

985
      commonPage.modalUtils().confirmModal();
986

987
      commonPage.sidebar().waitForPageLoad();
988

989
      serviceAccountTab.unhideInheritedRoles();
990

991
      serviceAccountTab
992
        .checkRoles(["create-realm"], false)
993
        .checkRoles([
994
          "default-roles-master",
995
          "offline_access",
996
          "uma_authorization",
997
          "uma_protection",
998
        ]);
999
    });
1000
  });
1001

1002
  describe("Mapping tab", () => {
1003
    const mappingClient = "mapping-client";
1004

1005
    beforeEach(() => {
1006
      loginPage.logIn();
1007
      keycloakBefore();
1008
      commonPage.sidebar().goToClients();
1009
      commonPage.tableToolbarUtils().searchItem(mappingClient);
1010
      commonPage.tableUtils().clickRowItemLink(mappingClient);
1011
    });
1012

1013
    before(() => {
1014
      adminClient.createClient({
1015
        protocol: "openid-connect",
1016
        clientId: mappingClient,
1017
        publicClient: false,
1018
      });
1019
    });
1020

1021
    after(() => {
1022
      adminClient.deleteClient(mappingClient);
1023
    });
1024

1025
    it("Add mapping to openid client", () => {
1026
      clientDetailsPage
1027
        .goToClientScopesTab()
1028
        .clickDedicatedScope(mappingClient);
1029
      dedicatedScopesMappersTab.addPredefinedMapper();
1030
      clientDetailsPage.modalUtils().table().clickHeaderItem(1, "input");
1031
      clientDetailsPage.modalUtils().confirmModal();
1032
      clientDetailsPage
1033
        .masthead()
1034
        .checkNotificationMessage("Mapping successfully created");
1035
    });
1036
  });
1037

1038
  describe("Keys tab test", () => {
1039
    const keysName = "keys-client";
1040

1041
    before(() =>
1042
      adminClient.createClient({
1043
        protocol: "openid-connect",
1044
        clientId: keysName,
1045
        publicClient: false,
1046
      }),
1047
    );
1048

1049
    beforeEach(() => {
1050
      loginPage.logIn();
1051
      keycloakBefore();
1052
      commonPage.sidebar().goToClients();
1053
      commonPage.tableToolbarUtils().searchItem(keysName);
1054
      commonPage.tableUtils().clickRowItemLink(keysName);
1055
    });
1056

1057
    after(() => {
1058
      adminClient.deleteClient(keysName);
1059
    });
1060

1061
    it("Generate new keys", () => {
1062
      const keysTab = clientDetailsPage.goToKeysTab();
1063
      keysTab.clickGenerate();
1064
      keysTab.fillGenerateModal("JKS", "keyname", "123", "1234").clickConfirm();
1065

1066
      commonPage
1067
        .masthead()
1068
        .checkNotificationMessage(
1069
          "New key pair and certificate generated successfully",
1070
        );
1071
    });
1072
  });
1073

1074
  describe("Realm client", () => {
1075
    const clientName = "master-realm";
1076

1077
    beforeEach(() => {
1078
      loginPage.logIn();
1079
      keycloakBefore();
1080
      commonPage.sidebar().goToClients();
1081
      commonPage.tableToolbarUtils().searchItem(clientName);
1082
      commonPage.tableUtils().clickRowItemLink(clientName);
1083
    });
1084

1085
    it("Displays the correct tabs", () => {
1086
      clientDetailsPage.goToSettingsTab();
1087
      clientDetailsPage
1088
        .tabUtils()
1089
        .checkTabExists(ClientsDetailsTab.Settings, true)
1090
        .checkTabExists(ClientsDetailsTab.Roles, true)
1091
        .checkTabExists(ClientsDetailsTab.Sessions, true)
1092
        .checkTabExists(ClientsDetailsTab.Permissions, true)
1093
        .checkTabExists(ClientsDetailsTab.Advanced, true)
1094
        .checkNumberOfTabsIsEqual(5);
1095
    });
1096

1097
    it("Hides the delete action", () => {
1098
      commonPage
1099
        .actionToolbarUtils()
1100
        .clickActionToggleButton()
1101
        .checkActionItemExists("Delete", false);
1102
    });
1103
  });
1104

1105
  describe("Bearer only", () => {
1106
    const clientId = "bearer-only";
1107

1108
    before(() =>
1109
      adminClient.createClient({
1110
        clientId,
1111
        protocol: "openid-connect",
1112
        publicClient: false,
1113
        bearerOnly: true,
1114
      }),
1115
    );
1116

1117
    beforeEach(() => {
1118
      loginPage.logIn();
1119
      keycloakBefore();
1120

1121
      commonPage.sidebar().goToClients();
1122
      cy.intercept("/admin/realms/master/clients/*").as("fetchClient");
1123
      commonPage.tableToolbarUtils().searchItem(clientId);
1124
      commonPage.tableUtils().clickRowItemLink(clientId);
1125
      cy.wait("@fetchClient");
1126
    });
1127

1128
    after(() => {
1129
      adminClient.deleteClient(clientId);
1130
    });
1131

1132
    it("Shows an explainer text for bearer only clients", () => {
1133
      commonPage
1134
        .actionToolbarUtils()
1135
        .bearerOnlyExplainerLabelElement.trigger("mouseenter");
1136
      commonPage
1137
        .actionToolbarUtils()
1138
        .bearerOnlyExplainerTooltipElement.should("exist");
1139
    });
1140

1141
    it("Hides the capability config section", () => {
1142
      cy.findByTestId("capability-config-form").should("not.exist");
1143
      cy.findByTestId("jump-link-capability-config").should("not.exist");
1144
    });
1145
  });
1146

1147
  describe("Accessibility tests for clients", () => {
1148
    const clientId = "a11y-client";
1149

1150
    beforeEach(() => {
1151
      loginPage.logIn();
1152
      keycloakBefore();
1153
      commonPage.sidebar().goToClients();
1154
      cy.injectAxe();
1155
    });
1156

1157
    it("Check a11y violations on load/ clients list tab", () => {
1158
      cy.checkA11y();
1159
    });
1160

1161
    it("Check a11y violations on create client page", () => {
1162
      commonPage.sidebar().goToClients();
1163
      commonPage.tableToolbarUtils().createClient();
1164
      createClientPage.fillClientData(clientId);
1165
      cy.checkA11y();
1166

1167
      cy.findByTestId("next").click();
1168
      cy.checkA11y();
1169

1170
      cy.findByTestId("next").click();
1171
      cy.checkA11y();
1172
    });
1173

1174
    it("Check a11y violations on client details page", () => {
1175
      const rolesTab = new ClientRolesTab();
1176

1177
      commonPage.sidebar().goToClients();
1178
      commonPage.tableToolbarUtils().createClient();
1179
      createClientPage.fillClientData(clientId).continue().continue().save();
1180
      cy.checkA11y();
1181

1182
      rolesTab.goToRolesTab();
1183
      cy.checkA11y();
1184

1185
      clientDetailsPage.goToClientScopesTab();
1186
      cy.checkA11y();
1187

1188
      clientDetailsPage.goToClientScopesEvaluateTab();
1189
      cy.checkA11y();
1190

1191
      clientDetailsPage.goToClientScopesEvaluateEffectiveRoleScopeMappingsTab();
1192
      cy.checkA11y();
1193

1194
      clientDetailsPage.goToClientScopesEvaluateGeneratedAccessTokenTab();
1195
      cy.checkA11y();
1196

1197
      clientDetailsPage.goToClientScopesEvaluateGeneratedIdTokenTab();
1198
      cy.checkA11y();
1199

1200
      clientDetailsPage.goToClientScopesEvaluateGeneratedUserInfoTab();
1201
      cy.checkA11y();
1202

1203
      clientDetailsPage.goToAdvancedTab();
1204
      cy.checkA11y();
1205
    });
1206

1207
    it("Check a11y violations in delete dialog", () => {
1208
      commonPage.tableToolbarUtils().searchItem(clientId, false);
1209
      commonPage.tableUtils().selectRowItemAction(clientId, "Delete");
1210
      cy.checkA11y();
1211
      cy.findAllByTestId("confirm").click();
1212
    });
1213

1214
    it("Check a11y violations on import client", () => {
1215
      cy.findByTestId("importClient").click();
1216
      cy.checkA11y();
1217
    });
1218

1219
    it("Check a11y violations on initial access token", () => {
1220
      const initialAccessTokenTab = new InitialAccessTokenTab();
1221
      initialAccessTokenTab.goToInitialAccessTokenTab();
1222
      cy.checkA11y();
1223
    });
1224

1225
    it("Check a11y violations on client registration/ anonymous access policies tab", () => {
1226
      const clientRegistration = new ClientRegistrationPage();
1227
      clientRegistration.goToClientRegistrationTab();
1228
      cy.checkA11y();
1229
    });
1230

1231
    it("Check a11y violations on client registration/ authenticated access policies tab", () => {
1232
      const clientRegistration = new ClientRegistrationPage();
1233
      clientRegistration.goToClientRegistrationTab();
1234
      cy.findByTestId("authenticated").click();
1235
      cy.checkA11y();
1236
    });
1237
  });
1238
});
1239

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

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

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

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