add certificate CN to app VHOST if it's not already
This commit is contained in:
@@ -45,7 +45,9 @@ EOF
|
|||||||
|
|
||||||
SSL_HOSTNAME=$(openssl x509 -in $SSL_INUSE/server.crt -noout -subject | tr '/' '\n' | grep CN= | cut -c4-)
|
SSL_HOSTNAME=$(openssl x509 -in $SSL_INUSE/server.crt -noout -subject | tr '/' '\n' | grep CN= | cut -c4-)
|
||||||
SSL_HOSTNAME=$(echo "$SSL_HOSTNAME" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g')
|
SSL_HOSTNAME=$(echo "$SSL_HOSTNAME" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g')
|
||||||
SSL_VHOSTS=$(egrep ^"$SSL_HOSTNAME"$ $VHOST_PATH)
|
|
||||||
|
[[ -z "$(egrep ^"$SSL_HOSTNAME"$ $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME" | sed 's/\\./\./g' >> $VHOST_PATH
|
||||||
|
SSL_VHOSTS=$(egrep ^"$SSL_HOSTNAME"$ $VHOST_PATH || exit 0)
|
||||||
NONSSL_VHOSTS=$(egrep -v ^"$SSL_HOSTNAME"$ $VHOST_PATH || exit 0)
|
NONSSL_VHOSTS=$(egrep -v ^"$SSL_HOSTNAME"$ $VHOST_PATH || exit 0)
|
||||||
|
|
||||||
while read line; do
|
while read line; do
|
||||||
|
|||||||
3
tests.mk
3
tests.mk
@@ -54,8 +54,9 @@ lint:
|
|||||||
# SC2034: VAR appears unused - https://github.com/koalaman/shellcheck/wiki/SC2034
|
# SC2034: VAR appears unused - https://github.com/koalaman/shellcheck/wiki/SC2034
|
||||||
# SC2086: Double quote to prevent globbing and word splitting - https://github.com/koalaman/shellcheck/wiki/SC2086
|
# SC2086: Double quote to prevent globbing and word splitting - https://github.com/koalaman/shellcheck/wiki/SC2086
|
||||||
# SC2143: Instead of [ -n $(foo | grep bar) ], use foo | grep -q bar - https://github.com/koalaman/shellcheck/wiki/SC2143
|
# SC2143: Instead of [ -n $(foo | grep bar) ], use foo | grep -q bar - https://github.com/koalaman/shellcheck/wiki/SC2143
|
||||||
|
# SC2001: See if you can use ${variable//search/replace} instead. - https://github.com/koalaman/shellcheck/wiki/SC2001
|
||||||
@echo linting...
|
@echo linting...
|
||||||
@$(QUIET) find . -not -path '*/\.*' | xargs file | egrep "shell|bash" | awk '{ print $$1 }' | sed 's/://g' | xargs shellcheck -e SC2034,SC2086,SC2143
|
@$(QUIET) find . -not -path '*/\.*' | xargs file | egrep "shell|bash" | awk '{ print $$1 }' | sed 's/://g' | xargs shellcheck -e SC2034,SC2086,SC2143,SC2001
|
||||||
|
|
||||||
unit-tests:
|
unit-tests:
|
||||||
@echo running unit tests...
|
@echo running unit tests...
|
||||||
|
|||||||
20
tests/unit/nginx-vhosts.bats
Normal file
20
tests/unit/nginx-vhosts.bats
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
create_app
|
||||||
|
setup_test_tls
|
||||||
|
deploy_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "nginx:build-config (with SSL CN mismatch)" {
|
||||||
|
run /bin/bash -c "dokku domains $TEST_APP | grep node-js-app.dokku.me"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_output "node-js-app.dokku.me"
|
||||||
|
}
|
||||||
BIN
tests/unit/server_ssl.tar
Normal file
BIN
tests/unit/server_ssl.tar
Normal file
Binary file not shown.
@@ -101,3 +101,10 @@ deploy_app() {
|
|||||||
git commit -m 'initial commit'
|
git commit -m 'initial commit'
|
||||||
git push target master || destroy_app
|
git push target master || destroy_app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_test_tls() {
|
||||||
|
TLS="/home/dokku/$TEST_APP/tls"
|
||||||
|
mkdir -p $TLS
|
||||||
|
tar xf $BATS_TEST_DIRNAME/server_ssl.tar -C $TLS
|
||||||
|
sudo chown -R dokku:dokku $TLS
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user