8000 fix(UI): redirect if user is not permissioned to see workspace by Kira-Pilot · Pull Request #6786 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix(UI): redirect if user is not permissioned to see workspace #6786

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

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
Kira-Pilot committed Mar 26, 2023
commit 0a4e0ef1bfcf8f70d9107b40853db210483fdde3
4 changes: 4 additions & 0 deletions site/src/pages/AuditPage/AuditPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe("AuditPage", () => {
const mock = jest.spyOn(CreateDayString, "createDayString")
mock.mockImplementation(() => "a minute ago")

jest.spyOn(API, "checkAuthorization").mockResolvedValue({
readPagePermissions: true,
})

// Mock the entitlements
server.use(
rest.get("/api/v2/entitlements", (req, res, ctx) => {
Expand Down
6 changes: 6 additions & 0 deletions site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const { t } = i18next

// It renders the workspace page and waits for it be loaded
const renderWorkspacePage = async () => {
jest.spyOn(api, "checkAuthorization").mockResolvedValue({
readPagePermissions: true,
})
jest.spyOn(api, "getTemplate").mockResolvedValueOnce(MockTemplate)
jest.spyOn(api, "getTemplateVersionRichParameters").mockResolvedValueOnce([])
renderWithAuth(<WorkspacePage />, {
Expand Down Expand Up @@ -191,6 +194,9 @@ describe("WorkspacePage", () => {
it("updates the parameters when they are missing during update", async () => {
// Setup mocks
const user = userEvent.setup()
jest.spyOn(api, "checkAuthorization").mockResolvedValue({
readPagePermissions: true,
})
jest
.spyOn(api, "getWorkspaceByOwnerAndName")
.mockResolvedValueOnce(MockOutdatedWorkspace)
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacePage/WorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const WorkspacePage: FC = () => {
}

return (
<RequirePermission isFeatureVisible={permissions?.readPagePermissions}>
<RequirePermission isFeatureVisible={permissions.readPagePermissions}>
<ChooseOne>
<Cond condition={workspaceState.matches("error")}>
<div className={styles.error}>
Expand Down
0