fix: preserve explicit https:443 port mappings on cert update

The ports plugin's `post-certs-update` trigger was rewriting every `https:443:*` mapping from the app's `http:80:*` mappings, silently overwriting any user-defined mapping such as `https:443:443` used by apps that terminate TLS inside the container. The trigger now skips the rewrite when an `https:443:*` mapping already exists, keeping the default behavior only when the app has no explicit HTTPS mapping configured.

Closes #8619.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-12 19:02:47 -04:00
parent 12c00b57fc
commit cecd07d914
3 changed files with 42 additions and 11 deletions

View File

@@ -87,6 +87,40 @@ teardown() {
assert_success
}
@test "(certs:add) preserves explicit https:443 port mapping" {
run /bin/bash -c "dokku ports:set $TEST_APP http:80:80 https:443:443"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/server.crt $BATS_TMPDIR/tls/server.key"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku --quiet ports:report $TEST_APP --ports-map"
echo "output: $output"
echo "status: $status"
assert_output "http:80:80 https:443:443"
}
@test "(certs:add) adds default https:443 mapping when none exists" {
run /bin/bash -c "dokku ports:set $TEST_APP http:80:5000"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/server.crt $BATS_TMPDIR/tls/server.key"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku --quiet ports:report $TEST_APP --ports-map"
echo "output: $output"
echo "status: $status"
assert_output "http:80:5000 https:443:5000"
}
@test "(certs) certs:add with multiple dots in the filename" {
run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/domain.com.crt $BATS_TMPDIR/tls/domain.com.key"
echo "output: $output"