From af9e4fc1509287cf1b668dbf1c27300c474ae004 Mon Sep 17 00:00:00 2001 From: jinapurapu <65002498+jinapurapu@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:56:28 -0700 Subject: [PATCH] Fixes for Permission tests (#2351) Updates location of Policies screen, adds required policies to testing profiles Authored-by: Jillian Inapurapu --- .../src/common/SecureComponent/permissions.ts | 2 + portal-ui/tests/permissions-1/groups.ts | 39 +++++++++++++------ portal-ui/tests/permissions-1/iamPolicies.ts | 14 +++---- portal-ui/tests/policies/users.json | 5 ++- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/portal-ui/src/common/SecureComponent/permissions.ts b/portal-ui/src/common/SecureComponent/permissions.ts index 228f22ad9..fa5487d5e 100644 --- a/portal-ui/src/common/SecureComponent/permissions.ts +++ b/portal-ui/src/common/SecureComponent/permissions.ts @@ -128,6 +128,8 @@ export const IAM_PAGES = { ACCOUNT: "/identity/account", ACCOUNT_ADD: "/identity/account/new-account", USER_SA_ACCOUNT_ADD: "/identity/users/new-user-sa/:userName", + + /* Access */ POLICIES: "/identity/policies", POLICY_ADD: "/identity/add-policy", POLICIES_VIEW: "/identity/policies/*", diff --git a/portal-ui/tests/permissions-1/groups.ts b/portal-ui/tests/permissions-1/groups.ts index 8f9f3649e..57534e4c1 100644 --- a/portal-ui/tests/permissions-1/groups.ts +++ b/portal-ui/tests/permissions-1/groups.ts @@ -50,22 +50,32 @@ fixture("For user with Groups permissions") await t.useRole(roles.groups); }); +test("Create Group button exists", async (t) => { + const createGroupButtonExists = elements.createGroupButton.exists; + await t + .navigateTo(groupsPageUrl) + .expect(createGroupButtonExists) + .ok() + .wait(2000); +}); + test("Groups sidebar item exists", async (t) => { await t .expect(identityElement.exists) .ok() .click(identityElement) .expect(groupsElement.exists) - .ok(); -}); - -test("Create Group button exists", async (t) => { - const createGroupButtonExists = elements.createGroupButton.exists; - await t.navigateTo(groupsPageUrl).expect(createGroupButtonExists).ok(); + .ok() + .wait(2000); }); test("Create Group button is clickable", async (t) => { - await t.navigateTo(groupsPageUrl).click(elements.createGroupButton); + await t + .navigateTo(groupsPageUrl) + .click(elements.createGroupButton) + .expect(true) + .ok() + .wait(2000); }); test("Group Name input exists in the Create Group page", async (t) => { @@ -73,7 +83,8 @@ test("Group Name input exists in the Create Group page", async (t) => { .navigateTo(groupsPageUrl) .click(elements.createGroupButton) .expect(elements.groupNameInput.exists) - .ok(); + .ok() + .wait(2000); }); test("Users table exists in the Create Groups page", async (t) => { @@ -82,7 +93,8 @@ test("Users table exists in the Create Groups page", async (t) => { .navigateTo(groupsPageUrl) .click(elements.createGroupButton) .expect(createGroupUserTableExists) - .ok(); + .ok() + .wait(2000); }); test.before(async (t) => { @@ -97,7 +109,8 @@ test.before(async (t) => { .typeText(elements.groupNameInput, constants.TEST_GROUP_NAME) .typeText(elements.filterUserInput, constants.TEST_USER_NAME) .click(elements.groupUserCheckbox) - .click(elements.saveButton); + .click(elements.saveButton) + .wait(2000); }); test.before(async (t) => { @@ -105,7 +118,11 @@ test.before(async (t) => { await functions.createUser(t); await createGroup(t, "groups-table"); })("Groups table exists", async (t) => { - await t.navigateTo(groupsPageUrl).expect(elements.table.exists).ok(); + await t + .navigateTo(groupsPageUrl) + .expect(elements.table.exists) + .ok() + .wait(2000); }); test.before(async (t) => { diff --git a/portal-ui/tests/permissions-1/iamPolicies.ts b/portal-ui/tests/permissions-1/iamPolicies.ts index 4bd89c471..85bf857cc 100644 --- a/portal-ui/tests/permissions-1/iamPolicies.ts +++ b/portal-ui/tests/permissions-1/iamPolicies.ts @@ -52,21 +52,21 @@ test("IAM Policies sidebar item exists", async (t) => { test("Create Policy button exists", async (t) => { const createPolicyButtonExists = elements.createPolicyButton.exists; await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .expect(createPolicyButtonExists) .ok(); }); test("Create Policy button is clickable", async (t) => { await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .click(elements.createPolicyButton); }); test("Policy Name input exists in the Create Policy modal", async (t) => { const policyNameInputExists = elements.createPolicyName.exists; await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .click(elements.createPolicyButton) .expect(policyNameInputExists) .ok(); @@ -75,7 +75,7 @@ test("Policy Name input exists in the Create Policy modal", async (t) => { test("Policy textfield exists in the Create Policy modal", async (t) => { const policyTextfieldExists = elements.createPolicyTextfield.exists; await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .click(elements.createPolicyButton) .expect(policyTextfieldExists) .ok(); @@ -83,7 +83,7 @@ test("Policy textfield exists in the Create Policy modal", async (t) => { test("Create Policy modal can be submitted after inputs are entered", async (t) => { await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .click(elements.createPolicyButton) .typeText(elements.createPolicyName, constants.TEST_IAM_POLICY_NAME) .typeText(elements.createPolicyTextfield, constants.TEST_IAM_POLICY, { @@ -94,7 +94,7 @@ test("Create Policy modal can be submitted after inputs are entered", async (t) }).after(async (t) => { // Clean up created policy await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .typeText(elements.searchResourceInput, constants.TEST_IAM_POLICY_NAME) .click(iamPolicyDelete) .click(elements.deleteButton); @@ -103,7 +103,7 @@ test("Create Policy modal can be submitted after inputs are entered", async (t) test("Created Policy can be viewed and deleted", async (t) => { const iamPolicyListItemExists = iamPolicyListItem.exists; await t - .navigateTo("http://localhost:9090/access/policies") + .navigateTo("http://localhost:9090/identity/policies") .click(elements.createPolicyButton) .typeText(elements.createPolicyName, constants.TEST_IAM_POLICY_NAME) .typeText(elements.createPolicyTextfield, constants.TEST_IAM_POLICY, { diff --git a/portal-ui/tests/policies/users.json b/portal-ui/tests/policies/users.json index 957992883..293332e8e 100644 --- a/portal-ui/tests/policies/users.json +++ b/portal-ui/tests/policies/users.json @@ -10,7 +10,10 @@ "admin:EnableUser", "admin:DisableUser", "admin:ListUserPolicies", - "admin:ListGroups" + "admin:ListGroups", + "admin:AttachUserOrGroupPolicy", + "admin:RemoveUserFromGroup", + "admin:AddUserToGroup" ], "Effect": "Allow", "Resource": ["arn:aws:s3:::*"],