Keycloak

Форк
0
/
realm_test.spec.ts 
120 строк · 3.7 Кб
1
import { v4 as uuid } from "uuid";
2
import LoginPage from "../support/pages/LoginPage";
3
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
4
import CreateRealmPage from "../support/pages/admin-ui/CreateRealmPage";
5
import Masthead from "../support/pages/admin-ui/Masthead";
6
import adminClient from "../support/util/AdminClient";
7
import { keycloakBefore } from "../support/util/keycloak_hooks";
8
import RealmSettings from "../support/pages/admin-ui/configure/realm_settings/RealmSettings";
9
import ModalUtils from "../support/util/ModalUtils";
10

11
const masthead = new Masthead();
12
const loginPage = new LoginPage();
13
const sidebarPage = new SidebarPage();
14
const createRealmPage = new CreateRealmPage();
15
const realmSettings = new RealmSettings();
16
const modalUtils = new ModalUtils();
17

18
const testRealmName = "Test-realm-" + uuid();
19
const newRealmName = "New-Test-realm-" + uuid();
20
const editedRealmName = "Edited-Test-realm-" + uuid();
21
const testDisabledName = "Test-Disabled";
22

23
describe("Realm tests", () => {
24
  beforeEach(() => {
25
    loginPage.logIn();
26
    keycloakBefore();
27
  });
28

29
  after(() =>
30
    Promise.all(
31
      [testRealmName, newRealmName, editedRealmName].map((realm) =>
32
        adminClient.deleteRealm(realm),
33
      ),
34
    ),
35
  );
36

37
  it("should fail creating duplicated or empty name realm", () => {
38
    sidebarPage.goToCreateRealm();
39

40
    createRealmPage.createRealm().verifyRealmNameFieldInvalid();
41

42
    createRealmPage.fillRealmName("master").createRealm();
43

44
    masthead.checkNotificationMessage(
45
      "Could not create realm Conflict detected. See logs for details",
46
    );
47

48
    createRealmPage.cancelRealmCreation();
49
  });
50

51
  it("should create Test realm", () => {
52
    sidebarPage.goToCreateRealm();
53

54
    // Test and clear resource field
55
    createRealmPage.fillCodeEditor();
56
    createRealmPage.clearTextField();
57

58
    createRealmPage.fillRealmName(testRealmName).createRealm();
59

60
    masthead.checkNotificationMessage("Realm created successfully");
61
  });
62

63
  it("CRUD test of Disabled realm", () => {
64
    sidebarPage.goToCreateRealm();
65
    sidebarPage.waitForPageLoad();
66

67
    createRealmPage.fillRealmName(testDisabledName).createRealm();
68

69
    masthead.checkNotificationMessage("Realm created successfully");
70

71
    cy.reload();
72
    sidebarPage.goToRealm(testDisabledName).goToRealmSettings();
73

74
    createRealmPage.disableRealm();
75
    modalUtils.confirmModal();
76

77
    masthead.checkNotificationMessage("Realm successfully updated");
78

79
    sidebarPage.goToRealm(testDisabledName).goToRealmSettings();
80
    realmSettings.clickActionMenu();
81
    cy.findByText("Delete").click();
82
    modalUtils.cancelModal();
83

84
    cy.reload();
85
    sidebarPage.waitForPageLoad();
86
    sidebarPage.goToRealm(testDisabledName).goToRealmSettings();
87
    realmSettings.clickActionMenu();
88
    cy.findByText("Delete").click();
89
    modalUtils.confirmModal();
90
    masthead.checkNotificationMessage("The realm has been deleted");
91

92
    // Show current realms
93
    sidebarPage.realmExists("Test-Disabled", false);
94
  });
95

96
  it("should create realm from new a realm", () => {
97
    sidebarPage.goToCreateRealm();
98
    createRealmPage.fillRealmName(newRealmName).createRealm();
99

100
    masthead.checkNotificationMessage("Realm created successfully");
101

102
    sidebarPage.goToCreateRealm();
103
    createRealmPage.fillRealmName(editedRealmName).createRealm();
104

105
    masthead.checkNotificationMessage("Realm created successfully");
106

107
    // Show current realms
108
    sidebarPage.showCurrentRealms(4);
109
  });
110

111
  it("should change to Test realm", () => {
112
    sidebarPage.goToRealm(editedRealmName);
113
    sidebarPage.getCurrentRealm().should("eq", editedRealmName);
114

115
    sidebarPage
116
      .goToRealm(testRealmName)
117
      .getCurrentRealm()
118
      .should("eq", testRealmName);
119
  });
120
});
121

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

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

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

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