Skip to content

feat(test): multi-tenant E2E tests — MVP validation criteria #1-4, #6-8 - #1480

Closed
pdettori wants to merge 2 commits into
rossoctl:mainfrom
pdettori:feat/openshell-e2e-multitenant-1362
Closed

pdettori wants to merge 2 commits into
rossoctl:mainfrom
pdettori:feat/openshell-e2e-multitenant-1362

Conversation

@pdettori

@pdettori pdettori commented May 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Test plan

  • pytest -m mvp collects all MVP-tagged tests
  • pytest kagenti/tests/e2e/openshell/test_12_tenant_isolation.py --collect-only shows 20 tests
  • CI workflow e2e-openshell-kind.yaml runs with 2 tenants deployed
  • Tenant isolation auth tests pass with OIDC-enabled gateways
  • RBAC tests verify namespace scoping via kubectl auth can-i

Closes #1362
Deferred criteria (#5, #9, #10, #11) tracked in #1479

Assisted-By: Claude Code

Add tenant isolation tests covering MVP criteria rossoctl#6-8:
- Auth isolation: JWT audience-based rejection across tenants
- RBAC isolation: ServiceAccount namespace scoping validation
- Credential isolation: provider secret and ConfigMap separation

Add sandbox connectivity tests for MVP criterion rossoctl#2:
- Gateway pod/service/port-forward reachability
- kubectl exec into sandbox pods (interactive session capability)

Tag existing tests (sandbox lifecycle rossoctl#1, OPA enforcement rossoctl#3,
credential security rossoctl#4) with the `mvp` marker for filtered runs.

Register `mvp` pytest marker in conftest.py.

Closes rossoctl#1362
Deferred criteria tracked in rossoctl#1479

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori

pdettori commented May 6, 2026

Copy link
Copy Markdown
Member Author

/run-e2e-openshell

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @pdettori
Commit: 44c8793a487d4d541e70ed234ce4a5e7806b6dbe
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

Fixes CodeQL alert "Binding a socket to all network interfaces"
by using 127.0.0.1 instead of empty string (all interfaces).
Port-forward tests only need localhost connectivity.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: 24cb3de

For maintainers: Please review the new changes and comment /run-e2e to trigger E2E tests.

Security checklist

Before running E2E tests, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

This is an automated security measure to prevent TOCTOU attacks

@pdettori

pdettori commented May 6, 2026

Copy link
Copy Markdown
Member Author

/run-e2e-openshell

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @pdettori
Commit: 24cb3de191bd531b259c525038e869b113b01720
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: 44c8793a487d4d541e70ed234ce4a5e7806b6dbe
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

❌ [Experimental] OpenShell E2E Tests Failed

Commit: 24cb3de191bd531b259c525038e869b113b01720
Workflow: View logs


Non-voting. Re-run: /run-e2e-openshell

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

❌ [Experimental] OpenShell E2E Tests Failed

Commit: 44c8793a487d4d541e70ed234ce4a5e7806b6dbe
Workflow: View logs


Non-voting. Re-run: /run-e2e-openshell

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: 24cb3de191bd531b259c525038e869b113b01720
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@pdettori

pdettori commented May 6, 2026

Copy link
Copy Markdown
Member Author

/run-e2e-openshell

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @pdettori
Commit: 24cb3de191bd531b259c525038e869b113b01720
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: 24cb3de191bd531b259c525038e869b113b01720
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

❌ [Experimental] OpenShell E2E Tests Failed

Commit: 24cb3de191bd531b259c525038e869b113b01720
Workflow: View logs


Non-voting. Re-run: /run-e2e-openshell

@pdettori pdettori reopened this May 7, 2026
huang195 pushed a commit to huang195/kagenti-extensions that referenced this pull request May 7, 2026
…polling

Replace the fire-once 60s poll for credential files with a continuous
polling mechanism that never gives up. This fixes transient 401 errors
in CI when the client-registration sidecar takes longer than 60s to
write /shared/client-id.txt and /shared/client-secret.txt.

Changes:
- ResolveCredentialFiles now returns a ready channel and polls with
  exponential backoff (5s→60s) after the initial timeout expires
- Add configurable credential_wait_timeout (default 120s)
- Return 503 (not silent 401) when identity is not yet loaded
- Add /healthz and /readyz HTTP endpoints on port 9091 for
  Kubernetes readiness probes

Fixes: rossoctl/rossoctl#1480

Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@Ladas Ladas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security & Code Review

Scope: 6 files, +866/-4 — new multi-tenant E2E tests for tenant isolation (criteria #6-8) and sandbox connectivity (criterion #2).

Security Assessment: PASS

  • Subprocess safety: All subprocess.run and subprocess.Popen calls use list-form arguments (no shell=True on untrusted input). The single sh -c usage has a hardcoded command string.
  • Test credentials: alice123/bob123 are intentional well-known fixtures for local Keycloak test users — not production secrets.
  • JWT handling: _decode_jwt_payload skips signature verification but is explicitly test-only, properly scoped and commented. Not copy-paste-dangerous.
  • Environment variables: TENANT_1/TENANT_2 flow into kubectl as list arguments (not through a shell) — no injection vector even with malicious values.

Code Review: PASS

  • Comprehensive tenant isolation coverage: JWT audience rejection, RBAC namespace scoping, credential isolation.
  • test_13_sandbox_connectivity.py validates gateway health, kubectl exec, and terminal session capability — solid coverage of criterion #2.
  • mvp pytest marker is a nice organizational touch for running MVP-focused test suites.
  • Consistent use of the kubectl_run helper from conftest.py (list-form subprocess) throughout.

Note: This PR has merge conflicts that need resolving before merge.

No security vulnerabilities found.

Assisted-By: Claude Code

huang195 added a commit that referenced this pull request May 7, 2026
…ealm

Root cause of the HyperShift E2E 401s on PR #1481 (and other PRs that
happened to race the operator's ClientRegistrationReconciler): the test
token had no `aud` claim because the Keycloak realm scope that carries
the audience mapper (`agent-team1-weather-service-aud`) was not yet
present when `87-setup-test-credentials.sh` queried for it. The fixture
logged "No agent audience scopes found (agents may not be deployed yet)"
and moved on, attaching nothing to `kagenti-e2e-tests`. The subsequent
`client_credentials` token therefore contained no `aud`, and AuthBridge's
`jwt-validation` plugin rejected every inbound request with "audience is
required (prevents confused deputy attacks)" → 401.

The scope is created asynchronously by kagenti-operator's
ClientRegistrationReconciler (default path) or the legacy
client-registration sidecar (opt-in). Neither is synchronous with the
weather-service Deployment admission, so the fixture and the scope
creator race.

This change gates the fixture on the observable output of that
reconciler — scope presence in realm `default-default-client-scopes` —
rather than orchestrating startup timing.

Changes:
- 87-setup-test-credentials.sh: when agent deployments exist in team1,
  poll the realm for at least one agent-*-aud scope before attaching.
  Default timeout 300s; SCOPE_WAIT_TIMEOUT env var overrides. Admin
  token is refreshed each iteration (master-realm admin tokens live
  ~60s). Happy path pays ~0s (first iteration finds scopes).
- tests/conftest.py: extract token acquisition into `_acquire_agent_token`
  and expose a new `keycloak_agent_token_refresh` fixture that returns a
  zero-arg callable minting a fresh token. Existing `keycloak_agent_token`
  keeps its session-scope cache behavior; the refresh fixture is there so
  tests can pick up a freshly-scoped token if a future race puts scope
  attachment after the session fixture cached its tokenless-of-aud value.
  Not wired into tests in this PR; left as follow-up pending observation.

Verification plan:
- Green Kind E2E with artificial operator stall: add sleep 60 in
  74-deploy-weather-agent.sh, verify wait loop kicks in and proceeds
  once scope appears.
- HyperShift re-run via /run-e2e on a PR to confirm: expected log
  sequence is "Waiting up to 300s for agent-*-aud scopes..." followed
  by "Agent audience scope(s) detected after Ns" within ~6 min, then
  "Added scope 'agent-team1-weather-service-aud' to kagenti-e2e-tests".
- Regression check on a healthy cluster: expect ~0s detection time, no
  measurable slowdown on the happy path.

Refs: issue seen on #1480, #1481.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Maintainer reviewed - safe to run E2E tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat: E2E tests — multi-tenant OpenShell validation

3 participants