Skip to content

Commit eee2b9f

Browse files
test(conformance): port the credential gating e2e tests (#5318)
* feat(testkit): create a sandbox with a policy, an image, and providers Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(conformance): port the credential gating e2e tests Port the six credential gating scenarios from e2e/rust/tests/credential_gating.rs into a conformance suite. Each test imports its own provider profile and creates a provider under a run-unique name, creates sandboxes from the Python test image through the CLI, and reaches probe servers on the host through host.openshell.internal. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(e2e): provide the Python test image to host-lane conformance The conformance suite now creates sandboxes from testkit::python_image(). Docker and Podman runners build openshell/e2e-python:dev also in e2e-conformance-only mode, and the Kubernetes and VM runners default OPENSHELL_TEST_PYTHON_IMAGE to the pullable uv Python image. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(e2e): remove the credential gating tests ported to conformance Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(testkit): add policy helpers, provider install, and YAML files Add testkit::policy (a base policy from base-policy.yaml, allow(), and Endpoint settings), install_provider(), YamlFile, ExecOutput::success(), and PYTHON_BINARIES, so suites build policies and providers the same way. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(support): add host servers that record what sandboxes send Add host-server-support with HttpRecorder and WebSocketRecorder, servers on the test host that sandboxes reach through host.openshell.internal. Move the host-gateway feature test onto them and onto testkit's base policy. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(conformance): build credential gating on shared test support Use testkit's policy helpers and install_provider and host-server-support's recorders, and assert on the requests that reached the host server instead of verdicts the sandbox clients print. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(e2e): pass the host gateway IP to the external Kubernetes driver The external-driver lane renders server.hostGatewayIP, but only the in-process driver reads it from the gateway TOML. The standalone driver takes OPENSHELL_HOST_GATEWAY_IP, which the post-renderer never set, so sandbox policy DNS refused host.openshell.internal on that lane. Copy the chart's rendered value into the driver container when present. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(testkit): default python_image() to a public pinned image Conformance has to run against any gateway, and the unpublished openshell/e2e-python:dev image only exists where a lane built or loaded it. Default to the pinned uv Python image, which any gateway can pull, and keep OPENSHELL_TEST_PYTHON_IMAGE as the override. Host lanes no longer build the workload image for conformance. The base test policy names no workload user, so drivers use a default non-root user on images without one, and host_gateway runs python3 from PATH. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(conformance): tighten credential gating checks from review - The WebSocket recorder reads frames until the connection ends, and the test waits for that before checking that no binary frame arrived. - The HTTP recorder keeps the request head and body apart. The REST tests compare the body exactly and check the secret appears nowhere, and failure messages redact it. - testkit errors keep the gateway's gRPC status code, and the admission test checks for FailedPrecondition. - The policy create request destructures the SDK spec, so a new field fails to compile instead of being dropped. - host_gateway no longer retries its connection. - Docs state that conformance requires sandboxes to reach the test machine as host.openshell.internal. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(testkit): restore openshell/e2e-python:dev as the default test image The tmachine installers load it and the Docker and Podman lanes build it, so those lanes don't pull an image inside a test's timeout or lose curl, git and openssl. The Kubernetes and VM lanes keep using the pinned public image through OPENSHELL_TEST_PYTHON_IMAGE, and the base test policy names the sandbox user again. Running conformance against any gateway without an override is left to a follow-up. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(conformance): add a positive control to the WebSocket denial test The test passed whenever no binary frame reached upstream, whatever the reason. It now first sends the same frame from a sandbox without the provider and requires that it arrives, so the denial check can fail. Unit tests check that WebSocketRecorder sees a binary frame after a long text frame, and none among text frames. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * docs(testing): link the remote-cluster follow-up for credential gating Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(test-support): derive the WebSocket accept key with tungstenite Use tungstenite's derive_accept_key instead of hashing with sha1 and base64 directly, and split host-server into http.rs and websocket.rs. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(e2e): fail the external-driver render when the host gateway alias is missing The post-renderer copied the host gateway IP whenever the chart rendered any hostAliases. It now matches the host.openshell.internal entry, and fails if the lane set server.hostGatewayIP but no such entry rendered. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * test(testkit): split provider install into profile import and provider create import_profile reads the profile's id from its YAML and returns it, and create_provider takes the provider name and type separately, so the provider name no longer has to match the profile id. install_provider does both. Document that policy::allow merges binaries under one name and that an override Python image must use a PYTHON_BINARIES path. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * refactor(testkit): make the provider helpers Context methods testkit creates things through Context methods, such as cx.sandbox(..) and cx.on_cleanup(..), so import_profile, create_provider and install_provider become cx methods instead of free functions. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> --------- Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent f62fa13 commit eee2b9f

39 files changed

Lines changed: 2289 additions & 1244 deletions

‎TESTING.md‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,14 @@ Suites:
438438

439439
- Common suite (`--features e2e`) - driver-neutral CLI behavior, sandbox lifecycle, sync, port forwarding, policy, and provider tests.
440440
- Conformance (`tests/suites/conformance`) - the testkit `conformance` crate:
441-
lifecycle, the CLI, persistent workspaces, file transfer, and the policy
442-
advisor. Driver E2E runs it with `openshell-conformance` against the lane's
443-
gateway and writes a JUnit report under `results/`; set
444-
`OPENSHELL_CONFORMANCE_BIN` to use a prebuilt program, as Branch E2E does
445-
with the static build it makes once per architecture. The
441+
lifecycle, the CLI, persistent workspaces, file transfer, the policy
442+
advisor, and credential gating. Driver E2E runs it with
443+
`openshell-conformance` against the lane's gateway and writes a JUnit report
444+
under `results/`; set `OPENSHELL_CONFORMANCE_BIN` to use a prebuilt program,
445+
as Branch E2E does with the static build it makes once per architecture.
446+
The Docker and Podman runners build `openshell/e2e-python:dev` for it; the
447+
Kubernetes and VM runners set `OPENSHELL_TEST_PYTHON_IMAGE` to a pullable
448+
Python image unless it is already set. The
446449
installed-artifact conformance lanes run the same crate through
447450
`openshell-test-runner` (see above).
448451
- Driver suites (`--features e2e-docker`, `e2e-podman`, `e2e-kubernetes`, or
@@ -670,6 +673,10 @@ explains the isolation backend separation behind the capability-free runtime.
670673
On a **remote** cluster, drop the `e2e-host-gateway` feature. Those tests rely
671674
on the sandbox-side `host.openshell.internal` alias reaching the machine running
672675
the tests, which is unreachable from pods on a remote cluster, so they fail.
676+
The conformance suite's `credential_gating` tests need the alias to reach that
677+
machine too, and the feature selection doesn't skip them, so they fail on a
678+
remote cluster. [#5409](https://github.com/NVIDIA/OpenShell/issues/5409)
679+
tracks handling that.
673680
Left enabled, the `host_gateway_alias` suite fails because
674681
`host.openshell.internal` does not resolve inside the pod, so the gateway
675682
SSRF-denies the request (`DNS resolution failed` / `ssrf_denied`) — a networking
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: apps/v1
5+
kind: StatefulSet
6+
metadata:
7+
name: openshell
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: kubernetes-compute-driver
13+
env:
14+
- name: OPENSHELL_HOST_GATEWAY_IP
15+
value: replaced-by-kustomize
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# The in-process driver reads server.hostGatewayIP from the rendered gateway
5+
# TOML. The external driver reads it from its own environment, so copy the
6+
# chart's rendered value into that container.
7+
apiVersion: kustomize.config.k8s.io/v1alpha1
8+
kind: Component
9+
patches:
10+
- path: driver-env-patch.yaml
11+
target:
12+
group: apps
13+
version: v1
14+
kind: StatefulSet
15+
name: openshell
16+
replacements:
17+
- source:
18+
group: apps
19+
version: v1
20+
kind: StatefulSet
21+
name: openshell
22+
fieldPath: spec.template.spec.hostAliases.0.ip
23+
targets:
24+
- select:
25+
group: apps
26+
version: v1
27+
kind: StatefulSet
28+
name: openshell
29+
fieldPaths:
30+
- spec.template.spec.containers.[name=kubernetes-compute-driver].env.[name=OPENSHELL_HOST_GATEWAY_IP].value

‎e2e/helm-plugins/openshell-external-compute-driver/post-renderer.sh‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,18 @@ cp "${plugin_dir}/kustomization.yaml" "${work_dir}/kustomization.yaml"
1616
cp "${plugin_dir}/workload-patch.yaml" "${work_dir}/workload-patch.yaml"
1717
tee "${work_dir}/rendered.yaml" >/dev/null
1818

19+
# server.hostGatewayIP renders the gateway pod's only hostAliases entry
20+
# (deploy/helm/openshell/templates/_gateway-workload.tpl), which the
21+
# host-gateway component copies from hostAliases.0.ip. The lane exports
22+
# OPENSHELL_E2E_EXPECTED_HOST_GATEWAY_IP when it sets server.hostGatewayIP, so
23+
# a chart change that moves the alias fails here instead of leaving the
24+
# external driver without the IP.
25+
if grep -q '^ *- host\.openshell\.internal$' "${work_dir}/rendered.yaml"; then
26+
cp -R "${plugin_dir}/host-gateway" "${work_dir}/host-gateway"
27+
printf 'components:\n - host-gateway\n' >>"${work_dir}/kustomization.yaml"
28+
elif [ -n "${OPENSHELL_E2E_EXPECTED_HOST_GATEWAY_IP:-}" ]; then
29+
echo "ERROR: server.hostGatewayIP is set, but the rendered chart has no host.openshell.internal hostAliases entry." >&2
30+
exit 1
31+
fi
32+
1933
kubectl kustomize "${work_dir}"

‎e2e/rust/Cargo.toml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ name = "websocket_conformance"
204204
path = "tests/websocket_conformance.rs"
205205
required-features = ["e2e-host-gateway"]
206206

207-
[[test]]
208-
name = "credential_gating"
209-
path = "tests/credential_gating.rs"
210-
required-features = ["e2e-host-gateway"]
211-
212207
[[test]]
213208
name = "user_namespaces"
214209
path = "tests/user_namespaces.rs"

‎e2e/rust/e2e-docker.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ if [ "${1:-}" = "${RUN_WITH_GATEWAY_COMMAND}" ]; then
5454
exit 0
5555
fi
5656

57-
if [ "${E2E_FEATURES}" != "e2e-conformance-only" ]; then
58-
CONTAINER_ENGINE=docker bash "${ROOT}/tasks/scripts/e2e-build-workload.sh"
59-
fi
57+
# The conformance suite runs on every lane, including e2e-conformance-only,
58+
# and creates sandboxes from this image (testkit::python_image()).
59+
CONTAINER_ENGINE=docker bash "${ROOT}/tasks/scripts/e2e-build-workload.sh"
6060

6161
exec "${ROOT}/e2e/with-docker-gateway.sh" \
6262
bash "${BASH_SOURCE[0]}" "${RUN_WITH_GATEWAY_COMMAND}"

‎e2e/rust/e2e-kubernetes.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ run_conformance() {
8080
fi
8181

8282
OPENSHELL_CONFORMANCE_JUNIT="${OPENSHELL_CONFORMANCE_JUNIT:-${ROOT}/results/${OPENSHELL_E2E_REPORT_NAME:-e2e-kubernetes}-conformance.xml}" \
83+
OPENSHELL_TEST_PYTHON_IMAGE="${OPENSHELL_TEST_PYTHON_IMAGE:-${E2E_PULLABLE_PYTHON_IMAGE}}" \
8384
e2e_run_openshell_conformance "Kubernetes"
8485
}
8586

‎e2e/rust/e2e-podman.sh‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ PODMAN_CI_TESTS=(
2525
bypass_detection
2626
ephemeral_cleanup
2727
core_dump_hardening
28-
credential_gating
2928
default_image
3029
driver_config_volume
3130
edge_tunnel_e2e
@@ -117,9 +116,9 @@ if [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ] && [ -z "${OPENSHELL_BIN:-}" ]; then
117116
export OPENSHELL_BIN="${ROOT}/target/debug/openshell"
118117
fi
119118

120-
if [ "${E2E_FEATURES}" != "e2e-conformance-only" ]; then
121-
CONTAINER_ENGINE=podman bash "${ROOT}/tasks/scripts/e2e-build-workload.sh"
122-
fi
119+
# The conformance suite runs on every lane, including e2e-conformance-only,
120+
# and creates sandboxes from this image (testkit::python_image()).
121+
CONTAINER_ENGINE=podman bash "${ROOT}/tasks/scripts/e2e-build-workload.sh"
123122

124123
exec "${ROOT}/e2e/with-podman-gateway.sh" \
125124
bash "${BASH_SOURCE[0]}" "${RUN_WITH_GATEWAY_COMMAND}"

‎e2e/rust/e2e-vm.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ e2e_export_gateway_restart_metadata \
463463
# preparation; allow 180s for slower CI runners.
464464
export OPENSHELL_PROVISION_TIMEOUT="${SANDBOX_PROVISION_TIMEOUT}"
465465

466-
e2e_run_openshell_conformance "VM"
466+
OPENSHELL_TEST_PYTHON_IMAGE="${OPENSHELL_TEST_PYTHON_IMAGE:-${E2E_PULLABLE_PYTHON_IMAGE}}" \
467+
e2e_run_openshell_conformance "VM"
467468
if [ "${E2E_FEATURES}" = "e2e-conformance-only" ]; then
468469
echo "::notice::Skipping Rust e2e tests (e2e-conformance-only)"
469470
exit 0

0 commit comments

Comments
 (0)