Skip to content

Commit 198a441

Browse files
fix: hide Access Tokens and User Access Control tabs from package settings if the user does not have corresponding permissions (#54)
1 parent 8a1c7a8 commit 198a441

File tree

12 files changed

+144
-254
lines changed

12 files changed

+144
-254
lines changed

src/packages/portal/pages/PortalPage/BaseVersionPage/PackageSettingsPage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Page } from '@playwright/test'
2-
import { Breadcrumbs, Button, Title } from '@shared/components/base'
2+
import { Breadcrumbs, Button, Placeholder, Title } from '@shared/components/base'
33
import { GeneralSettingsTab } from './PackageSettingsPage/GeneralSettingsTab'
44
import { ApiSpecConfigTab } from './PackageSettingsPage/ApiSpecConfigTab'
55
import { VersionsTab } from './PackageSettingsPage/VersionsTab'
@@ -16,6 +16,7 @@ export class PackageSettingsPage {
1616
readonly versionsTab = new VersionsTab(this.page)
1717
readonly accessTokensTab = new AccessTokensTab(this.page)
1818
readonly accessControlTab = new AccessControlTab(this.page)
19+
readonly noPermissionPlaceholder = new Placeholder(this.page.getByTestId('NoPermissionPlaceholder'), 'No permission')
1920

2021
constructor(private readonly page: Page) { }
2122
}

src/test-data/portal/uac/general/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export const NO_PERM_GEN_TOKEN = 'You do not have permission to generate token'
1111
export const NO_PERM_REVOKE_TOKEN = 'You do not have permission to revoke the token'
1212
export const NO_PERM_ADD_MEMBER = 'You do not have permission to add member'
1313
export const NO_PERM_MANAGE_ROLES = 'You do not have permission to manage user roles in current package'
14+
export const NO_PERM_SEE_PAGE = 'You do not have permission to see this page'

src/tests/portal/03-access-control/3.0-general.spec.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { PortalPage } from '@portal/pages/PortalPage'
44
import {
55
GRP_P_UAC_G1_N,
66
GRP_P_UAC_G2_N,
7+
NO_PERM_SEE_PAGE,
78
PKG_P_UAC_G_ASSIGN_N,
89
PKG_P_UAC_G_INHER_N,
910
PKG_P_UAC_G_MULT1_N,
@@ -301,27 +302,15 @@ test.describe('03.0 Access Control. General.', () => {
301302

302303
const portalPage = new PortalPage(page)
303304
const { versionPackagePage: versionPage } = portalPage
304-
const { accessControlTab } = versionPage.packageSettingsPage
305+
const { accessControlTab, noPermissionPlaceholder } = versionPage.packageSettingsPage
305306
const testUserName = TEST_USER_1.name
306-
const tooltipMsg = 'You do not have permission to manage user roles in current package'
307307

308308
await portalPage.gotoPackage(PKG_P_UAC_G_MULT2_N, SETTINGS_TAB_USERS)
309-
310309
await expect(accessControlTab.getUserRow(testUserName).adminChx).toBeEnabled()
311-
312310
await accessControlTab.getUserRow(testUserName).adminChx.click()
313311

314-
await expect(accessControlTab.getUserRow(testUserName).adminChx).toBeDisabled()
315-
316-
await accessControlTab.getUserRow(testUserName).adminChx.hover({ force: true })
317-
318-
await expect(portalPage.tooltip).toHaveCount(1)
319-
await expect(portalPage.tooltip).toHaveText(tooltipMsg)
320-
321-
await accessControlTab.getUserRow(testUserName).deleteBtn.hover({ force: true })
322-
323-
await expect(portalPage.tooltip).toHaveCount(1)
324-
await expect(portalPage.tooltip).toHaveText(tooltipMsg)
312+
await expect(accessControlTab).not.toBeVisible()
313+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
325314
})
326315

327316
test('[P-ACG-03.7] Deleting a user by checkbox clicking',

src/tests/portal/03-access-control/3.1.1-viewer-package.spec.ts

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ import { PortalPage } from '@portal/pages/PortalPage'
44
import {
55
CREATE_LIST_OF_USERS_V1,
66
GRP_P_VIEWER_ROOT_R,
7-
NO_PERM_ADD_MEMBER,
87
NO_PERM_CREATE_GROUP,
98
NO_PERM_DEL_PACKAGE,
109
NO_PERM_DEL_VERSION,
1110
NO_PERM_EDIT_PACKAGE,
1211
NO_PERM_EDIT_VERSION,
13-
NO_PERM_GEN_TOKEN,
14-
NO_PERM_MANAGE_ROLES,
12+
NO_PERM_SEE_PAGE,
1513
OGR_PREFIX_DELETION_MSG,
1614
OGR_PREFIX_EDITING_MSG,
1715
ORG_UAC_PKG_REST,
1816
PKG_P_VIEWER_R,
1917
V_P_PKG_UAC_VIEWER_CHANGED_R,
2018
} from '@test-data/portal'
21-
import { VERSION_OVERVIEW_TAB_GROUPS } from '@portal/entities'
19+
import { SETTINGS_TAB_TOKENS, SETTINGS_TAB_USERS, VERSION_OVERVIEW_TAB_GROUPS } from '@portal/entities'
2220
import { TICKET_BASE_URL } from '@test-setup'
2321

2422
test.describe('03.1.1 Access Control. Viewer role. (Package)', () => {
@@ -198,6 +196,7 @@ test.describe('03.1.1 Access Control. Viewer role. (Package)', () => {
198196
versionsTab,
199197
accessTokensTab,
200198
accessControlTab,
199+
noPermissionPlaceholder
201200
} = versionPage.packageSettingsPage
202201

203202
await portalPage.gotoPackage(testPackage)
@@ -261,31 +260,15 @@ test.describe('03.1.1 Access Control. Viewer role. (Package)', () => {
261260
})
262261

263262
await test.step('View "Access Tokens" tab', async () => {
264-
await accessTokensTab.click()
265-
266-
await expect(accessTokensTab.nameTxtFld).toBeDisabled()
267-
await expect(accessTokensTab.rolesAc).toBeDisabled()
268-
await expect(accessTokensTab.createdForAc).toBeDisabled()
269-
await expect(accessTokensTab.generateBtn).toBeDisabled()
270-
271-
await accessTokensTab.generateBtn.hover({ force: true })
272-
273-
await expect(portalPage.tooltip).toHaveCount(1)
274-
await expect(portalPage.tooltip).toHaveText(NO_PERM_GEN_TOKEN)
275-
276-
await expect(portalPage.tooltip).toHaveCount(1)
277-
// await expect(portalPage.tooltip).toHaveText(NO_PERM_REVOKE_TOKEN) //TODO: TestCase-B-1019
263+
await expect(accessTokensTab).not.toBeVisible()
264+
await portalPage.gotoPackage(testPackage, SETTINGS_TAB_TOKENS)
265+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
278266
})
279267

280268
await test.step('View "User Access Control" tab', async () => {
281-
await accessControlTab.click()
282-
283-
await expect(accessControlTab.addUserBtn).toBeDisabled()
284-
285-
await accessControlTab.addUserBtn.hover({ force: true })
286-
287-
await expect(portalPage.tooltip).toHaveCount(1)
288-
await expect(portalPage.tooltip).toHaveText(NO_PERM_ADD_MEMBER)
269+
await expect(accessControlTab).not.toBeVisible()
270+
await portalPage.gotoPackage(testPackage, SETTINGS_TAB_USERS)
271+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
289272
})
290273
})
291274
})

src/tests/portal/03-access-control/3.1.2-viewer-dashboard.spec.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import { expect, expectFile } from '@services/expect-decorator'
33
import { PortalPage } from '@portal/pages/PortalPage'
44
import {
55
DSH_P_VIEWER_R,
6-
NO_PERM_ADD_MEMBER,
76
NO_PERM_CREATE_GROUP,
87
NO_PERM_DEL_PACKAGE,
98
NO_PERM_DEL_VERSION,
109
NO_PERM_EDIT_PACKAGE,
1110
NO_PERM_EDIT_VERSION,
12-
NO_PERM_GEN_TOKEN,
13-
NO_PERM_MANAGE_ROLES,
11+
NO_PERM_SEE_PAGE,
1412
OGR_UAC_DSH_REST,
1513
PKG_P_VIEWER_R,
1614
V_P_DSH_UAC_VIEWER_CHANGED_R,
1715
} from '@test-data/portal'
18-
import { SETTINGS_TAB_GENERAL, VERSION_OVERVIEW_TAB_GROUPS } from '@portal/entities'
16+
import {
17+
SETTINGS_TAB_GENERAL,
18+
SETTINGS_TAB_TOKENS,
19+
SETTINGS_TAB_USERS,
20+
VERSION_OVERVIEW_TAB_GROUPS,
21+
} from '@portal/entities'
1922
import { TICKET_BASE_URL } from '@test-setup'
2023

2124
test.describe('03.1.2 Access Control. Viewer role. (Dashboard)', () => {
@@ -175,6 +178,7 @@ test.describe('03.1.2 Access Control. Viewer role. (Dashboard)', () => {
175178
versionsTab,
176179
accessTokensTab,
177180
accessControlTab,
181+
noPermissionPlaceholder,
178182
} = versionPage.packageSettingsPage
179183

180184
await portalPage.gotoDashboard(testDashboard)
@@ -225,31 +229,15 @@ test.describe('03.1.2 Access Control. Viewer role. (Dashboard)', () => {
225229
})
226230

227231
await test.step('View "Access Tokens" tab', async () => {
228-
await accessTokensTab.click()
229-
230-
await expect(accessTokensTab.nameTxtFld).toBeDisabled()
231-
await expect(accessTokensTab.rolesAc).toBeDisabled()
232-
await expect(accessTokensTab.createdForAc).toBeDisabled()
233-
await expect(accessTokensTab.generateBtn).toBeDisabled()
234-
235-
await accessTokensTab.generateBtn.hover({ force: true })
236-
237-
await expect(portalPage.tooltip).toHaveCount(1)
238-
await expect(portalPage.tooltip).toHaveText(NO_PERM_GEN_TOKEN)
239-
240-
await expect(portalPage.tooltip).toHaveCount(1)
241-
// await expect(portalPage.tooltip).toHaveText(NO_PERM_REVOKE_TOKEN) //TODO: TestCase-B-1019
232+
await expect(accessTokensTab).not.toBeVisible()
233+
await portalPage.gotoDashboard(testDashboard, SETTINGS_TAB_TOKENS)
234+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
242235
})
243236

244237
await test.step('View "User Access Control" tab', async () => {
245-
await accessControlTab.click()
246-
247-
await expect(accessControlTab.addUserBtn).toBeDisabled()
248-
249-
await accessControlTab.addUserBtn.hover({ force: true })
250-
251-
await expect(portalPage.tooltip).toHaveCount(1)
252-
await expect(portalPage.tooltip).toHaveText(NO_PERM_ADD_MEMBER)
238+
await expect(accessControlTab).not.toBeVisible()
239+
await portalPage.gotoDashboard(testDashboard, SETTINGS_TAB_USERS)
240+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
253241
})
254242
})
255243
})

src/tests/portal/03-access-control/3.1.3-viewer-group.spec.ts

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import { expect } from '@services/expect-decorator'
33
import { PortalPage } from '@portal/pages/PortalPage'
44
import {
55
GRP_P_VIEWER_R,
6-
NO_PERM_ADD_MEMBER,
76
NO_PERM_CREATE_PACKAGES,
87
NO_PERM_DEL_PACKAGE,
98
NO_PERM_EDIT_PACKAGE,
10-
NO_PERM_GEN_TOKEN,
11-
NO_PERM_MANAGE_ROLES,
9+
NO_PERM_SEE_PAGE,
1210
} from '@test-data/portal'
1311
import { TICKET_BASE_URL } from '@test-setup'
12+
import { SETTINGS_TAB_TOKENS, SETTINGS_TAB_USERS } from '@portal/entities'
1413

1514
test.describe('03.1.3 Access Control. Viewer role. (Group)', () => {
1615

@@ -27,7 +26,7 @@ test.describe('03.1.3 Access Control. Viewer role. (Group)', () => {
2726

2827
const portalPage = new PortalPage(page)
2928
const { versionPackagePage: versionPage } = portalPage
30-
const { generalTab, accessTokensTab, accessControlTab } = versionPage.packageSettingsPage
29+
const { generalTab, accessTokensTab, accessControlTab, noPermissionPlaceholder } = versionPage.packageSettingsPage
3130

3231
await test.step('Navigate to a group', async () => {
3332
await portalPage.gotoGroup(testGroup)
@@ -58,31 +57,15 @@ test.describe('03.1.3 Access Control. Viewer role. (Group)', () => {
5857
})
5958

6059
await test.step('View "Access Tokens" tab', async () => {
61-
await accessTokensTab.click()
62-
63-
await expect(accessTokensTab.nameTxtFld).toBeDisabled()
64-
await expect(accessTokensTab.rolesAc).toBeDisabled()
65-
await expect(accessTokensTab.createdForAc).toBeDisabled()
66-
await expect(accessTokensTab.generateBtn).toBeDisabled()
67-
68-
await accessTokensTab.generateBtn.hover({ force: true })
69-
70-
await expect(portalPage.tooltip).toHaveCount(1)
71-
await expect(portalPage.tooltip).toHaveText(NO_PERM_GEN_TOKEN)
72-
73-
await expect(portalPage.tooltip).toHaveCount(1)
74-
//! await expect(portalPage.tooltip).toHaveText(NO_PERM_REVOKE_TOKEN) //Issue: TestCase-B-1019
60+
await expect(accessTokensTab).not.toBeVisible()
61+
await portalPage.gotoPackage(testGroup, SETTINGS_TAB_TOKENS)
62+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
7563
})
7664

7765
await test.step('View "User Access Control" tab', async () => {
78-
await accessControlTab.click()
79-
80-
await expect(accessControlTab.addUserBtn).toBeDisabled()
81-
82-
await accessControlTab.addUserBtn.hover({ force: true })
83-
84-
await expect(portalPage.tooltip).toHaveCount(1)
85-
await expect(portalPage.tooltip).toHaveText(NO_PERM_ADD_MEMBER)
66+
await expect(accessControlTab).not.toBeVisible()
67+
await portalPage.gotoPackage(testGroup, SETTINGS_TAB_USERS)
68+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
8669
})
8770
})
8871
})

src/tests/portal/03-access-control/3.2.1-editor-package.spec.ts

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { PortalPage } from '@portal/pages/PortalPage'
44
import {
55
CREATE_LIST_OF_USERS_V1,
66
GRP_P_EDITOR_ROOT_N,
7-
NO_PERM_ADD_MEMBER,
87
NO_PERM_DEL_PACKAGE,
98
NO_PERM_EDIT_PACKAGE,
10-
NO_PERM_GEN_TOKEN,
11-
NO_PERM_MANAGE_ROLES,
9+
NO_PERM_SEE_PAGE,
1210
OGR_PREFIX_DELETION_MSG,
1311
OGR_PREFIX_EDITING_MSG,
1412
ORG_PKG_UAC_EDITOR_REST_CHANGING_OPERATIONS_N,
@@ -22,9 +20,20 @@ import {
2220
V_P_PKG_UAC_EDITOR_EDITING_RELEASE_N,
2321
VERSION_DELETED_MSG,
2422
} from '@test-data/portal'
25-
import { SETTINGS_TAB_VERSIONS, VERSION_OVERVIEW_TAB_GROUPS } from '@portal/entities'
23+
import {
24+
SETTINGS_TAB_TOKENS,
25+
SETTINGS_TAB_USERS,
26+
SETTINGS_TAB_VERSIONS,
27+
VERSION_OVERVIEW_TAB_GROUPS,
28+
} from '@portal/entities'
2629
import type { VersionStatuses } from '@shared/entities'
27-
import { API_TITLES_MAP, ARCHIVED_VERSION_STATUS, DRAFT_VERSION_STATUS, RELEASE_VERSION_STATUS, REST_API_TYPE } from '@shared/entities'
30+
import {
31+
API_TITLES_MAP,
32+
ARCHIVED_VERSION_STATUS,
33+
DRAFT_VERSION_STATUS,
34+
RELEASE_VERSION_STATUS,
35+
REST_API_TYPE,
36+
} from '@shared/entities'
2837
import { PUBLISH_TIMEOUT, SNAPSHOT_TIMEOUT, TICKET_BASE_URL } from '@test-setup'
2938

3039
test.describe('03.2.1 Access Control. Editor role. (Package)', () => {
@@ -326,6 +335,7 @@ test.describe('03.2.1 Access Control. Editor role. (Package)', () => {
326335
apiSpecConfigTab,
327336
accessTokensTab,
328337
accessControlTab,
338+
noPermissionPlaceholder,
329339
} = versionPage.packageSettingsPage
330340

331341
await portalPage.gotoGroup(rootGroup)
@@ -359,31 +369,15 @@ test.describe('03.2.1 Access Control. Editor role. (Package)', () => {
359369
})
360370

361371
await test.step('View "Access Tokens" tab', async () => {
362-
await accessTokensTab.click()
363-
364-
await expect(accessTokensTab.nameTxtFld).toBeDisabled()
365-
await expect(accessTokensTab.rolesAc).toBeDisabled()
366-
await expect(accessTokensTab.createdForAc).toBeDisabled()
367-
await expect(accessTokensTab.generateBtn).toBeDisabled()
368-
369-
await accessTokensTab.generateBtn.hover({ force: true })
370-
371-
await expect(portalPage.tooltip).toHaveCount(1)
372-
await expect(portalPage.tooltip).toHaveText(NO_PERM_GEN_TOKEN)
373-
374-
await expect(portalPage.tooltip).toHaveCount(1)
375-
//! await expect(portalPage.tooltip).toHaveText(NO_PERM_REVOKE_TOKEN) //Issue: TestCase-B-1019
372+
await expect(accessTokensTab).not.toBeVisible()
373+
await portalPage.gotoPackage(testPackage, SETTINGS_TAB_TOKENS)
374+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
376375
})
377376

378377
await test.step('View "User Access Control" tab', async () => {
379-
await accessControlTab.click()
380-
381-
await expect(accessControlTab.addUserBtn).toBeDisabled()
382-
383-
await accessControlTab.addUserBtn.hover({ force: true })
384-
385-
await expect(portalPage.tooltip).toHaveCount(1)
386-
await expect(portalPage.tooltip).toHaveText(NO_PERM_ADD_MEMBER)
378+
await expect(accessControlTab).not.toBeVisible()
379+
await portalPage.gotoPackage(testPackage, SETTINGS_TAB_USERS)
380+
await expect(noPermissionPlaceholder).toHaveText(NO_PERM_SEE_PAGE)
387381
})
388382
})
389383

0 commit comments

Comments
 (0)