Skip to content

Commit aa5eb90

Browse files
committed
Add tests using staging server
1 parent 896d55d commit aa5eb90

15 files changed

Lines changed: 293 additions & 10 deletions

dns_scripts/dns_add_duckdns

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# need to add your Token for duckdns below
4+
token=${DUCKDNS_TOKEN:-}
5+
6+
if [ -z "$token" ]; then
7+
echo "DUCKDNS_TOKEN not set"
8+
exit 1
9+
fi
10+
11+
domain="$1"
12+
txtvalue="$2"
13+
14+
response=$(curl --silent "https://www.duckdns.org/update?domains=${domain}&token=${token}&txt=${txtvalue}")
15+
if [ "$response" != "OK" ]; then
16+
echo "Failed to update TXT record for ${domain} at duckdns.org (is the TOKEN valid?)"
17+
echo "Response: $response"
18+
exit 1
19+
fi

dns_scripts/dns_del_duckdns

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# need to add your Token for duckdns below
4+
token=${DUCKDNS_TOKEN:-}
5+
domain="$1"
6+
7+
response=$(curl --silent "https://www.duckdns.org/update?domains=${domain}&token=${token}&txt=&clear=true")
8+
if [ "$response" != "OK" ]; then
9+
echo "Failed to update TXT record for ${domain} at duckdns.org (is the TOKEN valid?)"
10+
echo "$response"
11+
exit 1
12+
fi

docker-compose.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,24 @@ services:
156156
- i.ubuntu18.getssl.test
157157
- j.ubuntu18.getssl.test
158158
- k.ubuntu18.getssl.test
159-
159+
getssl-duckdns:
160+
build:
161+
context: .
162+
dockerfile: test/Dockerfile-ubuntu
163+
container_name: getssl-duckdns
164+
volumes:
165+
- .:/getssl
166+
environment:
167+
GETSSL_HOST: getssl.duckdns.org
168+
GETSSL_IP: 10.30.50.15
169+
NGINX_CONFIG: /etc/nginx/sites-enabled/default
170+
DUCKDNS_TOKEN: $DUCKDNS_TOKEN
171+
STAGING: "true"
172+
networks:
173+
acmenet:
174+
ipv4_address: 10.30.50.15
175+
aliases:
176+
- getssl.duckdns.org
160177

161178

162179
networks:

test/1-simple-http01.bats

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ setup() {
1212

1313

1414
@test "Create new certificate using HTTP-01 verification" {
15+
if [ -n "$STAGING" ]; then
16+
skip "Using staging server, skipping internal test"
17+
fi
1518
CONFIG_FILE="getssl-http01.cfg"
1619
setup_environment
1720
init_getssl
@@ -24,7 +27,9 @@ setup() {
2427

2528

2629
@test "Force renewal of certificate using HTTP-01" {
27-
#!FIXME test certificate has been updated
30+
if [ -n "$STAGING" ]; then
31+
skip "Using staging server, skipping internal test"
32+
fi
2833
run ${CODE_DIR}/getssl -f $GETSSL_HOST
2934
assert_success
3035
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'

test/2-simple-dns01.bats

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ setup() {
1212

1313

1414
@test "Create new certificate using DNS-01 verification" {
15+
if [ -n "$STAGING" ]; then
16+
skip "Using staging server, skipping internal test"
17+
fi
18+
1519
CONFIG_FILE="getssl-dns01.cfg"
1620
setup_environment
1721
init_getssl
@@ -24,7 +28,9 @@ setup() {
2428

2529

2630
@test "Force renewal of certificate using DNS-01" {
27-
#!FIXME test certificate has been updated
31+
if [ -n "$STAGING" ]; then
32+
skip "Using staging server, skipping internal test"
33+
fi
2834
run ${CODE_DIR}/getssl -f $GETSSL_HOST
2935
assert_success
3036
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'

test/3-dual-rsa-ecdsa.bats

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ setup() {
1212

1313

1414
@test "Create dual certificates using HTTP-01 verification" {
15+
if [ -n "$STAGING" ]; then
16+
skip "Using staging server, skipping internal test"
17+
fi
1518
CONFIG_FILE="getssl-http01-dual-rsa-ecdsa.cfg"
1619
setup_environment
1720
init_getssl
@@ -21,12 +24,17 @@ setup() {
2124

2225

2326
@test "Force renewal of dual certificates using HTTP-01" {
24-
#!FIXME test certificate has been updated
27+
if [ -n "$STAGING" ]; then
28+
skip "Using staging server, skipping internal test"
29+
fi
2530
run ${CODE_DIR}/getssl -f $GETSSL_HOST
2631
assert_success
2732
}
2833

2934
@test "Create dual certificates using DNS-01 verification" {
35+
if [ -n "$STAGING" ]; then
36+
skip "Using staging server, skipping internal test"
37+
fi
3038
CONFIG_FILE="getssl-dns01-dual-rsa-ecdsa.cfg"
3139
setup_environment
3240
init_getssl
@@ -36,7 +44,9 @@ setup() {
3644

3745

3846
@test "Force renewal of dual certificates using DNS-01" {
39-
#!FIXME test certificate has been updated
47+
if [ -n "$STAGING" ]; then
48+
skip "Using staging server, skipping internal test"
49+
fi
4050
run ${CODE_DIR}/getssl -f $GETSSL_HOST
4151
assert_success
4252
cleanup_environment

test/4-more-than-10-hosts.bats

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ setup() {
1212

1313

1414
@test "Create certificates for more than 10 hosts using HTTP-01 verification" {
15+
if [ -n "$STAGING" ]; then
16+
skip "Using staging server, skipping internal test"
17+
fi
1518
CONFIG_FILE="getssl-http01-10-hosts.cfg"
1619
setup_environment
1720

@@ -30,7 +33,9 @@ setup() {
3033

3134

3235
@test "Force renewal of more than 10 certificates using HTTP-01" {
33-
#!FIXME test certificate has been updated
36+
if [ -n "$STAGING" ]; then
37+
skip "Using staging server, skipping internal test"
38+
fi
3439
run ${CODE_DIR}/getssl -f $GETSSL_HOST
3540
assert_success
3641
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'

test/5-secp384-http01.bats

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ setup() {
1212

1313

1414
@test "Create new secp384r1 certificate using HTTP-01 verification" {
15+
if [ -n "$STAGING" ]; then
16+
skip "Using staging server, skipping internal test"
17+
fi
1518
CONFIG_FILE="getssl-http01-secp384.cfg"
1619
setup_environment
1720
init_getssl
@@ -21,12 +24,18 @@ setup() {
2124

2225

2326
@test "Force renewal of secp384r1 certificate using HTTP-01" {
27+
if [ -n "$STAGING" ]; then
28+
skip "Using staging server, skipping internal test"
29+
fi
2430
run ${CODE_DIR}/getssl -f $GETSSL_HOST
2531
assert_success
2632
}
2733

2834

2935
@test "Create new secp521r1 certificate using HTTP-01 verification" {
36+
if [ -n "$STAGING" ]; then
37+
skip "Using staging server, skipping internal test"
38+
fi
3039
CONFIG_FILE="getssl-http01-secp521.cfg"
3140
setup_environment
3241
init_getssl
@@ -36,6 +45,9 @@ setup() {
3645

3746

3847
@test "Force renewal of secp521r1 certificate using HTTP-01" {
48+
if [ -n "$STAGING" ]; then
49+
skip "Using staging server, skipping internal test"
50+
fi
3951
run ${CODE_DIR}/getssl -f $GETSSL_HOST
4052
assert_success
4153
}

test/6-dual-rsa-ecdsa-copy-2-locations.bats

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ load '/getssl/test/test_helper.bash'
77

88
# These are run for every test, not once per file
99
setup() {
10-
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
11-
curl --silent -X POST -d '{"host":"'a.$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/add-a
10+
if [ -z "$STAGING" ]; then
11+
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
12+
curl --silent -X POST -d '{"host":"'a.$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/add-a
13+
fi
1214
}
1315

1416

1517
teardown() {
16-
curl --silent -X POST -d '{"host":"'a.$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/del-a
18+
if [ -z "$STAGING" ]; then
19+
curl --silent -X POST -d '{"host":"'a.$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/del-a
20+
fi
1721
}
1822

1923

2024
@test "Create dual certificates and copy RSA and ECDSA chain and key to two locations" {
25+
if [ -n "$STAGING" ]; then
26+
skip "Using staging server, skipping internal test"
27+
fi
2128
CONFIG_FILE="getssl-http01-dual-rsa-ecdsa-2-locations.cfg"
2229
setup_environment
2330
mkdir -p /root/a.${GETSSL_HOST}

test/7-duckdns-dns01.bats

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#! /usr/bin/env bats
2+
3+
load '/bats-support/load.bash'
4+
load '/bats-assert/load.bash'
5+
load '/getssl/test/test_helper.bash'
6+
7+
8+
# These are run for every test, not once per file
9+
setup() {
10+
if [ -n "$STAGING" ]; then
11+
export GETSSL_HOST=getssl.duckdns.org
12+
fi
13+
}
14+
15+
16+
@test "Create new certificate using staging server and DuckDNS" {
17+
if [ -z "$STAGING" ]; then
18+
skip "Running internal tests, skipping external test"
19+
fi
20+
CONFIG_FILE="getssl-duckdns01.cfg"
21+
22+
setup_environment
23+
init_getssl
24+
create_certificate
25+
assert_success
26+
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
27+
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
28+
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
29+
}
30+
31+
@test "Force renewal of certificate using staging server and DuckDNS" {
32+
if [ -z "$STAGING" ]; then
33+
skip "Running internal tests, skipping external test"
34+
fi
35+
run ${CODE_DIR}/getssl -f $GETSSL_HOST
36+
assert_success
37+
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
38+
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
39+
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
40+
cleanup_environment
41+
curl --silent -X POST -d '{"host":"getssl.duckdns.org", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/del-a
42+
}

0 commit comments

Comments
 (0)