Skip to content

Commit b81f503

Browse files
authored
Fix bug caused in v-update-letsencrypt-ssl (hestiacp#2627)
* Fix bug caused in v-update-letsencrypt-ssl * Fix bug with false matches alias string * Expand with test for Wildcard Can't be ran on test server due to requirement that DNS records need to be availble
1 parent 2ccf56c commit b81f503

File tree

3 files changed

+67
-3
lines changed

3 files changed

+67
-3
lines changed

bin/v-update-letsencrypt-ssl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
8282
# Loop through all crt aliases
8383
for alias in ${aliases//,/ } ; do
8484
# Validate if the alias still exists in web.conf
85-
if [[ "$ALIAS" =~ $alias ]]; then
85+
if [[ ",$ALIAS," =~ ",$alias," ]]; then
8686
f_aliases+="$alias,"
8787
fi
8888
done

test/letsencrypt.bats

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ function setup() {
3333
}
3434

3535
@test "[ Web ] Create web domain" {
36-
run v-add-web-domain $user $domain $ip yes "www.$domain,renewal.$domain"
36+
run v-add-web-domain $user $domain $ip yes "www.$domain,renewal.$domain,foobar.$domain,bar.$domain"
3737
assert_success
3838
refute_output
3939
}
4040

4141
@test "[ Web ] Request new certificate for web domain" {
42-
run v-add-letsencrypt-domain $user $domain "www.$domain,renewal.$domain"
42+
run v-add-letsencrypt-domain $user $domain "www.$domain,renewal.$domain,foobar.$domain,bar.$domain"
4343
assert_success
4444
refute_output
4545
}
@@ -62,6 +62,18 @@ function setup() {
6262
refute_output
6363
}
6464

65+
@test "[ All ] Remove alias and update ssl" {
66+
run v-delete-web-domain-alias $user $domain bar.$domain
67+
assert_success
68+
refute_output
69+
70+
run v-update-letsencrypt-ssl
71+
assert_success
72+
refute_output
73+
74+
}
75+
76+
6577
@test [ Web ] Delete web ssl" {
6678
run v-delete-letsencrypt-domain $user $domain "yes"
6779
assert_success

test/wildcard.bats

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bats
2+
3+
if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then
4+
. /etc/profile.d/hestia.sh
5+
fi
6+
7+
load 'test_helper/bats-support/load'
8+
load 'test_helper/bats-assert/load'
9+
load 'test_helper/bats-file/load'
10+
11+
12+
function random() {
13+
head /dev/urandom | tr -dc 0-9 | head -c$1
14+
}
15+
16+
function setup() {
17+
source /tmp/wildcard.sh
18+
source $HESTIA/func/main.sh
19+
source $HESTIA/conf/hestia.conf
20+
source $HESTIA/func/ip.sh
21+
}
22+
23+
# User and domain needs to already exists as dns domain due to DNS
24+
25+
@test "[ Web ] Create web domain" {
26+
run v-add-web-domain $user $domain $ip yes "*.$domain"
27+
assert_success
28+
refute_output
29+
}
30+
31+
@test "[ Web ] Request new certificate for web domain" {
32+
run v-restart-web
33+
run v-add-letsencrypt-domain $user $domain "*.$domain"
34+
assert_success
35+
refute_output
36+
}
37+
38+
@test "[ All ] Run renewal script for LE" {
39+
run v-update-letsencrypt-ssl
40+
assert_success
41+
refute_output
42+
43+
run openssl x509 -text -in /usr/local/hestia/data/users/$user/ssl/$domain.crt
44+
assert_success
45+
assert_output --partial "*.$domain"
46+
}
47+
48+
@test "[ Web ] Delete web domain" {
49+
run v-delete-web-domain $user $domain "yes"
50+
assert_success
51+
refute_output
52+
}

0 commit comments

Comments
 (0)