Skip to content

test(e2e): port OIDC authorization tests from e2e/rust to features/oidc-auth #5731

Open

Description

@matthewgrossman

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/keycloak gains password-grant sessions per user. Keycloak publishes the extra users as OPENSHELL_TEST_KEYCLOAK_USER_* and OPENSHELL_TEST_KEYCLOAK_USER_B_*.
  • tests/support/oidc for the PKCE flow, and a browser stand-in that records the authorization URL.

Decisions (11-18)

  • Use a new <base>-oidc tmachine environment that reuses the Keycloak setup. Don't turn OIDC on in the existing Keycloak environment (it would change keycloak-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_overrides role.
  • test(e2e): migrate the Python E2E suites to Rust #5624 adds e2e/rust/tests/oidc_authz.rs with 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_authz moves onto them in features/oidc-auth.

Files deleted

oidc_pkce.rs.

Context

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/support contract table.
  • oidc_pkce.rs is deleted, and every reference to it in wrapper scripts, tasks/*.toml and nextest config is removed.
  • features/oidc-auth has rows in .github/workflows/e2e-suites.yml on the drivers its legacy lane covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

topic:testingUnit, integration, regression, conformance, E2E tests, coverage, flakes, and test infrastructure.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions