@@ -20,6 +20,9 @@ use Test::More qw//;
20
20
21
21
use Test::Nginx qw/ / ;
22
22
23
+ eval { require JSON::PP; };
24
+ Test::More::plan(skip_all => " JSON::PP not installed" ) if $@ ;
25
+
23
26
our $PEBBLE = $ENV {TEST_NGINX_PEBBLE_BINARY } // ' pebble' ;
24
27
25
28
my %features = (
@@ -49,26 +52,28 @@ sub new {
49
52
50
53
$self -> {state } = $extra {state } // $t -> testdir();
51
54
52
- $t -> write_file(" pebble-$port .json" , <<EOF );
53
- {
54
- "pebble": {
55
- "listenAddress": "127.0.0.1:$port ",
56
- "managementListenAddress": "127.0.0.1:$mgmt ",
57
- "certificate": "$cert ",
58
- "privateKey": "$key ",
59
- "httpPort": $http_port ,
60
- "tlsPort": $tls_port ,
61
- "ocspResponderURL": "",
62
- "certificateValidityPeriod": $validity ,
63
- "profiles": {
64
- "default": {
65
- "description": "The default profile",
66
- "validityPeriod": $validity
67
- }
68
- }
69
- }
70
- }
71
- EOF
55
+ my %conf = (
56
+ listenAddress => ' 127.0.0.1:' . $port ,
57
+ managementListenAddress => ' 127.0.0.1:' . $mgmt ,
58
+ certificate => $cert ,
59
+ privateKey => $key ,
60
+ httpPort => $http_port + 0,
61
+ tlsPort => $tls_port + 0,
62
+ ocspResponderURL => ' ' ,
63
+ certificateValidityPeriod => $validity + 0,
64
+ profiles => {
65
+ default => {
66
+ validityPeriod => $validity + 0,
67
+ }
68
+ },
69
+ );
70
+
71
+ # merge custom configuration
72
+
73
+ @conf { keys %{$extra {conf }} } = values %{$extra {conf }};
74
+
75
+ my $conf = JSON::PP-> new()-> canonical()-> encode({ pebble => \%conf });
76
+ $t -> write_file(" pebble-$port .json" , $conf );
72
77
73
78
return $self ;
74
79
}
@@ -80,7 +85,7 @@ sub port {
80
85
81
86
sub trusted_ca {
82
87
my $self = shift ;
83
- Test::Nginx::log_core(' || Fetching certificate from port ' , $self -> {mgmt });
88
+ Test::Nginx::log_core(' || ACME: get certificate from' , $self -> {mgmt });
84
89
my $cert = _get_body($self -> {mgmt }, ' /roots/0' );
85
90
$cert =~ s / (BEGIN|END) C/ $1 TRUSTED C/ g ;
86
91
$cert ;
@@ -172,7 +177,8 @@ sub acme_test_daemon {
172
177
my $dnsserver = ' 127.0.0.1:' . $acme -> {dns_port };
173
178
174
179
$ENV {PEBBLE_VA_NOSLEEP } = 1 if $acme -> {nosleep };
175
- $ENV {PEBBLE_WFE_NONCEREJECT } = $acme -> {noncereject } if $acme -> {noncereject };
180
+ $ENV {PEBBLE_WFE_NONCEREJECT } =
181
+ $acme -> {noncereject } if $acme -> {noncereject };
176
182
177
183
open STDOUT , " >" , $t -> testdir . ' /pebble-' . $port . ' .out'
178
184
or die " Can't reopen STDOUT: $! " ;
0 commit comments