Repository navigation
Description
User Story
As a maintainer retiring e2e/rust, I want the OIDC role and workspace authorization tests on testkit as a small set of table-driven tests, so they run on a Keycloak environment and the 43 near-identical legacy tests become 13.
Description
All 43 tests come from oidc_pkce.rs and move to tests/suites/features/oidc-auth. The browser (PKCE) login runs once; every other test logs in with a password grant through tests/support/keycloak. Role × action pairs become rows of table tests. Merges keep every assertion.
Suggested new tests and the legacy tests each one covers:
| New test | Legacy tests it covers |
|---|---|
pkce_browser_login_persists_session |
The PKCE login helpers (login_identity, assert_pkce_authorization_url, assert_persisted_login) as one test |
user_reports_gateway_validated_identity |
user_can_report_gateway_validated_identity |
platform_admin_smoke |
admin_can_list_sandboxes, admin_can_inspect_gateway, admin_can_list_providers, admin_can_manage_provider, admin_can_create_workspace |
non_admins_denied_platform_actions (table) |
user_cannot_inspect_gateway, user_cannot_create_workspace, user_cannot_delete_workspace, workspace_admin_cannot_{create,delete}_workspace, workspace_admin_cannot_inspect_gateway |
workspace_user_read_access |
workspace_user_can_read_workspace, user_can_list_sandboxes, user_can_list_providers, workspace_admin_can_read_workspace |
sandbox_create_delete_by_role (table) |
admin_can_{create,delete}_sandbox, user_can_{create,delete}_sandbox |
workspace_user_denied_management (table) |
user_cannot_{create,delete}_provider, workspace_user_cannot_manage_members |
workspace_admin_manages_providers_and_members |
workspace_admin_can_{create,delete}_provider, workspace_admin_can_{add,remove}_user_member, membership_removal_revokes_workspace_access |
workspace_admin_cannot_grant_admin |
same name |
cross_workspace_access_denied (table) |
workspace_admin_cannot_read_another_workspace, workspace_admin_cannot_manage_another_workspace_members, workspace_user_cannot_read_another_users_workspace, workspace_user_cannot_list_another_workspace_{sandboxes,providers,members}, workspace_user_cannot_create_sandbox_in_another_workspace (also checks the other workspace has no new sandbox) |
workspace_list_hides_other_workspaces |
workspace_list_hides_another_users_workspace (parse JSON names; also check default is hidden) |
workspace_admin_cannot_manage_another_workspace_providers |
same name (checks redaction and no side effect) |
user_can_resolve_provider_profile_for_sandbox |
same name (imports the profile as admin with cleanup, or the environment publishes it) |
Dropped (each repeats a role × action pair another test asserts; needs approval in #5297): admin_can_delete_workspace, second_workspace_user_cannot_read_first_users_workspace, workspace_admin_can_create_sandbox, workspace_admin_can_delete_sandbox.
All names, providers and workspaces are unique per run and created in a test-owned workspace, not default.
Helpers and environment this PR adds
- An OIDC environment: Keycloak plus a gateway with OIDC enabled and mTLS kept, so testkit connects as it does today (decision C in test(e2e): decide which e2e/rust tests to port and in what order #5297).
tests/support/keycloakgains password-grant sessions per user. Keycloak publishes the extra users asOPENSHELL_TEST_KEYCLOAK_USER_*andOPENSHELL_TEST_KEYCLOAK_USER_B_*.tests/support/oidcfor the PKCE flow, and a browser stand-in that records the authorization URL.
Decisions (11-18)
- Use a new
<base>-oidctmachine environment that reuses the Keycloak setup. Don't turn OIDC on in the existing Keycloak environment (it would changekeycloak-provider-refresh). - The environment sets
[openshell.gateway.mtls_auth] enabled = true. With an OIDC issuer set, the gateway otherwise stops mapping client certificates to users and testkit's own connection loses its user. testkit's certificate user is a platform admin, so setup and cleanup work. - Per-user clients connect with the gateway CA and a bearer token, and no client certificate.
- Denials are checked by gRPC status code. One test checks the CLI's remediation message.
- Gateway settings go through the shared
gateway_overridesrole. - test(e2e): migrate the Python E2E suites to Rust #5624 adds
e2e/rust/tests/oidc_authz.rswith its own per-user client and workspace helpers. This PR owns those helpers (per-user Keycloak client, workspace create/delete with cleanup and membership, JWT claim reading);oidc_authzmoves onto them infeatures/oidc-auth.
Files deleted
oidc_pkce.rs.
Context
- Part of test(e2e): decide which e2e/rust tests to port and in what order #5297. Stacks on test(testkit): share TLS host servers, a gateway settings role and the environment contract table #5728 (TLS host servers,
gateway_overridesrole, contract table). PR4 (test(e2e): port CLI exec, attach, and SSH host identity tests to testkit #5442) is merged; PR3 (test(e2e): port provider tests from e2e/rust to testkit #5657,create_provider/ProviderBuilder) is open, so merge it in if it hasn't landed. - Waits on decision C in test(e2e): decide which e2e/rust tests to port and in what order #5297 (the OIDC environment keeps mTLS). The four drops wait on decision D.
- Cost of decision C: no test may assume OIDC is the only way in. An OIDC-only mode for testkit is added later only if a test needs it.
Definition of Done
- All 43 legacy tests are covered by the 13 tests above or dropped as listed, with the drops approved in test(e2e): decide which e2e/rust tests to port and in what order #5297.
- Each new environment variable has a row in the
tests/supportcontract table. -
oidc_pkce.rsis deleted, and every reference to it in wrapper scripts,tasks/*.tomland nextest config is removed. -
features/oidc-authhas rows in.github/workflows/e2e-suites.ymlon the drivers its legacy lane covered.
Activity