-
Notifications
You must be signed in to change notification settings - Fork 91
ENG-3137: Fix viewer users unable to edit assigned systems #7754
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
Open
thabofletcher
wants to merge
5
commits into
main
Choose a base branch
from
ENG-3137/fix-viewer-assigned-system-readonly-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
895a041
ENG-3137: Fix viewer users unable to edit assigned systems
thabofletcher 999f206
Enable alphaRbac flag in Cypress regression test
thabofletcher 556cf47
Add changelog entry for ENG-3137 fix
thabofletcher ac18bc8
Fix import sort order in SystemInformationForm
thabofletcher be19f51
Address review comments on regression test
thabofletcher 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
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,4 @@ | ||
| type: Fixed | ||
| description: Fixed viewer users being unable to edit systems assigned to them due to an ungated read-only permission check | ||
| pr: 7754 | ||
| labels: [] |
87 changes: 87 additions & 0 deletions
87
clients/admin-ui/cypress/e2e/systems/plus/viewer-assigned-system.cy.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,87 @@ | ||
| /** | ||
| * Regression test for ENG-3137: Viewer user can't edit a system assigned to them | ||
| * | ||
| * A viewer user with an assigned system should be able to edit that system. | ||
| * The RBAC commit (8e9788e) introduced a read-only check that only looks at | ||
| * the global SYSTEM_UPDATE scope, ignoring SYSTEM_MANAGER_UPDATE which | ||
| * allows per-system editing for assigned systems. | ||
| */ | ||
| import { | ||
| stubDatasetCrud, | ||
| stubPlus, | ||
| stubSystemCrud, | ||
| stubSystemIntegrations, | ||
| stubSystemVendors, | ||
| stubTaxonomyEntities, | ||
| } from "cypress/support/stubs"; | ||
|
|
||
| import { SYSTEM_ROUTE } from "~/features/common/nav/routes"; | ||
| import { RoleRegistryEnum, ScopeRegistryEnum } from "~/types/api"; | ||
|
|
||
| describe("ENG-3137: Viewer with assigned system should be able to edit", () => { | ||
| beforeEach(() => { | ||
| cy.login(); | ||
| cy.overrideFeatureFlag("alphaRbac", true); | ||
| stubSystemCrud(); | ||
| stubTaxonomyEntities(); | ||
| stubPlus(true); | ||
| cy.intercept("GET", "/api/v1/system", { | ||
| fixture: "systems/systems.json", | ||
| }).as("getSystems"); | ||
| cy.intercept({ method: "POST", url: "/api/v1/system*" }).as( | ||
| "postDictSystem", | ||
| ); | ||
| cy.intercept("/api/v1/config?api_set=false", {}); | ||
| stubDatasetCrud(); | ||
| stubSystemIntegrations(); | ||
| stubSystemVendors(); | ||
| }); | ||
|
|
||
| it("viewer with system_manager:update can edit assigned system", () => { | ||
| // Simulate a viewer who also has system_manager:update for their assigned system | ||
| cy.fixture("login.json").then((body) => { | ||
| const { id: userId } = body.user_data; | ||
| cy.intercept(`/api/v1/user/${userId}/permission`, { | ||
| body: { | ||
| id: userId, | ||
| user_id: userId, | ||
| roles: [RoleRegistryEnum.VIEWER], | ||
| total_scopes: [ | ||
| // Standard viewer scopes | ||
| ScopeRegistryEnum.SYSTEM_READ, | ||
| ScopeRegistryEnum.SYSTEM_MANAGER_READ, | ||
| ScopeRegistryEnum.SYSTEM_MANAGER_UPDATE, | ||
| // Other viewer scopes | ||
| ScopeRegistryEnum.USER_READ, | ||
| ScopeRegistryEnum.ORGANIZATION_READ, | ||
| ], | ||
| }, | ||
| }).as("getUserPermission"); | ||
| }); | ||
|
|
||
| cy.visit(`${SYSTEM_ROUTE}/configure/demo_analytics_system`); | ||
| cy.wait("@getUserPermission"); | ||
|
|
||
| // The form should NOT be read-only for a viewer with system_manager:update | ||
| cy.getByTestId("input-name").should("exist"); | ||
|
|
||
| // Regression guard (ENG-3137): read-only alert should NOT appear | ||
| cy.contains("Read-only access").should("not.exist"); | ||
|
|
||
| // Regression guard (ENG-3137): form fields should be editable, not disabled | ||
| cy.get("fieldset[disabled]").should("not.exist"); | ||
| }); | ||
|
|
||
| it("viewer WITHOUT system_manager:update sees read-only form", () => { | ||
| // Standard viewer without system_manager:update | ||
| cy.assumeRole(RoleRegistryEnum.VIEWER); | ||
|
|
||
| cy.visit(`${SYSTEM_ROUTE}/configure/demo_analytics_system`); | ||
|
|
||
| cy.getByTestId("input-name").should("exist"); | ||
|
|
||
| // This viewer SHOULD see read-only since they have no update permissions | ||
| cy.contains("Read-only access").should("exist"); | ||
| cy.get("fieldset[disabled]").should("exist"); | ||
| }); | ||
| }); | ||
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.
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.