Skip to content

Commit e9304a8

Browse files
committed
test: address review feedback on ssl/stream-mtls tests
- t/ssl.t: guard the openresty version parse so an unexpected `nginx -V` output falls back to the pre-1.29 wording instead of warning on an undef numeric comparison. - t/stream/upstream_mtls.t: TEST 2 now also asserts the upstream rejects the request ("No required SSL certificate was sent"), proving the handshake did not succeed when set_cert_and_key rejected the missing key, not just that the argument was rejected.
1 parent f953f0a commit e9304a8

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

t/ssl.t

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ no_long_string();
88
# reworded in OpenResty 1.29.2.4. Detect the running version once and pick
99
# the exact expected message, so a wrong-message regression is still caught.
1010
my $nginx_binary = $ENV{'TEST_NGINX_BINARY'} || 'nginx';
11-
my $version = eval { `$nginx_binary -V 2>&1` };
11+
my $version = eval { `$nginx_binary -V 2>&1` } // '';
1212
my ($major, $minor) = $version =~ m{openresty/(\d+)\.(\d+)};
13-
my $reworded = ($major > 1 or ($major == 1 and $minor >= 29));
13+
# If the version cannot be parsed, fall back to the pre-1.29 wording rather
14+
# than warning on an undef numeric compare.
15+
my $reworded = defined $major && defined $minor
16+
&& ($major > 1 || ($major == 1 && $minor >= 29));
1417

1518
$::err_cert_both_set = $reworded
1619
? "client_cert_path and client_cert cannot both be set"

t/stream/upstream_mtls.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ __DATA__
8686
"GET / HTTP/1.0\r\nHost: admin.apisix.dev\r\n\r\n"
8787
--- error_log
8888
set_cert_and_key failed: both client certificate and private key should be given
89+
# no client cert was applied, so the upstream mTLS must not succeed: the
90+
# verify-on upstream rejects the request instead of printing "client verify:
91+
# SUCCESS"
92+
--- stream_response_like: No required SSL certificate was sent
8993
9094
9195

0 commit comments

Comments
 (0)