Files
dokku/tests/unit/proxy.bats
Jose Diaz-Gonzalez 76b033234f fix: split report global keys into raw and computed across plugins
The `<plugin>-global-<property>` keys in `:report` output returned the resolved value with the built-in default substituted in, so external tooling could not distinguish a property that had been set globally to the default from one that had never been set. The bare keys for caddy, haproxy, and traefik global-only properties had the same shape. The `global-<property>` keys now hold the raw stored value and are empty when nothing has been set, and a new `computed-<property>` key holds the effective value used at runtime, falling back through the per-app value (where one exists), the global value, and the built-in default. The bare global-only keys for the three proxy plugins are removed in favor of the raw/computed pair. Closes #8631.
2026-05-23 00:05:33 -04:00

176 lines
4.6 KiB
Bash

#!/usr/bin/env bats
load test_helper
setup() {
global_setup
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
create_app
}
teardown() {
destroy_app
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
global_teardown
}
@test "(proxy) proxy:help" {
run /bin/bash -c "dokku proxy"
echo "output: $output"
echo "status: $status"
assert_output_contains "Manage the proxy integration for an app"
help_output="$output"
run /bin/bash -c "dokku proxy:help"
echo "output: $output"
echo "status: $status"
assert_output_contains "Manage the proxy integration for an app"
assert_output "$help_output"
}
@test "(proxy:report) --global raw vs computed type" {
run /bin/bash -c "dokku --quiet proxy:report --global --format json | jq -r '.\"proxy-global-type\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output ""
run /bin/bash -c "dokku --quiet proxy:report --global --format json | jq -r '.\"proxy-computed-type\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "nginx"
run /bin/bash -c "dokku proxy:set --global type caddy"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku --quiet proxy:report --global --format json | jq -r '.\"proxy-global-type\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "caddy"
run /bin/bash -c "dokku --quiet proxy:report --global --format json | jq -r '.\"proxy-computed-type\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "caddy"
run /bin/bash -c "dokku proxy:set --global type"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku --quiet proxy:report --global --format json | jq -r '.\"proxy-global-type\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output ""
run /bin/bash -c "dokku --quiet proxy:report --global --format json | jq -r '.\"proxy-computed-type\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "nginx"
}
@test "(proxy:set) invalid port mapping set" {
run /bin/bash -c "dokku proxy:set $TEST_APP http:80:80"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "Detected potential port mapping instead of proxy type"
}
@test "(proxy) proxy:build-config/clear-config" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "rm -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku proxy:clear-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku proxy:clear-config --all"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
echo "output: $output"
echo "status: $status"
assert_failure
}
@test "(proxy) proxy:enable/disable" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
assert_nonssl_domain "${TEST_APP}.${DOKKU_DOMAIN}"
run /bin/bash -c "dokku proxy:disable $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
assert_not_external_port $(<$CID_FILE)
done
run /bin/bash -c "dokku proxy:enable $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
assert_http_success "${TEST_APP}.${DOKKU_DOMAIN}"
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
assert_not_external_port $(<$CID_FILE)
done
}