@@ -20,6 +20,9 @@ use Test::More qw//;
2020
2121use Test::Nginx qw/ / ;
2222
23+ eval { require JSON::PP; };
24+ Test::More::plan(skip_all => " JSON::PP not installed" ) if $@ ;
25+
2326our $PEBBLE = $ENV {TEST_NGINX_PEBBLE_BINARY } // ' pebble' ;
2427
2528my %features = (
@@ -49,26 +52,28 @@ sub new {
4952
5053 $self -> {state } = $extra {state } // $t -> testdir();
5154
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 );
7277
7378 return $self ;
7479}
@@ -80,7 +85,7 @@ sub port {
8085
8186sub trusted_ca {
8287 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 });
8489 my $cert = _get_body($self -> {mgmt }, ' /roots/0' );
8590 $cert =~ s / (BEGIN|END) C/ $1 TRUSTED C/ g ;
8691 $cert ;
@@ -172,7 +177,8 @@ sub acme_test_daemon {
172177 my $dnsserver = ' 127.0.0.1:' . $acme -> {dns_port };
173178
174179 $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 };
176182
177183 open STDOUT , " >" , $t -> testdir . ' /pebble-' . $port . ' .out'
178184 or die " Can't reopen STDOUT: $! " ;
0 commit comments