2021-03-03 19:12:16 +00:00
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2021-03-04 14:26:21 +00:00
|
|
|
import CreateUserPage from "../support/pages/admin_console/manage/users/CreateUserPage";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
2021-03-11 20:23:08 +00:00
|
|
|
import UserDetailsPage from "../support/pages/admin_console/manage/users/UserDetailsPage";
|
2021-10-25 14:38:54 +00:00
|
|
|
import AttributesTab from "../support/pages/admin_console/manage/AttributesTab";
|
2021-03-11 20:23:08 +00:00
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2021-03-18 12:48:14 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
2021-04-14 18:19:39 +00:00
|
|
|
import GroupModal from "../support/pages/admin_console/manage/groups/GroupModal";
|
|
|
|
import UserGroupsPage from "../support/pages/admin_console/manage/users/UserGroupsPage";
|
2021-05-06 05:31:40 +00:00
|
|
|
import AdminClient from "../support/util/AdminClient";
|
2021-12-21 06:22:44 +00:00
|
|
|
import CredentialsPage from "../support/pages/admin_console/manage/users/CredentialsPage";
|
2021-04-14 18:19:39 +00:00
|
|
|
|
|
|
|
let groupName = "group";
|
2021-04-19 19:53:28 +00:00
|
|
|
let groupsList: string[] = [];
|
2021-04-14 18:19:39 +00:00
|
|
|
|
|
|
|
describe("Group creation", () => {
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const groupModal = new GroupModal();
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
beforeEach(() => {
|
2021-04-14 18:19:39 +00:00
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
});
|
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
function createNewGroup() {
|
2021-04-14 18:19:39 +00:00
|
|
|
groupName += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
2021-09-15 09:45:56 +00:00
|
|
|
sidebarPage.waitForPageLoad();
|
2021-06-16 11:35:03 +00:00
|
|
|
groupModal.open().fillGroupForm(groupName).clickCreate();
|
2021-04-14 18:19:39 +00:00
|
|
|
|
2021-04-19 19:53:28 +00:00
|
|
|
groupsList = [...groupsList, groupName];
|
|
|
|
masthead.checkNotificationMessage("Group created");
|
|
|
|
|
|
|
|
sidebarPage.goToGroups();
|
2021-04-20 12:22:36 +00:00
|
|
|
}
|
2021-04-19 19:53:28 +00:00
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
it("Add groups to be joined", () => {
|
|
|
|
for (let i = 0; i <= 2; i++) {
|
|
|
|
createNewGroup();
|
|
|
|
}
|
2021-04-14 18:19:39 +00:00
|
|
|
});
|
|
|
|
});
|
2021-03-03 19:12:16 +00:00
|
|
|
|
|
|
|
describe("Users test", () => {
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2021-03-04 14:26:21 +00:00
|
|
|
const createUserPage = new CreateUserPage();
|
2021-04-14 18:19:39 +00:00
|
|
|
const userGroupsPage = new UserGroupsPage();
|
2021-03-04 14:26:21 +00:00
|
|
|
const masthead = new Masthead();
|
2021-03-11 20:23:08 +00:00
|
|
|
const modalUtils = new ModalUtils();
|
2021-03-04 14:26:21 +00:00
|
|
|
const listingPage = new ListingPage();
|
2021-03-11 20:23:08 +00:00
|
|
|
const userDetailsPage = new UserDetailsPage();
|
2021-12-21 06:22:44 +00:00
|
|
|
const credentialsPage = new CredentialsPage();
|
2021-10-25 14:38:54 +00:00
|
|
|
const attributesTab = new AttributesTab();
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
let itemId = "user_crud";
|
2021-12-21 06:22:44 +00:00
|
|
|
let itemIdWithCred = "user_crud_cred";
|
2021-03-03 19:12:16 +00:00
|
|
|
|
|
|
|
describe("User creation", () => {
|
2021-03-11 20:23:08 +00:00
|
|
|
beforeEach(() => {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-03-03 19:12:16 +00:00
|
|
|
loginPage.logIn();
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.intercept(
|
|
|
|
"/auth/admin/realms/master/components?type=org.keycloak.storage.UserStorageProvider"
|
|
|
|
).as("brute-force");
|
2021-03-03 19:12:16 +00:00
|
|
|
sidebarPage.goToUsers();
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
after(async () => {
|
|
|
|
await new AdminClient().deleteGroups();
|
|
|
|
});
|
2021-03-04 18:49:05 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Go to create User page", () => {
|
2021-03-04 14:26:21 +00:00
|
|
|
createUserPage.goToCreateUser();
|
2021-03-03 19:12:16 +00:00
|
|
|
cy.url().should("include", "users/add-user");
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
// Verify Cancel button works
|
|
|
|
createUserPage.cancel();
|
2021-03-03 19:12:16 +00:00
|
|
|
cy.url().should("not.include", "/add-user");
|
|
|
|
});
|
2021-03-04 14:26:21 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Create user test", () => {
|
2021-03-04 14:26:21 +00:00
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
2021-03-04 18:49:05 +00:00
|
|
|
|
2021-03-04 14:26:21 +00:00
|
|
|
// Create
|
|
|
|
createUserPage.goToCreateUser();
|
2021-03-04 18:49:05 +00:00
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
createUserPage.createUser(itemId);
|
|
|
|
|
|
|
|
createUserPage.toggleAddGroupModal();
|
|
|
|
|
|
|
|
const groupsListCopy = groupsList.slice(0, 1);
|
|
|
|
|
|
|
|
groupsListCopy.forEach((element) => {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(`${element}-check`).click();
|
2021-04-20 12:22:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
createUserPage.joinGroups();
|
|
|
|
|
|
|
|
createUserPage.save();
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been created");
|
|
|
|
|
2021-03-11 20:23:08 +00:00
|
|
|
sidebarPage.goToUsers();
|
|
|
|
});
|
|
|
|
|
2021-12-21 06:22:44 +00:00
|
|
|
it("Create user with credentials test", () => {
|
|
|
|
itemIdWithCred += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
createUserPage.goToCreateUser();
|
|
|
|
|
|
|
|
createUserPage.createUser(itemIdWithCred);
|
|
|
|
|
|
|
|
createUserPage.save();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been created");
|
|
|
|
|
|
|
|
sidebarPage.goToUsers();
|
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemIdWithCred);
|
|
|
|
|
|
|
|
userDetailsPage.fillUserData().save();
|
|
|
|
masthead.checkNotificationMessage("The user has been saved");
|
|
|
|
|
|
|
|
credentialsPage
|
|
|
|
.goToCredentialsTab()
|
|
|
|
.clickEmptyStatePasswordBtn()
|
|
|
|
.fillPasswordForm()
|
|
|
|
.clickConfirmationBtn()
|
|
|
|
.clickSetPasswordBtn();
|
|
|
|
|
|
|
|
sidebarPage.goToUsers();
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("User details test", () => {
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-03-11 20:23:08 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
userDetailsPage.fillUserData().save();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been saved");
|
|
|
|
|
2021-04-14 18:19:39 +00:00
|
|
|
sidebarPage.goToUsers();
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
});
|
2021-03-23 19:02:27 +00:00
|
|
|
|
2021-10-25 14:38:54 +00:00
|
|
|
it("User attributes test", () => {
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-10-25 14:38:54 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
attributesTab
|
|
|
|
.goToAttributesTab()
|
2021-10-28 18:49:19 +00:00
|
|
|
.fillLastRow("key", "value")
|
2021-10-25 14:38:54 +00:00
|
|
|
.saveAttribute();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been saved");
|
|
|
|
});
|
|
|
|
|
2021-10-28 18:49:19 +00:00
|
|
|
it("User attributes with multiple values test", () => {
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-10-28 18:49:19 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
cy.intercept("PUT", `/auth/admin/realms/master/users/*`).as("save-user");
|
|
|
|
|
|
|
|
const attributeKey = "key-multiple";
|
|
|
|
attributesTab
|
|
|
|
.goToAttributesTab()
|
|
|
|
.fillLastRow(attributeKey, "other value")
|
|
|
|
.saveAttribute();
|
|
|
|
|
|
|
|
cy.wait("@save-user").should(({ request, response }) => {
|
|
|
|
expect(response?.statusCode).to.equal(204);
|
|
|
|
|
2021-12-01 07:58:25 +00:00
|
|
|
expect(request?.body.attributes, "response body").deep.equal({
|
|
|
|
key: ["value"],
|
|
|
|
"key-multiple": ["other value"],
|
|
|
|
});
|
2021-10-28 18:49:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been saved");
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Add user to groups test", () => {
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-04-14 18:19:39 +00:00
|
|
|
// Go to user groups
|
2021-03-04 14:26:21 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
userGroupsPage.goToGroupsTab();
|
|
|
|
userGroupsPage.toggleAddGroupModal();
|
2021-04-19 19:53:28 +00:00
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
const groupsListCopy = groupsList.slice(1, 2);
|
|
|
|
|
|
|
|
groupsListCopy.forEach((element) => {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(`${element}-check`).click();
|
2021-04-19 19:53:28 +00:00
|
|
|
});
|
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
userGroupsPage.joinGroups();
|
2021-04-14 18:19:39 +00:00
|
|
|
});
|
2021-03-11 20:23:08 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Leave group test", () => {
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
// Go to user groups
|
|
|
|
userGroupsPage.goToGroupsTab();
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.findByTestId(`leave-${groupsList[0]}`).click();
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId("modalConfirm").click();
|
2021-04-14 18:19:39 +00:00
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Go to user consents test", () => {
|
2021-11-03 13:45:37 +00:00
|
|
|
cy.wait("@brute-force");
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
2021-04-14 18:39:21 +00:00
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId("user-consents-tab").click();
|
|
|
|
cy.findByTestId("empty-state").contains("No consents");
|
2021-04-14 18:39:21 +00:00
|
|
|
});
|
|
|
|
|
2021-12-21 06:22:44 +00:00
|
|
|
it("Reset credential of User with empty state", () => {
|
|
|
|
cy.wait("@brute-force");
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
credentialsPage
|
|
|
|
.goToCredentialsTab()
|
|
|
|
.clickEmptyStateResetBtn()
|
|
|
|
.fillResetCredentialForm();
|
|
|
|
masthead.checkNotificationMessage("Failed to send email to user.");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Reset credential of User with existing credentials", () => {
|
|
|
|
cy.wait("@brute-force");
|
|
|
|
listingPage.goToItemDetails(itemIdWithCred);
|
|
|
|
credentialsPage
|
|
|
|
.goToCredentialsTab()
|
|
|
|
.clickResetBtn()
|
|
|
|
.fillResetCredentialForm();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Failed to send email to user.");
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Delete user test", () => {
|
2021-03-11 20:23:08 +00:00
|
|
|
// Delete
|
|
|
|
listingPage.deleteItem(itemId);
|
|
|
|
|
|
|
|
modalUtils.checkModalTitle("Delete user?").confirmModal();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been deleted");
|
|
|
|
|
|
|
|
listingPage.itemExist(itemId, false);
|
2021-03-04 14:26:21 +00:00
|
|
|
});
|
2021-12-21 06:22:44 +00:00
|
|
|
|
|
|
|
it("Delete user with credential test", () => {
|
|
|
|
// Delete
|
|
|
|
listingPage.deleteItem(itemIdWithCred);
|
|
|
|
|
|
|
|
modalUtils.checkModalTitle("Delete user?").confirmModal();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been deleted");
|
|
|
|
|
|
|
|
listingPage.itemExist(itemIdWithCred, false);
|
|
|
|
});
|
2021-03-03 19:12:16 +00:00
|
|
|
});
|
2021-04-19 19:53:28 +00:00
|
|
|
});
|