github.com/minio/console@v1.4.1/web-app/tests/permissions-7/users.ts (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2022 MinIO, Inc. 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Affero General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Affero General Public License for more details. 13 // 14 // You should have received a copy of the GNU Affero General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 import * as roles from "../utils/roles"; 18 import * as elements from "../utils/elements"; 19 import * as constants from "../utils/constants"; 20 import { Selector } from "testcafe"; 21 import { identityElement, usersElement } from "../utils/elements-menu"; 22 import { IAM_PAGES } from "../../src/common/SecureComponent/permissions"; 23 24 const userListItem = Selector(".ReactVirtualized__Table__rowColumn").withText( 25 constants.TEST_USER_NAME, 26 ); 27 const policyListItem = Selector(".ReactVirtualized__Table__rowColumn").withText( 28 constants.TEST_ASSIGN_POLICY_NAME, 29 ); 30 31 const userDeleteIconButton = userListItem 32 .child("checkbox") 33 .withAttribute("aria-label", "secondary checkbox"); 34 35 const userCheckbox = Selector(".TableCheckbox span.checkbox"); 36 37 fixture("For user with Users permissions") 38 .page("http://localhost:9090") 39 .beforeEach(async (t) => { 40 await t.useRole(roles.users); 41 }); 42 43 test("Users sidebar item exists", async (t) => { 44 const usersExist = usersElement.exists; 45 await t 46 .expect(identityElement.exists) 47 .ok() 48 .click(identityElement) 49 .expect(usersExist) 50 .ok(); 51 }); 52 const appBaseUrl = "http://localhost:9090"; 53 let usersPageUrl = `${appBaseUrl}${IAM_PAGES.USERS}`; 54 let usersAddPageUrl = `${appBaseUrl}${IAM_PAGES.USER_ADD}`; 55 test("Create User button exists", async (t) => { 56 const createUserButtonExists = elements.createUserButton.exists; 57 await t.navigateTo(usersPageUrl).expect(createUserButtonExists).ok(); 58 }); 59 60 test("Create User button is clickable", async (t) => { 61 await t.navigateTo(usersPageUrl).click(elements.createUserButton); 62 }); 63 64 test("Create User Page to create a user", async (t) => { 65 const accessKeyInputExists = elements.usersAccessKeyInput.exists; 66 const secretKeyInputExists = elements.usersSecretKeyInput.exists; 67 await t 68 .navigateTo(usersAddPageUrl) 69 .expect(accessKeyInputExists) 70 .ok() 71 .expect(secretKeyInputExists) 72 .ok() 73 .typeText(elements.usersAccessKeyInput, constants.TEST_USER_NAME) 74 .typeText(elements.usersSecretKeyInput, constants.TEST_PASSWORD) 75 .click(elements.saveButton); 76 }); 77 78 test("Users table exists", async (t) => { 79 const usersTableExists = elements.table.exists; 80 await t.navigateTo(usersPageUrl).expect(usersTableExists).ok(); 81 }); 82 83 test("IAM Policy can be set on User", async (t) => { 84 const userListItemExists = userListItem.exists; 85 const policyListItemExists = policyListItem.exists; 86 await t 87 .navigateTo(usersPageUrl) 88 .typeText(elements.searchResourceInput, constants.TEST_USER_NAME) 89 .expect(userListItemExists) 90 .ok() 91 .click(userListItem) 92 .click(elements.userPolicies) 93 .click(elements.assignPoliciesButton) 94 .typeText(elements.searchResourceInput, constants.TEST_ASSIGN_POLICY_NAME) 95 .click(userCheckbox) 96 .click(elements.saveButton) 97 .expect(policyListItemExists) 98 .ok(); 99 }); 100 101 test("Created User can be viewed and deleted", async (t) => { 102 const userListItemExists = userListItem.exists; 103 const deleteSelectedButton = Selector("button").withAttribute( 104 "id", 105 "delete-selected-users", 106 ); 107 await t 108 .navigateTo(usersPageUrl) 109 .typeText(elements.searchResourceInput, constants.TEST_USER_NAME) 110 .expect(userListItemExists) 111 .ok() 112 .click(userCheckbox) 113 .click(deleteSelectedButton) 114 .click(elements.deleteButton) 115 .expect(userListItemExists) 116 .notOk(); 117 });