-
Notifications
You must be signed in to change notification settings - Fork 980
feat: condition Audit log on licensing #3685
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
Changes from 1 commit
aced91f
49f5652
a641881
4e79b2d
6dfe4df
17d8d1b
8fdc834
3627ef3
8b88265
4fea785
733954b
fc237a0
cb20ccd
75f7f6e
2e94269
3c54e1e
4d40c30
a26786e
a7d836b
4f975b8
9505faa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,41 +15,55 @@ import { server } from "testHelpers/server" | |
*/ | ||
describe("Navbar", () => { | ||
it("shows Audit Log link when permitted and entitled", async () => { | ||
// set entitlements to allow audit log | ||
server.use( | ||
rest.get("/api/v2/entitlements", (req, res, ctx) => { | ||
return res(ctx.status(200), ctx.json(MockEntitlementsWithAuditLog)) | ||
}), | ||
) | ||
render(<App />) | ||
await waitFor(() => { | ||
const link = screen.getByText(Language.users) // TODO change after debugging | ||
expect(link).toBeDefined() | ||
}, { timeout: 10000 }) | ||
await waitFor( | ||
() => { | ||
const link = screen.getByText(Language.audit) | ||
expect(link).toBeDefined() | ||
}, | ||
{ timeout: 5000 }, | ||
) | ||
}) | ||
|
||
it("does not show Audit Log link when not entitled", async () => { | ||
// by default, user is an Admin with permission to see the audit log, | ||
// but is unlicensed so not entitled to see the audit log | ||
render(<App />) | ||
await waitFor(() => { | ||
const link = screen.queryByText(Language.audit) | ||
expect(link).toBe(null) | ||
}) | ||
await waitFor( | ||
() => { | ||
const link = screen.queryByText(Language.audit) | ||
expect(link).toBe(null) | ||
}, | ||
{ timeout: 5000 }, | ||
) | ||
}) | ||
|
||
it("does not show Audit Log link when not permitted via role", async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with this test. How does one know that a member is not permitted? I see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
// set permissions to Member (can't audit) | ||
server.use( | ||
rest.post(`/api/v2/users/${MockUser.id}/authorization`, async (req, res, ctx) => { | ||
return res(ctx.status(200), ctx.json(MockMemberPermissions)) | ||
}), | ||
) | ||
// set entitlements to allow audit log | ||
server.use( | ||
rest.get("/api/v2/entitlements", (req, res, ctx) => { | ||
return res(ctx.status(200), ctx.json(MockEntitlementsWithAuditLog)) | ||
}), | ||
) | ||
render(<App />) | ||
await waitFor(() => { | ||
const link = screen.queryByText(Language.audit) | ||
expect(link).toBe(null) | ||
}) | ||
await waitFor( | ||
() => { | ||
const link = screen.queryByText(Language.audit) | ||
expect(link).toBe(null) | ||
}, | ||
{ timeout: 5000 }, | ||
) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this code, how does one know Audit Log link is not entitled? Is it due to the lack of the mocked request or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the default handler in
handlers.ts
returns empty license data, as if you're an OSS user.