Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
{"environment":"ubuntu-k3s","installer":"k3s","family":"features","package":"routable-host-ip","gateway":"tmachine","runner":"ubuntu-24.04"},
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"features","package":"routable-host-ip","gateway":"tmachine","runner":"ubuntu-24.04"},
{"environment":"ubuntu-docker-rootful","installer":"deb","family":"features","package":"connect-ssh-supervision","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"ubuntu-docker-rootful-middleware-http-hooks","installer":"deb","family":"features","package":"middleware-http-hooks","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"fedora-podman-rootful-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"},
{"environment":"fedora-podman-rootful-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
Expand Down
1 change: 0 additions & 1 deletion e2e/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions e2e/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,6 @@ name = "host_gateway_alias"
path = "tests/host_gateway_alias.rs"
required-features = ["e2e-host-gateway"]

[[test]]
name = "supervisor_middleware_http_hooks"
path = "tests/supervisor_middleware_http_hooks.rs"
required-features = ["e2e-docker"]

[[test]]
name = "workspace_namespace_managed"
path = "tests/workspace_namespace_managed.rs"
Expand Down Expand Up @@ -270,7 +265,6 @@ tower = "0.5"
url = "2"

[dev-dependencies]
flate2 = "1"
openshell-ocsf-validate = { path = "../../crates/openshell-ocsf-validate" }
serial_test = "3"

Expand Down
1 change: 0 additions & 1 deletion e2e/rust/e2e-podman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ PODMAN_CI_TESTS=(
podman_host_gateway
provider_github_app
provider_token_exchange
sandbox_compat_signals_sched
)

if [ -n "${E2E_TEST}" ] && [ -n "${E2E_TEST_SET}" ]; then
Expand Down
35 changes: 35 additions & 0 deletions e2e/with-docker-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,20 @@ ADDITIONAL_CA_SERVER_PID=""
ADDITIONAL_CA_SERVER_LOG="${WORKDIR}/additional-ca-server.log"
ADDITIONAL_CA_DIR="${WORKDIR}/additional-ca"
ADDITIONAL_CA_PORT=""
CONTENT_GUARD_PID=""
CONTENT_GUARD_PORT=""
IMAGE_UPDATES_MODE="${OPENSHELL_E2E_DOCKER_IMAGE_UPDATES:-0}"
SUPERVISOR_NETWORK_MODE="${OPENSHELL_E2E_DOCKER_SUPERVISOR_NETWORK_MODE:-}"
case "${SUPERVISOR_NETWORK_MODE}" in
""|host|bridge|auto) ;;
*) echo "ERROR: invalid Docker supervisor network mode for e2e." >&2; exit 2 ;;
esac

if [ -n "${OPENSHELL_E2E_CONTENT_GUARD_BIN:-}" ] && [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ]; then
echo "ERROR: The content guard fixture requires a gateway started by this wrapper." >&2
exit 2
fi

if [ "${IMAGE_UPDATES_MODE}" = "1" ] && [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ]; then
echo "ERROR: Docker image-update qualification requires a new gateway owned by this wrapper." >&2
exit 2
Expand All @@ -156,6 +163,7 @@ cleanup() {

e2e_stop_gateway "${GATEWAY_PID}" "${GATEWAY_PID_FILE}"
e2e_stop_process "${ADDITIONAL_CA_SERVER_PID}" "additional CA HTTPS fixture"
e2e_stop_process "${CONTENT_GUARD_PID}" "content guard middleware"

if [ "${exit_code}" -ne 0 ] \
&& [ -n "${E2E_NAMESPACE}" ] \
Expand Down Expand Up @@ -608,6 +616,27 @@ fi
export OPENSHELL_E2E_GATEWAY_CA_CERT="${PKI_DIR}/ca.crt"
GATEWAY_ENDPOINT="https://${SUPERVISOR_GATEWAY_HOST}:${HOST_PORT}"

if [ -n "${OPENSHELL_E2E_CONTENT_GUARD_BIN:-}" ]; then
CONTENT_GUARD_PORT="$(e2e_pick_port)"
"${OPENSHELL_E2E_CONTENT_GUARD_BIN}" --bind "0.0.0.0:${CONTENT_GUARD_PORT}" &
CONTENT_GUARD_PID=$!
for ((attempt = 0; attempt < 30; attempt++)); do
if ! kill -0 "${CONTENT_GUARD_PID}" 2>/dev/null; then
echo "ERROR: Content guard exited before it started listening." >&2
exit 1
fi
if (exec 3<>"/dev/tcp/127.0.0.1/${CONTENT_GUARD_PORT}") 2>/dev/null; then
break
fi
sleep 1
done
if [ "${attempt}" -eq 30 ]; then
echo "ERROR: Content guard did not start listening." >&2
exit 1
fi
export OPENSHELL_TEST_CONTENT_GUARD_REGISTRATION=content-guard-example
fi

echo "Starting openshell-gateway on port ${HOST_PORT} (namespace: ${E2E_NAMESPACE})..."
echo "Using sandbox image: ${SANDBOX_IMAGE} (pull policy: ${SANDBOX_IMAGE_PULL_POLICY})"
e2e_generate_gateway_jwt "${JWT_DIR}"
Expand Down Expand Up @@ -677,6 +706,12 @@ GATEWAY_CONFIG="${STATE_DIR}/gateway.toml"
printf 'supervisor_image = %s\n' "$(toml_string "${SUPERVISOR_IMAGE}")"
printf '\n[openshell.drivers.docker.resource_admission]\n'
printf 'enabled = false\n'
if [ -n "${CONTENT_GUARD_PORT}" ]; then
printf '\n[[openshell.supervisor.middleware]]\n'
printf 'name = %s\n' "$(toml_string "${OPENSHELL_TEST_CONTENT_GUARD_REGISTRATION}")"
printf 'grpc_endpoint = %s\n' "$(toml_string "http://${SUPERVISOR_GATEWAY_HOST}:${CONTENT_GUARD_PORT}")"
printf 'allow_insecure_transport = true\nmax_payload_bytes = 262144\ntimeout = "2s"\n'
fi
} > "${GATEWAY_CONFIG}"

GATEWAY_ARGS=(
Expand Down
5 changes: 2 additions & 3 deletions tasks/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ TARGET_DIR="${CARGO_TARGET_DIR:-$PWD/target}/content-guard"
cargo build --locked --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml \
--target-dir "${TARGET_DIR}"
export OPENSHELL_E2E_CONTENT_GUARD_BIN="${TARGET_DIR}/debug/supervisor-middleware-content-guard"
export OPENSHELL_E2E_REQUIRE_MIDDLEWARE=1
exec e2e/with-docker-gateway.sh cargo test --manifest-path e2e/rust/Cargo.toml \
--features e2e-docker --test supervisor_middleware_http_hooks -- --nocapture
exec e2e/with-docker-gateway.sh cargo test --locked \
--manifest-path tests/suites/features/Cargo.toml -p middleware-http-hooks -- --nocapture
"""

["e2e:mcp"]
Expand Down
1 change: 1 addition & 0 deletions tests/suites/conformance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mod policy_update;
mod port_forward;
mod process;
mod settings;
mod signals_scheduling;
mod smoke;
mod ssh;
mod templates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
//! failed with EPERM. The broker now mediates them: the caller's own thread
//! group is allowed and every other target stays denied.

#![cfg(feature = "e2e")]

use openshell_e2e::harness::sandbox::SandboxGuard;
use testkit::Context;

const SUCCESS_MARKER: &str = "sandbox_compat_signals_sched=ok";

Expand Down Expand Up @@ -175,17 +173,24 @@ sys.exit(0 if not failures else 1)
"#
}

#[tokio::test]
async fn sandbox_allows_own_group_and_denies_foreign_scheduling_and_signals() {
let mut sandbox = SandboxGuard::create(&["--", "python3", "-c", compat_script()])
.await
.expect("sandbox create");

assert!(
sandbox.create_output.contains(SUCCESS_MARKER),
"expected own-group probes to pass and foreign-target probes to be denied:\n{}",
sandbox.create_output
/// Scheduling and signal probes may act on the caller's thread group, but
/// scheduling changes that target another process must fail with EPERM.
#[testkit::test]
async fn sandbox_allows_own_group_and_denies_foreign_scheduling_and_signals(
cx: &mut Context,
) -> testkit::Result {
let sandbox = cx
.sandbox("sig")
.image(testkit::python_image())
.command(["sleep", "infinity"])
.create_ready()
.await?;
let output = sandbox.run_python(compat_script(), &[]).await?;
testkit::ensure!(
output.stdout.lines().any(|line| line == SUCCESS_MARKER),
"missing successful syscall probes:\n{}{}",
output.stdout,
output.stderr
);

sandbox.cleanup().await;
Ok(())
}
45 changes: 45 additions & 0 deletions tests/suites/features/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/suites/features/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

[workspace]
resolver = "2"
members = ["cdi", "connect-ssh-supervision", "docker-updates", "host-gateway", "keycloak-provider-refresh", "kubernetes-updates", "oci-image", "routable-host-ip"]
members = ["cdi", "connect-ssh-supervision", "docker-updates", "host-gateway", "keycloak-provider-refresh", "kubernetes-updates", "middleware-http-hooks", "oci-image", "routable-host-ip"]
25 changes: 25 additions & 0 deletions tests/suites/features/middleware-http-hooks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

[package]
name = "middleware-http-hooks"
description = "Features suite: HTTP hooks against a registered middleware service"
version = "0.0.0"
edition = "2024"
rust-version = "1.94"
license = "Apache-2.0"
repository = "https://github.com/ai-openshell/openshell"
publish = false

[[test]]
name = "middleware-http-hooks"
path = "tests/http_hooks.rs"
harness = false

[dependencies]
flate2 = "1"
host-server-support = { path = "../../../support/host-server" }
middleware-support = { path = "../../../support/middleware" }
openshell-testkit = { path = "../../../testkit/testkit" }
serde_json = "1"
tokio = { version = "1", features = ["io-util", "net", "rt", "sync", "time"] }
13 changes: 13 additions & 0 deletions tests/suites/features/middleware-http-hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Registered middleware HTTP hooks

Run `mise run e2e:middleware-http-hooks` to start a Docker gateway and the
content-guard example and run the suite. The tmachine row
`ubuntu-docker-rootful-middleware-http-hooks/deb` starts and registers the same
example during environment setup. Build its binary with
`nix run .#build-artifacts-test-archives` when preparing inputs locally.

Both environments set `OPENSHELL_TEST_CONTENT_GUARD_REGISTRATION` to the name
registered in the gateway (typically `content-guard-example`). The suite fails
if it is missing. The gateway and supervisor must be able to reach the guard,
and the sandbox must be able to reach an upstream hosted by the test process
at `host.openshell.internal`.
Loading
Loading