From 6f938dd12bfb18bdebafe53db8e59b814d659efc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 20 Sep 2026 17:31:47 -0400 Subject: [PATCH] fix: assert the forwarded set, not a sample variable The test used `DOKKU_IMAGE` as a variable that does not cross the privilege drop, which stopped being true once every environment-overridable variable was forwarded. It now reads the `--preserve-env` argument itself, so it tests the contract rather than one member of the list. --- tests/unit/core_3.bats | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/core_3.bats b/tests/unit/core_3.bats index 37f4054f9..832bb51b1 100644 --- a/tests/unit/core_3.bats +++ b/tests/unit/core_3.bats @@ -80,20 +80,20 @@ teardown() { } @test "(core) [global-flags] an unlisted variable only crosses when DOKKU_PRESERVE_ENV names it" { - # DOKKU_IMAGE is not carried across the re-exec and is re-derived by the child, so the - # traced value shows whether the caller's value survived. The flag form of --trace is - # used deliberately: DOKKU_TRACE=1 would trace the parent as well as the child. - run /bin/bash -c "DOKKU_IMAGE=probe/image dokku --trace apps:list 2>&1 >/dev/null | grep -m1 'export DOKKU_IMAGE'" + # DOKKU_TRACE is set in the environment rather than passed as --trace so that the + # parent traces too: the sudo line naming the forwarded variables is only emitted there + run /bin/bash -c "DOKKU_TRACE=1 DOKKU_TEST_CROSSING=1 dokku apps:list 2>&1 >/dev/null | grep -o -- '--preserve-env=[^ ]*' | head -1" echo "output: $output" echo "status: $status" assert_success - assert_output_not_contains "probe/image" + assert_output_contains "--preserve-env=" + assert_output_not_contains "DOKKU_TEST_CROSSING" - run /bin/bash -c "DOKKU_PRESERVE_ENV=DOKKU_IMAGE DOKKU_IMAGE=probe/image dokku --trace apps:list 2>&1 >/dev/null | grep -m1 'export DOKKU_IMAGE'" + run /bin/bash -c "DOKKU_TRACE=1 DOKKU_PRESERVE_ENV=DOKKU_TEST_CROSSING DOKKU_TEST_CROSSING=1 dokku apps:list 2>&1 >/dev/null | grep -o -- '--preserve-env=[^ ]*' | head -1" echo "output: $output" echo "status: $status" assert_success - assert_output_contains "probe/image" + assert_output_contains "DOKKU_TEST_CROSSING" } @test "(core) [global-flags] the system sudo supports a named preserve-env list" {