Repository navigation
SSO e2e testing - #12739
SSO e2e testing#12739
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Adds end-to-end Playwright coverage for SSO using a mocked OIDC provider, and adjusts frontend/backend SSO flows to correctly surface and handle “pending provider signup” and SSO failure states (related to #10911).
Changes:
- Add a mock OIDC server + Playwright tests that exercise real SSO redirects and the “provider signup” pending flow.
- Add a new frontend
/provider-signuppage and routing to complete registration when allauth leaves the session in a pending flow. - Tighten SSO enablement handling (backend setting surfaced via server info; backend rejects social login when SSO is disabled).
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/yarn.lock | Adds lock entries for the OIDC mock server dependency chain. |
| src/frontend/tests/pui_sso.spec.ts | New Playwright e2e coverage for SSO login, registration completion, and disabled/closed registration paths. |
| src/frontend/tests/defaults.ts | Adds mock OIDC server URL/port and mock SSO user identity used across config/tests. |
| src/frontend/src/states/UserState.tsx | Captures auth context from failed session checks to support pending-flow routing. |
| src/frontend/src/states/states.tsx | Extends server settings type to include sso_enabled. |
| src/frontend/src/states/ServerApiState.tsx | Makes sso_enabled() respect the server-provided SSO enablement setting. |
| src/frontend/src/states/LocalState.tsx | Improves host resolution to avoid incorrect origin fallback when frontend/backend differ. |
| src/frontend/src/router.tsx | Adds lazy route for the new /provider-signup page. |
| src/frontend/src/pages/Auth/ProviderSignup.tsx | New page to complete SSO registration for users without a local account. |
| src/frontend/src/pages/Auth/LoggedIn.tsx | Surfaces allauth SSO callback errors via notification and redirects to login. |
| src/frontend/src/functions/auth.tsx | Routes to /provider-signup when a pending provider-signup flow is detected; fixes SSO callback URL to use frontend origin + base. |
| src/frontend/src/components/buttons/SSOButton.tsx | Adjusts SSO button behavior to rely on click handler (not anchor component). |
| src/frontend/playwright/mock-oidc-server.mjs | Introduces minimal local OIDC provider for CI/local e2e. |
| src/frontend/playwright.config.ts | Starts mock OIDC server and configures backend to use it for SSO during e2e runs. |
| src/frontend/package.json | Adds oauth2-mock-server dev dependency. |
| src/frontend/lib/types/Auth.tsx | Aligns auth context/flow typing with the flows used for pending provider signup. |
| src/frontend/lib/enums/ApiEndpoints.tsx | Adds auth_provider_signup endpoint constant. |
| src/backend/InvenTree/InvenTree/sso.py | Removes unused provider helper functions. |
| src/backend/InvenTree/InvenTree/auth_overrides.py | Rejects SSO logins via adapter hook when SSO is globally disabled. |
| src/backend/InvenTree/InvenTree/api.py | Exposes sso_enabled in server info settings payload. |
Suppressed comments (1)
src/frontend/tests/pui_sso.spec.ts:109
- This also assumes
user/returns an array. If the API starts returning a paginated envelope, the assertion will crash instead of correctly checking that no user was created. Parse both response shapes for robustness.
const users = await api
.get(`user/?search=${mockSsoUser.username}`)
.then((response) => response.json());
expect(
users.find((user: any) => user.username === mockSsoUser.username)
).toBeUndefined();
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Very intresting that this came up only now. On my deployments users are always pre-staged via an entra provisiong agent so that the fixed path never triggered but I imagine that is an industry specific solution. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12739 +/- ##
==========================================
- Coverage 86.79% 86.77% -0.02%
==========================================
Files 1461 1461
Lines 98012 98022 +10
Branches 11430 11356 -74
==========================================
- Hits 85072 85063 -9
- Misses 12874 12893 +19
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/frontend/src/functions/auth.tsx:486
checkLoginStatesetssetLoginChecked(true)inside the!no_redirectbranch and then callssetLoginChecked(true)again unconditionally at the end of the function. This double update is redundant and can make state changes harder to reason about.
} else if (!no_redirect) {
setLoginChecked(true);
// A user authenticated via SSO, but with no matching local account, is
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

Uh oh!
There was an error while loading. Please reload this page.