diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 5fe105fa5..2e0cd954f 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -55,9 +55,9 @@ case "$1" in url | urls) [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1 - APP="$2"; SCHEME="http"; SSL="$DOKKU_ROOT/$APP/tls" + APP="$2"; SCHEME="http"; SSL="$DOKKU_ROOT/$APP/tls"; WILDCARD_SSL="$DOKKU_ROOT/tls" - if [[ -e "$SSL/server.crt" ]] && [[ -e "$SSL/server.key" ]]; then + if [[ -e "$SSL/server.crt" && -e "$SSL/server.key" ]] || [[ -e "$WILDCARD_SSL/server.crt" && -e "$WILDCARD_SSL/server.key" ]]; then SCHEME="https" fi diff --git a/tests/unit/00_dokku-standard.bats b/tests/unit/00_dokku-standard.bats new file mode 100644 index 000000000..930dad279 --- /dev/null +++ b/tests/unit/00_dokku-standard.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + create_app +} + +teardown() { + rm -rf /home/dokku/$TEST_APP/tls /home/dokku/tls + destroy_app +} + +@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" +} + +@test "urls (app ssl)" { + mkdir -p /home/dokku/$TEST_APP/tls + touch /home/dokku/$TEST_APP/tls/server.crt /home/dokku/$TEST_APP/tls/server.key + run bash -c "dokku urls $TEST_APP | grep dokku.me" + echo "output: "$output + echo "status: "$status + assert_output "https://dokku.me" +} + +@test "urls (wildcard ssl)" { + mkdir -p /home/dokku/tls + touch /home/dokku/tls/server.crt /home/dokku/tls/server.key + run bash -c "dokku urls $TEST_APP | grep dokku.me" + echo "output: "$output + echo "status: "$status + assert_output "https://dokku.me" +}