Skip to content

Commit 8f09a17

Browse files
committed
fixup! Tests: ACME client tests.
1 parent b0f6922 commit 8f09a17

File tree

10 files changed

+85
-18
lines changed

10 files changed

+85
-18
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,19 @@ jobs:
8888
~/.cargo/registry/index/
8989
~/.cargo/registry/cache/
9090
~/.cargo/git/db/
91+
bin/pebble
9192
nginx/objs/**/CACHEDIR.TAG
9293
nginx/objs/**/ngx-debug
9394
nginx/objs/**/ngx-release
9495
key: ${{ runner.os }}-nginx-${{ hashFiles('**/Cargo.lock') }}
9596
restore-keys: ${{ runner.os }}-nginx-
9697

98+
- name: test prerequisites
99+
run: |
100+
cpan -i IO::Socket::SSL
101+
build/get-pebble.sh
102+
echo TEST_NGINX_PEBBLE_BINARY="$PWD/bin/pebble" >> "$GITHUB_ENV"
103+
97104
- name: build
98105
id: build
99106
run: make BUILD=${{ matrix.build }} -j $(nproc) build

.github/workflows/sanitizers.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
cargo rust-src rustfmt
1616
clang compiler-rt llvm
1717
git-core
18-
make patch
18+
make openssl patch which
1919
perl-FindBin
2020
perl-IO-Socket-SSL
2121
perl-Test-Harness
@@ -56,12 +56,18 @@ jobs:
5656
~/.cargo/registry/index/
5757
~/.cargo/registry/cache/
5858
~/.cargo/git/db/
59+
bin/pebble
5960
nginx/objs/**/CACHEDIR.TAG
6061
nginx/objs/**/ngx-debug
6162
nginx/objs/**/ngx-release
6263
key: ${{ runner.os }}-cargo-asan-${{ hashFiles('**/Cargo.lock') }}
6364
restore-keys: ${{ runner.os }}-cargo-asan-
6465

66+
- name: Install test prerequisites
67+
run: |
68+
build/get-pebble.sh
69+
echo TEST_NGINX_PEBBLE_BINARY="$PWD/bin/pebble" >> "$GITHUB_ENV"
70+
6571
- name: Configure and build nginx
6672
run: |
6773
make -j$(nproc) BUILD=sanitize build

build/get-pebble.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
VERSION="${1:-2.8.0}"
6+
SHA256SUM="$2"
7+
TARGET=${3:-bin/pebble}
8+
TARGET=$(realpath "$TARGET")
9+
10+
SYSTEM=$(uname -s | tr "[:upper:]" "[:lower:]")
11+
12+
if [ -z "$SHA256SUM" ]; then
13+
case "$SYSTEM" in
14+
linux)
15+
SHA256SUM="837d1fba39715fed3a378dea0ece5f3ddf404d114ec48fcc5c69bb987f22bdb3";;
16+
darwin)
17+
SHA256SUM="7a25d25aacb33e1939e44648f32347f922c1a51e54d3a92125f0881df7da9e4b";;
18+
*)
19+
echo "Unsupported platform: $SYSTEM";
20+
exit 1;
21+
esac
22+
fi
23+
24+
if echo "$SHA256SUM $TARGET" | sha256sum -c; then
25+
exit 0;
26+
fi
27+
28+
MACHINE=$(uname -m)
29+
case "$MACHINE" in
30+
aarch64)
31+
MACHINE=arm64;;
32+
x86_64)
33+
MACHINE=amd64;;
34+
esac
35+
36+
PREFIX="pebble-${SYSTEM}-${MACHINE}"
37+
38+
WORKDIR=$(mktemp -d)
39+
trap 'rm -rf "$WORKDIR"' EXIT
40+
41+
cd "$WORKDIR"
42+
curl -L -o "$PREFIX.tar.gz" \
43+
"https://github.com/letsencrypt/pebble/releases/download/v${VERSION}/${PREFIX}.tar.gz"
44+
tar -xzf "$PREFIX.tar.gz"
45+
46+
BINARY="$PREFIX/$SYSTEM/$MACHINE/pebble"
47+
if ! echo "$SHA256SUM $BINARY" | sha256sum -c; then
48+
echo "checksum mismatch"
49+
exit 1;
50+
fi
51+
52+
chmod +x "$BINARY"
53+
mkdir -p "$(dirname "$TARGET")"
54+
mv "$BINARY" "$TARGET"

t/acme_http.t

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use Test::Nginx::DNS;
2626
select STDERR; $| = 1;
2727
select STDOUT; $| = 1;
2828

29-
my $t = Test::Nginx->new()->has(qw/http socket_ssl/)
30-
->has_daemon('openssl')->has_daemon('pebble');
29+
my $t = Test::Nginx->new()->has(qw/http http_ssl socket_ssl/)
30+
->has_daemon('openssl');
3131

3232
$t->write_file_expand('nginx.conf', <<'EOF');
3333
@@ -129,7 +129,6 @@ sub get {
129129
http_get('/',
130130
PeerAddr => '127.0.0.1:' . port($port),
131131
SSL => 1,
132-
SSL_hostname => $host,
133132
$ca ? (
134133
SSL_ca_file => "$d/$ca.crt",
135134
SSL_verifycn_name => $host,

t/acme_key_type.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use Test::Nginx::DNS;
2626
select STDERR; $| = 1;
2727
select STDOUT; $| = 1;
2828

29-
my $t = Test::Nginx->new()->has(qw/http http_ssl socket_ssl/)
30-
->has_daemon('openssl')->has_daemon('pebble');
29+
my $t = Test::Nginx->new()->has(qw/http http_ssl sni socket_ssl_sni/)
30+
->has_daemon('openssl');
3131

3232
$t->write_file_expand('nginx.conf', <<'EOF');
3333

t/acme_multiple_issuers.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use Test::Nginx::DNS;
2626
select STDERR; $| = 1;
2727
select STDOUT; $| = 1;
2828

29-
my $t = Test::Nginx->new()->has(qw/http socket_ssl/)
30-
->has_daemon('openssl')->has_daemon('pebble');
29+
my $t = Test::Nginx->new()->has(qw/http http_ssl sni socket_ssl_sni/)
30+
->has_daemon('openssl');
3131

3232
$t->write_file_expand('nginx.conf', <<'EOF');
3333

t/acme_reload.t

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use Test::Nginx::DNS;
2626
select STDERR; $| = 1;
2727
select STDOUT; $| = 1;
2828

29-
my $t = Test::Nginx->new()->has(qw/http socket_ssl/)
30-
->has_daemon('openssl')->has_daemon('pebble');
29+
my $t = Test::Nginx->new()->has(qw/http http_ssl socket_ssl/)
30+
->has_daemon('openssl');
3131

3232
$t->write_file_expand('nginx.conf', <<'EOF');
3333
@@ -134,7 +134,6 @@ sub get {
134134
http_get('/',
135135
PeerAddr => '127.0.0.1:' . port($port),
136136
SSL => 1,
137-
SSL_hostname => $host,
138137
$ca ? (
139138
SSL_ca_file => "$d/$ca.crt",
140139
SSL_verifycn_name => $host,

t/acme_renewal.t

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use Test::Nginx::DNS;
2626
select STDERR; $| = 1;
2727
select STDOUT; $| = 1;
2828

29-
my $t = Test::Nginx->new()->has(qw/http socket_ssl/)
30-
->has_daemon('openssl')->has_daemon('pebble');
29+
my $t = Test::Nginx->new()->has(qw/http http_ssl socket_ssl/)
30+
->has_daemon('openssl');
3131

3232
$t->write_file_expand('nginx.conf', <<'EOF');
3333
@@ -133,7 +133,6 @@ sub get {
133133
http_get('/',
134134
PeerAddr => '127.0.0.1:' . port($port),
135135
SSL => 1,
136-
SSL_hostname => $host,
137136
$ca ? (
138137
SSL_ca_file => "$d/$ca.crt",
139138
SSL_verifycn_name => $host,

t/acme_ssl_verify.t

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use Test::Nginx::DNS;
2626
select STDERR; $| = 1;
2727
select STDOUT; $| = 1;
2828

29-
my $t = Test::Nginx->new()->has(qw/http socket_ssl/)
30-
->has_daemon('openssl')->has_daemon('pebble');
29+
my $t = Test::Nginx->new()->has(qw/http http_ssl socket_ssl/)
30+
->has_daemon('openssl');
3131

3232
$t->write_file_expand('nginx.conf', <<'EOF');
3333
@@ -126,7 +126,6 @@ sub get {
126126
http_get('/',
127127
PeerAddr => '127.0.0.1:' . port($port),
128128
SSL => 1,
129-
SSL_hostname => $host,
130129
$ca ? (
131130
SSL_ca_file => "$d/$ca.crt",
132131
SSL_verifycn_name => $host,

t/lib/Test/Nginx/ACME.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ our @EXPORT_OK = qw/ acme_test_daemon /;
1616
use File::Spec;
1717
use Test::Nginx qw//;
1818

19+
our $PEBBLE = $ENV{TEST_NGINX_PEBBLE_BINARY} // 'pebble';
20+
1921
sub new {
2022
my $self = {};
2123
bless $self, shift @_;
2224

2325
my ($t, $port, $mgmt, $cert, $key, %extra) = @_;
2426

27+
$t->has_daemon($PEBBLE);
28+
2529
my $http_port = $extra{http_port} || Test::Nginx::port(8080);
2630
my $tls_port = $extra{tls_port} || Test::Nginx::port(8443);
2731
my $validity = $extra{validity} || 3600;
@@ -115,7 +119,7 @@ sub acme_test_daemon {
115119
open STDERR, ">", $t->testdir . '/pebble-' . $port . '.err'
116120
or die "Can't reopen STDERR: $!";
117121

118-
exec('pebble', '-config', $t->testdir . '/pebble-' . $port . '.json',
122+
exec($PEBBLE, '-config', $t->testdir . '/pebble-' . $port . '.json',
119123
'-dnsserver', $dnsserver);
120124
}
121125

0 commit comments

Comments
 (0)