-
Notifications
You must be signed in to change notification settings - Fork 461
feat(ui): add OIDC ConfigureSSO wizard skeleton #9200
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
NicolasLopes7
wants to merge
1
commit into
main
Choose a base branch
from
nicolas/oidc-self-serve-configure
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
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,2 @@ | ||
| --- | ||
| --- |
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,2 @@ | ||
| --- | ||
| --- |
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
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
90 changes: 90 additions & 0 deletions
90
packages/ui/src/components/ConfigureSSO/steps/ConfigureStep/__tests__/ConfigureStep.test.tsx
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,90 @@ | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { Flow } from '@/customizables'; | ||
| import { bindCreateFixtures } from '@/test/create-fixtures'; | ||
| import { render, screen } from '@/test/utils'; | ||
| import { CardStateProvider } from '@/ui/elements/contexts'; | ||
|
|
||
| import type { EnterpriseConnectionProviderType } from '../../../types'; | ||
|
|
||
| // The dispatch reads `organizationEnterpriseConnection.provider`. The nested | ||
| // sub-flows also read `enterpriseConnection` (via `Step.Footer.Reset`), which is | ||
| // left undefined so that footer self-hides in this isolated render. | ||
| const contextState = vi.hoisted(() => ({ provider: undefined as string | undefined })); | ||
|
|
||
| vi.mock('../../../ConfigureSSOContext', () => ({ | ||
| useConfigureSSO: () => ({ | ||
| enterpriseConnection: undefined, | ||
| contentRef: { current: null }, | ||
| enterpriseConnectionMutations: {}, | ||
| organizationEnterpriseConnection: { | ||
| provider: contextState.provider, | ||
| hasConnection: true, | ||
| }, | ||
| }), | ||
| })); | ||
|
|
||
| import { ConfigureProviderStep, resolveConfigureSteps } from '../index'; | ||
| import { OidcCustomConfigureSteps } from '../oidc'; | ||
| import { | ||
| SamlCustomConfigureSteps, | ||
| SamlGoogleConfigureSteps, | ||
| SamlMicrosoftConfigureSteps, | ||
| SamlOktaConfigureSteps, | ||
| } from '../saml'; | ||
|
|
||
| const { createFixtures } = bindCreateFixtures('ConfigureSSO'); | ||
|
|
||
| describe('resolveConfigureSteps', () => { | ||
| it('dispatches a derived OIDC provider key to the OIDC sub-flow by prefix (not the oidc_custom literal)', () => { | ||
| // The regression: the backend returns `oidc_<slug>` derived from the connection | ||
| // name (e.g. `clerk.dev` → `oidc_clerk_dev`), never the `oidc_custom` input alias. | ||
| expect(resolveConfigureSteps('oidc_clerk_dev')).toBe(OidcCustomConfigureSteps); | ||
| expect(resolveConfigureSteps('oidc_ghe_acme')).toBe(OidcCustomConfigureSteps); | ||
| expect(resolveConfigureSteps('oidc_gitlab_ent_acme')).toBe(OidcCustomConfigureSteps); | ||
| expect(resolveConfigureSteps('oidc_custom')).toBe(OidcCustomConfigureSteps); | ||
| }); | ||
|
|
||
| it('dispatches SAML providers by exact literal', () => { | ||
| expect(resolveConfigureSteps('saml_okta')).toBe(SamlOktaConfigureSteps); | ||
| expect(resolveConfigureSteps('saml_custom')).toBe(SamlCustomConfigureSteps); | ||
| expect(resolveConfigureSteps('saml_google')).toBe(SamlGoogleConfigureSteps); | ||
| expect(resolveConfigureSteps('saml_microsoft')).toBe(SamlMicrosoftConfigureSteps); | ||
| }); | ||
|
|
||
| it('returns undefined for an unrecognized provider so the caller can degrade', () => { | ||
| expect(resolveConfigureSteps('ldap_enterprise' as EnterpriseConnectionProviderType)).toBeUndefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('ConfigureProviderStep', () => { | ||
| const renderStep = (wrapper: React.ComponentType<{ children?: React.ReactNode }>) => | ||
| render( | ||
| <Flow.Root flow='configureSSO'> | ||
| <CardStateProvider> | ||
| <ConfigureProviderStep /> | ||
| </CardStateProvider> | ||
| </Flow.Root>, | ||
| { wrapper }, | ||
| ); | ||
|
|
||
| it('renders the OIDC configure steps for a derived provider key without throwing', async () => { | ||
| contextState.provider = 'oidc_clerk_dev'; | ||
| const { wrapper } = await createFixtures(); | ||
|
|
||
| renderStep(wrapper); | ||
|
|
||
| // The OIDC sub-flow mounts on its first step. Before the fix this threw | ||
| // `No steps found for provider: oidc_clerk_dev` and white-screened the wizard. | ||
| expect(await screen.findByText(/create a new oidc application/i)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('degrades to the unsupported-provider state for a provider the SDK does not recognize', async () => { | ||
| contextState.provider = 'ldap_enterprise'; | ||
| const { wrapper } = await createFixtures(); | ||
|
|
||
| renderStep(wrapper); | ||
|
|
||
| expect(await screen.findByText(/unsupported provider/i)).toBeInTheDocument(); | ||
| }); | ||
| }); |
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.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Match the guard to the OIDC key contract.
Line 16 classifies
oidcandoidcfooas OIDC even though they do not matchOidcProviderType(oidc_${string}). This can route malformed backend values into the OIDC wizard instead of the unsupported-provider fallback. Require the underscore delimiter and add a regression test.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents