mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Fix URL schemes in dokku urls output
Previously, the presence of TLS certificates would cause `dokku urls` to output all https URLs, even for domains which were not configured to use TLS. This change introduces a URLS file in the app's directory which contains the URLs with schemes based on whether they have been configured to use TLS in the nginx config. Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
@@ -12,6 +12,20 @@ teardown() {
|
||||
disable_tls_wildcard
|
||||
}
|
||||
|
||||
assert_urls() {
|
||||
urls=$@
|
||||
run dokku urls $TEST_APP
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output < <(tr ' ' '\n' <<< "${urls}")
|
||||
}
|
||||
|
||||
build_nginx_config() {
|
||||
# simulate nginx post-deploy
|
||||
dokku domains:setup $TEST_APP
|
||||
dokku nginx:build-config $TEST_APP
|
||||
}
|
||||
|
||||
@test "run (with tty)" {
|
||||
deploy_app
|
||||
run /bin/bash -c "dokku run $TEST_APP ls /app/package.json"
|
||||
@@ -29,24 +43,29 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "urls (non-ssl)" {
|
||||
run bash -c "dokku urls $TEST_APP | grep dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "http://dokku.me"
|
||||
assert_urls "http://dokku.me"
|
||||
build_nginx_config
|
||||
assert_urls "http://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "urls (app ssl)" {
|
||||
setup_test_tls
|
||||
run bash -c "dokku urls $TEST_APP | grep dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "https://dokku.me"
|
||||
assert_urls "https://dokku.me"
|
||||
build_nginx_config
|
||||
assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "urls (wildcard ssl)" {
|
||||
setup_test_tls_wildcard
|
||||
run bash -c "dokku urls $TEST_APP | grep dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "https://dokku.me"
|
||||
assert_urls "https://dokku.me"
|
||||
build_nginx_config
|
||||
assert_urls "https://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me"
|
||||
add_domain "dokku.example.com"
|
||||
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://dokku.example.com"
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ destroy_app() {
|
||||
echo $TEST_APP | dokku apps:destroy $TEST_APP
|
||||
}
|
||||
|
||||
add_domain() {
|
||||
dokku domains:add $TEST_APP $1
|
||||
}
|
||||
|
||||
deploy_app() {
|
||||
APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"}
|
||||
TMP=$(mktemp -d -t "$TARGET.XXXXX")
|
||||
|
||||
Reference in New Issue
Block a user