-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: expose dynamic client registration in deployment settings #27480
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
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
c0472a8
feat(site): add OAuth2 dynamic client registration toggle to deployme…
BobbyHo 5eaecb1
test(site): cover the new oauth2 provider settings API and query helpers
BobbyHo af8db90
refactor(site): adopt designer mockup for the DCR setting
BobbyHo 5c03561
refactor(site): move DynamicClientRegistrationSetting to its own file
BobbyHo 659cfa4
test(site): co-locate DynamicClientRegistrationSetting stories
BobbyHo 61711b0
refactor(site): use ConfirmDialog for the DCR confirmation
BobbyHo 5a726d6
feat(site): add loading and pending states to the DCR setting
BobbyHo bd0231a
fix(site): close the DCR dialog when the setting is enabled elsewhere
BobbyHo b0cba2f
feat(site): link the OAuth2 settings tab to a query param
BobbyHo 9ca7db2
Merge branch 'main' into coder-eng-3062-dcr-flag-ui
BobbyHo 595bc63
fix(site): stop the DCR dialog reopening without user action
BobbyHo 8bdf4a1
fix(site): name the consequences in the DCR confirmation dialog
BobbyHo 45baa4c
fix(site): explain why the DCR buttons are disabled
BobbyHo c068c40
fix(site): say what disabling DCR does not undo
BobbyHo c2158c7
fix(site): keep the DCR button focusable while a request is in flight
BobbyHo a49c0cd
docs: add the web UI route to the DCR section
BobbyHo 4177fcb
Merge branch 'main' into coder-eng-3062-dcr-flag-ui
BobbyHo 0560e77
fix(site): scope the settings error to the settings tab
BobbyHo 754b1a6
fix(site): follow the ConfirmDialog move to components/Dialog
BobbyHo 90292cd
fix(site): group the settings props and scope the header action
BobbyHo 0ea5890
test(site): assert the settings invalidation spares app queries
BobbyHo 6bca8be
fix(site): address review nits on the DCR setting
BobbyHo 3ededdc
refactor(site): follow module naming and trim restating comments
BobbyHo c0132af
docs: document removing an OAuth2 application
BobbyHo 52f3630
fix(site): seed the settings cache from the save response
BobbyHo d1e4a82
fix(site): separate the settings load and update errors
BobbyHo a046ef3
test(site): end the simulated transitions on demand, not on a timer
BobbyHo 5533491
fix(site): return focus to the setting button when the dialog closes
BobbyHo ad99fd3
fix(site): move the apps error into its tab and close four test gaps
BobbyHo b1bd105
feat(site): link the docs and name the registration endpoint
BobbyHo cecf2bc
feat(site): add a retry action to the OAuth2 settings tab
BobbyHo c98592c
test(site): cover the OAuth2 settings permission gates
BobbyHo 036c528
fix(site): stop pointing the DCR caveat at the Applications tab
BobbyHo f728c50
refactor(site): tighten the OAuth2 settings page seams
BobbyHo ba1bdf0
Merge branch 'main' into coder-eng-3062-dcr-flag-ui
BobbyHo 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { API } from "#/api/api"; | ||
| import type * as TypesGen from "#/api/typesGenerated"; | ||
| import { createTestQueryClient } from "#/testHelpers/renderHelpers"; | ||
| import { getSettings, oauth2ProviderAppKey, putSettings } from "./oauth2"; | ||
|
|
||
| vi.mock("#/api/api", () => ({ | ||
| API: { | ||
| getOAuth2ProviderSettings: vi.fn(), | ||
| putOAuth2ProviderSettings: vi.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| const settings: TypesGen.OAuth2ProviderSettings = { | ||
| dynamic_client_registration_enabled: true, | ||
| }; | ||
|
|
||
| describe("getSettings", () => { | ||
| it("fetches settings via the API client", async () => { | ||
| const getSettingsMock = vi.mocked(API.getOAuth2ProviderSettings); | ||
| getSettingsMock.mockResolvedValue(settings); | ||
|
|
||
| const result = await getSettings().queryFn(); | ||
|
|
||
| expect(getSettingsMock).toHaveBeenCalled(); | ||
| expect(result).toEqual(settings); | ||
| }); | ||
| }); | ||
|
|
||
| describe("putSettings", () => { | ||
| it("delegates directly to the API client", async () => { | ||
| const putSettingsMock = vi.mocked(API.putOAuth2ProviderSettings); | ||
| putSettingsMock.mockResolvedValue(settings); | ||
| const queryClient = createTestQueryClient(); | ||
|
|
||
| const result = await putSettings(queryClient).mutationFn(settings); | ||
|
|
||
| expect(putSettingsMock).toHaveBeenCalledWith(settings); | ||
| expect(result).toEqual(settings); | ||
| }); | ||
|
|
||
| // `invalidateQueries` matches by key prefix, so asserting the settings key | ||
| // was invalidated says nothing about what else went with it. Seeding an app | ||
| // query alongside it is what catches a widened invalidation scope, which | ||
| // would refetch every app on every settings save. | ||
| it("invalidates the settings query without touching app queries", async () => { | ||
| const queryClient = createTestQueryClient(); | ||
| const settingsQueryKey = getSettings().queryKey; | ||
| const appQueryKey = oauth2ProviderAppKey("app-1"); | ||
| queryClient.setQueryData(settingsQueryKey, { | ||
| dynamic_client_registration_enabled: false, | ||
| }); | ||
| queryClient.setQueryData(appQueryKey, { id: "app-1" }); | ||
|
|
||
| await putSettings(queryClient).onSuccess(settings); | ||
|
|
||
| expect(queryClient.getQueryState(settingsQueryKey)?.isInvalidated).toBe( | ||
| true, | ||
| ); | ||
| expect(queryClient.getQueryState(appQueryKey)?.isInvalidated).toBe(false); | ||
| }); | ||
|
|
||
| // Invalidating resolves whether or not the refetch that follows succeeds, and | ||
| // a failed refetch keeps the query's last successful data. Seeding the cache | ||
| // from the response the server just returned is what stops a successful save | ||
| // from rendering the pre-save value under an error alert. | ||
| it("writes the saved value into the cache", async () => { | ||
| const queryClient = createTestQueryClient(); | ||
| const settingsQueryKey = getSettings().queryKey; | ||
| queryClient.setQueryData(settingsQueryKey, { | ||
| dynamic_client_registration_enabled: false, | ||
| }); | ||
|
|
||
| await putSettings(queryClient).onSuccess({ | ||
| dynamic_client_registration_enabled: true, | ||
| }); | ||
|
|
||
| expect(queryClient.getQueryData(settingsQueryKey)).toEqual({ | ||
| dynamic_client_registration_enabled: true, | ||
| }); | ||
| }); | ||
| }); |
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.