mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-02 10:18:42 +00:00
SSO e2e testing (#12739)
* Extend SSO auth workflows * SSO e2e testing workflow * Remove orphaned code * Add unit tests for SSO * improved error messaging * Add test for SSO registration disabled * Fix gating on LOGIN_ENABLE_SSO * Adjust UI state management * Add playwright test for SSO disabled * Add backend unit tests * Adjust API version * Additional playwright tests * Retain desired page state on login failure * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Adjust test code * Stricter matcher checking --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
69afe7723f
commit
a205717171
@@ -1,5 +1,7 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
import { mockOidcPort, mockSsoUser } from './tests/defaults';
|
||||
|
||||
// Detect if running in CI
|
||||
const IS_CI = !!process.env.CI;
|
||||
|
||||
@@ -79,6 +81,23 @@ export default defineConfig({
|
||||
stderr: 'pipe',
|
||||
timeout: 120 * 1000
|
||||
},
|
||||
// Mock OIDC provider - see tests/pui_sso.spec.ts
|
||||
{
|
||||
command: 'node ./playwright/mock-oidc-server.mjs',
|
||||
env: {
|
||||
MOCK_OIDC_PORT: String(mockOidcPort),
|
||||
MOCK_OIDC_SUB: mockSsoUser.sub,
|
||||
MOCK_OIDC_USERNAME: mockSsoUser.username,
|
||||
MOCK_OIDC_EMAIL: mockSsoUser.email,
|
||||
MOCK_OIDC_FIRST_NAME: mockSsoUser.firstName,
|
||||
MOCK_OIDC_LAST_NAME: mockSsoUser.lastName
|
||||
},
|
||||
url: `http://localhost:${mockOidcPort}/.well-known/openid-configuration`,
|
||||
reuseExistingServer: IS_CI,
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
timeout: 60 * 1000
|
||||
},
|
||||
{
|
||||
command: 'invoke dev.server -a 0.0.0.0:8000',
|
||||
env: {
|
||||
@@ -93,7 +112,27 @@ export default defineConfig({
|
||||
INVENTREE_LOGIN_ATTEMPTS: '3',
|
||||
INVENTREE_PLUGINS_MANDATORY: 'samplelocate',
|
||||
INVENTREE_CUSTOM_SPLASH: 'img/playwright_custom_splash.png',
|
||||
INVENTREE_CUSTOM_LOGO: 'img/playwright_custom_logo.png'
|
||||
INVENTREE_CUSTOM_LOGO: 'img/playwright_custom_logo.png',
|
||||
// Dummy mail config - only needed to satisfy the "is email
|
||||
// configured" gate on registration/SSO-signup; nothing here ever
|
||||
// needs to actually be delivered, and send failures are swallowed.
|
||||
INVENTREE_EMAIL_HOST: 'localhost',
|
||||
INVENTREE_EMAIL_SENDER: 'noreply@example.org',
|
||||
// Register the mock OIDC provider from above as a real SSO backend
|
||||
INVENTREE_SOCIAL_BACKENDS: 'openid_connect',
|
||||
INVENTREE_SOCIAL_PROVIDERS: JSON.stringify({
|
||||
openid_connect: {
|
||||
APPS: [
|
||||
{
|
||||
provider_id: 'mock',
|
||||
name: 'Mock SSO',
|
||||
client_id: 'playwright-mock-client',
|
||||
secret: 'playwright-mock-secret',
|
||||
settings: { server_url: `http://localhost:${mockOidcPort}` }
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
},
|
||||
url: 'http://localhost:8000/api/',
|
||||
reuseExistingServer: IS_CI,
|
||||
|
||||
Reference in New Issue
Block a user