Files
dokku/tests/unit/traefik-vhosts.bats
Jose Diaz-Gonzalez 5faabea3d4 feat: port vhost proxy :report subcommands to golang
The bash :report implementations for the caddy, haproxy, openresty, and traefik proxy plugins are replaced with a compiled golang binary that collects report keys in parallel and marshals json directly. The traefik dns-provider values keep their masking behaviour, remaining hidden in the default stdout report while surfacing for --format json or an explicit flag query. These four plugins previously had no unit tests, so a bats suite covering the report matrix is added for each.
2026-07-07 06:29:01 -04:00

73 lines
2.0 KiB
Bash

#!/usr/bin/env bats
load test_helper
setup() {
create_app
}
teardown() {
destroy_app
dokku traefik:set --global challenge-mode >/dev/null 2>&1 || true
dokku traefik:set --global dns-provider-test_key >/dev/null 2>&1 || true
}
@test "(traefik:report) info-flag works before deploy" {
run /bin/bash -c "dokku traefik:set --global challenge-mode"
assert_success
run /bin/bash -c "dokku traefik:report $TEST_APP --traefik-computed-challenge-mode"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "tls"
run /bin/bash -c "dokku traefik:report $TEST_APP --traefik-invalid-flag"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "Invalid flag passed"
}
@test "(traefik:report) --format json" {
run /bin/bash -c "dokku traefik:report --global --format json | jq -e ."
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku traefik:report --global --format json | jq -r '.\"computed-api-enabled\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "false"
run /bin/bash -c "dokku traefik:report --global"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "global traefik information"
}
@test "(traefik:report) dns-provider values are masked unless queried" {
run /bin/bash -c "dokku traefik:set --global dns-provider-test_key secretvalue"
assert_success
run /bin/bash -c "dokku traefik:report --global | grep test_key"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "*******"
run /bin/bash -c "dokku traefik:report --global --traefik-dns-provider-test_key"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "secretvalue"
run /bin/bash -c "dokku traefik:report --global --format json | jq -r '.\"dns-provider-test_key\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "secretvalue"
}