refactor: simplify how url generation works
The URLS file is no longer necessary as urls are now generated directly from the app VHOST file. This also moves all the url generation logic to the domains plugin.
This commit is contained in:
@@ -136,8 +136,6 @@ teardown() {
|
||||
assert_success
|
||||
run [ -d /home/dokku/great-test-name/tls ]
|
||||
assert_failure
|
||||
run [ -f /home/dokku/great-test-name/URLS ]
|
||||
assert_failure
|
||||
run [ -f /home/dokku/great-test-name/VHOST ]
|
||||
assert_failure
|
||||
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' $(dokku url $TEST_APP) | grep 200"
|
||||
|
||||
@@ -39,33 +39,72 @@ teardown() {
|
||||
|
||||
@test "(core) urls (non-ssl)" {
|
||||
assert_urls "http://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
dokku domains:add $TEST_APP "test.dokku.me"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "(core) urls (app ssl)" {
|
||||
assert_urls "http://${TEST_APP}.dokku.me"
|
||||
setup_test_tls
|
||||
dokku proxy:build-config "$TEST_APP"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "https://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me" "https://${TEST_APP}.dokku.me" "https://test.dokku.me"
|
||||
|
||||
run setup_test_tls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
assert_urls "https://${TEST_APP}.dokku.me"
|
||||
|
||||
run /bin/bash -c "dokku domains:add $TEST_APP test.dokku.me"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "(core) url (app ssl)" {
|
||||
setup_test_tls
|
||||
dokku proxy:build-config "$TEST_APP"
|
||||
run setup_test_tls
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
assert_url "https://${TEST_APP}.dokku.me"
|
||||
}
|
||||
|
||||
@test "(core) urls (wildcard ssl)" {
|
||||
setup_test_tls wildcard
|
||||
dokku proxy:build-config "$TEST_APP"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "https://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me" "https://${TEST_APP}.dokku.me" "https://test.dokku.me"
|
||||
add_domain "dokku.example.com"
|
||||
assert_urls "http://dokku.example.com" "http://${TEST_APP}.dokku.me" "http://test.dokku.me" "https://dokku.example.com" "https://${TEST_APP}.dokku.me" "https://test.dokku.me"
|
||||
run setup_test_tls wildcard
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
assert_urls "https://${TEST_APP}.dokku.me"
|
||||
|
||||
run /bin/bash -c "dokku domains:add $TEST_APP test.dokku.me"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://test.dokku.me"
|
||||
|
||||
run /bin/bash -c "dokku domains:add $TEST_APP dokku.example.com"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_urls "http://dokku.example.com" "http://${TEST_APP}.dokku.me" "https://dokku.example.com" "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "(core) git-remote (off-port)" {
|
||||
|
||||
@@ -16,8 +16,8 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" {
|
||||
setup_test_tls
|
||||
add_domain "node-js-app.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
dokku domains:add $TEST_APP "node-js-app.dokku.me"
|
||||
dokku domains:add $TEST_APP "test.dokku.me"
|
||||
deploy_app
|
||||
dokku nginx:show-config $TEST_APP
|
||||
assert_ssl_domain "node-js-app.dokku.me"
|
||||
@@ -26,8 +26,8 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
|
||||
setup_test_tls wildcard
|
||||
add_domain "wildcard1.dokku.me"
|
||||
add_domain "wildcard2.dokku.me"
|
||||
dokku domains:add $TEST_APP "wildcard1.dokku.me"
|
||||
dokku domains:add $TEST_APP "wildcard2.dokku.me"
|
||||
deploy_app
|
||||
dokku nginx:show-config $TEST_APP
|
||||
assert_ssl_domain "wildcard1.dokku.me"
|
||||
@@ -51,9 +51,9 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (with SSL and Multiple SANs)" {
|
||||
setup_test_tls sans
|
||||
add_domain "test.dokku.me"
|
||||
add_domain "www.test.dokku.me"
|
||||
add_domain "www.test.app.dokku.me"
|
||||
dokku domains:add $TEST_APP "test.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.app.dokku.me"
|
||||
deploy_app
|
||||
assert_ssl_domain "test.dokku.me"
|
||||
assert_ssl_domain "www.test.dokku.me"
|
||||
|
||||
@@ -58,7 +58,7 @@ teardown() {
|
||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add pre deploy)" {
|
||||
rm "$DOKKU_ROOT/VHOST"
|
||||
create_app
|
||||
add_domain "www.test.app.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.app.dokku.me"
|
||||
deploy_app
|
||||
assert_nonssl_domain "www.test.app.dokku.me"
|
||||
}
|
||||
@@ -66,7 +66,7 @@ teardown() {
|
||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add post deploy)" {
|
||||
rm "$DOKKU_ROOT/VHOST"
|
||||
deploy_app
|
||||
add_domain "www.test.app.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.app.dokku.me"
|
||||
check_urls http://www.test.app.dokku.me
|
||||
assert_http_success http://www.test.app.dokku.me
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ teardown() {
|
||||
@test "(nginx-vhosts) nginx:build-config (dockerfile expose)" {
|
||||
deploy_app dockerfile
|
||||
|
||||
add_domain "www.test.app.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.app.dokku.me"
|
||||
check_urls http://${TEST_APP}.dokku.me:3000
|
||||
check_urls http://${TEST_APP}.dokku.me:3003
|
||||
check_urls http://www.test.app.dokku.me:3000
|
||||
|
||||
@@ -16,8 +16,8 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL and custom nginx template)" {
|
||||
setup_test_tls wildcard
|
||||
add_domain "wildcard1.dokku.me"
|
||||
add_domain "wildcard2.dokku.me"
|
||||
dokku domains:add $TEST_APP "wildcard1.dokku.me"
|
||||
dokku domains:add $TEST_APP "wildcard2.dokku.me"
|
||||
deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_ssl_nginx_template
|
||||
|
||||
assert_ssl_domain "wildcard1.dokku.me"
|
||||
@@ -27,7 +27,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (custom nginx template - no ssl)" {
|
||||
add_domain "www.test.app.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.app.dokku.me"
|
||||
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
@@ -53,7 +53,7 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
add_domain "www.test.app.dokku.me"
|
||||
dokku domains:add $TEST_APP "www.test.app.dokku.me"
|
||||
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
|
||||
@@ -154,8 +154,8 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" {
|
||||
setup_test_tls
|
||||
add_domain "node-js-app.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
dokku domains:add $TEST_APP "node-js-app.dokku.me"
|
||||
dokku domains:add $TEST_APP "test.dokku.me"
|
||||
deploy_app
|
||||
dokku nginx:show-config $TEST_APP
|
||||
assert_ssl_domain "node-js-app.dokku.me"
|
||||
@@ -164,8 +164,8 @@ teardown() {
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
|
||||
setup_test_tls wildcard
|
||||
add_domain "wildcard1.dokku.me"
|
||||
add_domain "wildcard2.dokku.me"
|
||||
dokku domains:add $TEST_APP "wildcard1.dokku.me"
|
||||
dokku domains:add $TEST_APP "wildcard2.dokku.me"
|
||||
deploy_app
|
||||
dokku nginx:show-config $TEST_APP
|
||||
assert_ssl_domain "wildcard1.dokku.me"
|
||||
|
||||
@@ -218,10 +218,6 @@ destroy_key() {
|
||||
rm -f /tmp/testkey* &>/dev/null || true
|
||||
}
|
||||
|
||||
add_domain() {
|
||||
dokku domains:add "$TEST_APP" "$1"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2119
|
||||
check_urls() {
|
||||
local PATTERN="$1"
|
||||
@@ -288,10 +284,14 @@ assert_not_external_port() {
|
||||
|
||||
assert_url() {
|
||||
url="$1"
|
||||
run /bin/bash -c "dokku url $TEST_APP"
|
||||
run /bin/bash -c "dokku url $TEST_APP | xargs"
|
||||
echo "VHOST: $(cat $DOKKU_ROOT/$TEST_APP/VHOST | xargs)"
|
||||
echo "tls: $(ls $DOKKU_ROOT/$TEST_APP/tls || true)"
|
||||
echo "proxy-is-enabled: $(dokku plugin:trigger proxy-is-enabled "$TEST_APP")"
|
||||
echo "port-map: $(dokku config:get "$TEST_APP" DOKKU_PROXY_PORT_MAP)"
|
||||
echo "url: $(dokku urls $TEST_APP)"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
echo "url: ${url}"
|
||||
assert_output "${url}"
|
||||
}
|
||||
|
||||
@@ -299,9 +299,13 @@ assert_urls() {
|
||||
# shellcheck disable=SC2124
|
||||
urls="$@"
|
||||
run /bin/bash -c "dokku urls $TEST_APP | xargs"
|
||||
echo "VHOST: $(cat $DOKKU_ROOT/$TEST_APP/VHOST | xargs)"
|
||||
echo "tls: $(ls $DOKKU_ROOT/$TEST_APP/tls || true)"
|
||||
echo "proxy-is-enabled: $(dokku plugin:trigger proxy-is-enabled "$TEST_APP")"
|
||||
echo "port-map: $(dokku config:get "$TEST_APP" DOKKU_PROXY_PORT_MAP)"
|
||||
echo "urls: $(dokku urls $TEST_APP)"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
echo "urls:" "$urls"
|
||||
assert_output "$urls"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user