Skip to content

Commit 7590fea

Browse files
committed
fixup! Tests: ACME client tests.
1 parent b0f6922 commit 7590fea

File tree

10 files changed

+89
-19
lines changed

10 files changed

+89
-19
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,30 @@ jobs:
8181
toolchain: ${{ matrix.rust-version }}
8282
components: clippy, rustfmt
8383

84+
- uses: perl-actions/install-with-cpm@8b1a9840b26cc3885ae2889749a48629be2501b0 # v1.9
85+
with:
86+
install: IO::Socket::SSL
87+
8488
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
8589
with:
8690
path: |
8791
~/.cargo/bin/
8892
~/.cargo/registry/index/
8993
~/.cargo/registry/cache/
9094
~/.cargo/git/db/
95+
bin/pebble
9196
nginx/objs/**/CACHEDIR.TAG
9297
nginx/objs/**/ngx-debug
9398
nginx/objs/**/ngx-release
99+
target/
94100
key: ${{ runner.os }}-nginx-${{ hashFiles('**/Cargo.lock') }}
95101
restore-keys: ${{ runner.os }}-nginx-
96102

103+
- name: download pebble
104+
run: |
105+
build/get-pebble.sh
106+
echo TEST_NGINX_PEBBLE_BINARY="$PWD/bin/pebble" >> "$GITHUB_ENV"
107+
97108
- name: build
98109
id: build
99110
run: make BUILD=${{ matrix.build }} -j $(nproc) build

.github/workflows/sanitizers.yaml

Lines changed: 8 additions & 2 deletions
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: download pebble
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
@@ -75,4 +81,4 @@ jobs:
7581
TEST_NGINX_GLOBALS: >-
7682
user root;
7783
run: |
78-
make -j$(nproc) BUILD=sanitize test
84+
make -j$(nproc) BUILD=sanitize TEST_PREREQ= test

build/get-pebble.sh

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