-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix permissions and add specs for domain and dp #25782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
173 changes: 173 additions & 0 deletions
173
...i/src/main/resources/ui/playwright/e2e/Features/Permissions/DomainViewPermissions.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| /* | ||
| * Copyright 2025 Collate. | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { expect, Page, test as base } from '@playwright/test'; | ||
| import { PolicyClass } from '../../../support/access-control/PoliciesClass'; | ||
| import { RolesClass } from '../../../support/access-control/RolesClass'; | ||
| import { DataProduct } from '../../../support/domain/DataProduct'; | ||
| import { Domain } from '../../../support/domain/Domain'; | ||
| import { UserClass } from '../../../support/user/UserClass'; | ||
| import { performAdminLogin } from '../../../utils/admin'; | ||
| import { redirectToHomePage } from '../../../utils/common'; | ||
|
|
||
| const adminUser = new UserClass(); | ||
| const testUser = new UserClass(); | ||
| const domain = new Domain(); | ||
| const dataProduct = new DataProduct([domain]); | ||
|
|
||
| let policy: PolicyClass; | ||
| let role: RolesClass; | ||
|
|
||
| const test = base.extend<{ | ||
| page: Page; | ||
| testUserPage: Page; | ||
| }>({ | ||
| page: async ({ browser }, use) => { | ||
| const adminPage = await browser.newPage(); | ||
| try { | ||
| await adminUser.login(adminPage); | ||
| await use(adminPage); | ||
| } finally { | ||
| await adminPage.close(); | ||
| } | ||
| }, | ||
| testUserPage: async ({ browser }, use) => { | ||
| const userPage = await browser.newPage(); | ||
| try { | ||
| await testUser.login(userPage); | ||
| await use(userPage); | ||
| } finally { | ||
| await userPage.close(); | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| test.beforeAll('Setup pre-requests', async ({ browser }) => { | ||
| const { apiContext, afterAction } = await performAdminLogin(browser); | ||
| await adminUser.create(apiContext); | ||
| await adminUser.setAdminRole(apiContext); | ||
| await testUser.create(apiContext); | ||
| await domain.create(apiContext); | ||
| await dataProduct.create(apiContext); | ||
|
|
||
| policy = new PolicyClass(); | ||
| await policy.create(apiContext, [ | ||
| { | ||
| name: 'DenyViewDomainRule', | ||
| resources: ['domain'], | ||
| operations: ['ViewAll', 'ViewBasic'], | ||
| effect: 'deny', | ||
| }, | ||
| { | ||
| name: 'DenyViewDataProductRule', | ||
| resources: ['dataProduct'], | ||
| operations: ['ViewAll', 'ViewBasic'], | ||
| effect: 'deny', | ||
| }, | ||
| ]); | ||
|
|
||
| role = new RolesClass(); | ||
| await role.create(apiContext, [policy.responseData.name]); | ||
|
|
||
| await testUser.patch({ | ||
| apiContext, | ||
| patchData: [ | ||
| { | ||
| op: 'replace', | ||
| path: '/roles', | ||
| value: [ | ||
| { | ||
| id: role.responseData.id, | ||
| type: 'role', | ||
| name: role.responseData.name, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| await afterAction(); | ||
| }); | ||
|
|
||
| test.describe('Domain and Data Product View Permission Denied', () => { | ||
| test('Domain listing page should show permission error', async ({ | ||
| testUserPage, | ||
| }) => { | ||
| await redirectToHomePage(testUserPage); | ||
| await testUserPage.goto('/domain'); | ||
| await testUserPage.waitForLoadState('networkidle'); | ||
|
|
||
| await expect( | ||
| testUserPage.getByTestId('permission-error-placeholder') | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('Data Product listing page should show permission error', async ({ | ||
| testUserPage, | ||
| }) => { | ||
| await redirectToHomePage(testUserPage); | ||
| await testUserPage.goto('/dataProduct'); | ||
| await testUserPage.waitForLoadState('networkidle'); | ||
|
|
||
| await expect( | ||
| testUserPage.getByTestId('permission-error-placeholder') | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('Domain detail page should show permission error', async ({ | ||
| testUserPage, | ||
| }) => { | ||
| const domainFqn = encodeURIComponent( | ||
| domain.responseData.fullyQualifiedName ?? domain.data.name | ||
| ); | ||
| await redirectToHomePage(testUserPage); | ||
| await testUserPage.goto(`/domain/${domainFqn}`); | ||
| await testUserPage.waitForLoadState('networkidle'); | ||
|
|
||
| await expect( | ||
| testUserPage.getByTestId('permission-error-placeholder') | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('Data Product detail page should show permission error', async ({ | ||
| testUserPage, | ||
| }) => { | ||
| const dataProductFqn = encodeURIComponent( | ||
| dataProduct.responseData.fullyQualifiedName ?? dataProduct.data.name | ||
| ); | ||
| await redirectToHomePage(testUserPage); | ||
| await testUserPage.goto(`/dataProduct/${dataProductFqn}`); | ||
| await testUserPage.waitForLoadState('networkidle'); | ||
|
|
||
| await expect( | ||
| testUserPage.getByTestId('permission-error-placeholder') | ||
| ).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test.afterAll('Cleanup', async ({ browser }) => { | ||
| const { apiContext, afterAction } = await performAdminLogin(browser); | ||
|
|
||
| if (role?.responseData?.id) { | ||
| await role.delete(apiContext); | ||
| } | ||
| if (policy?.responseData?.id) { | ||
| await policy.delete(apiContext); | ||
| } | ||
|
|
||
| await dataProduct.delete(apiContext); | ||
| await domain.delete(apiContext); | ||
| await adminUser.delete(apiContext); | ||
| await testUser.delete(apiContext); | ||
| await afterAction(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.