Skip to content

Commit bec0421

Browse files
davidbenevanlucas
authored andcommitted
test: update test expectations for OpenSSL 1.1.0
Some errors in the two versions are different. The test-tls-no-sslv3 one because OpenSSL 1.1.x finally does version negotiation properly. 1.0.x's logic was somewhat weird and resulted in very inconsistent errors for SSLv3 in particular. Also the function codes are capitalized differently, but function codes leak implementation details, so don't assert on them to begin with. PR-URL: #16130 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent 8a8ac8c commit bec0421

5 files changed

Lines changed: 13 additions & 5 deletions

‎test/parallel/test-crypto.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ assert.throws(function() {
238238
// Throws crypto error, so there is an opensslErrorStack property.
239239
// The openSSL stack should have content.
240240
if((errinstanceofError)&&
241-
/asn1encodingroutines:ASN1_CHECK_TLEN:wrongtag/.test(err)&&
241+
/asn1encodingroutines:[^:]*:wrongtag/.test(err)&&
242242
err.opensslErrorStack!==undefined&&
243243
Array.isArray(err.opensslErrorStack)&&
244244
err.opensslErrorStack.length>0){

‎test/parallel/test-tls-junk-server.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ server.listen(0, function() {
2121
req.end();
2222

2323
req.once('error',common.mustCall(function(err){
24-
assert(/unknownprotocol/.test(err.message));
24+
// OpenSSL 1.0.x and 1.1.x use different error messages for junk inputs.
25+
assert(/unknownprotocol/.test(err.message)||
26+
/wrongversionnumber/.test(err.message));
2527
server.close();
2628
}));
2729
});

‎test/parallel/test-tls-no-sslv3.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ process.on('exit', function() {
4646
common.printSkipMessage('`openssl s_client -ssl3` not supported.');
4747
}else{
4848
assert.strictEqual(errors.length,1);
49-
assert(/:wrongversionnumber/.test(errors[0].message));
49+
// OpenSSL 1.0.x and 1.1.x report invalid client versions differently.
50+
assert(/:wrongversionnumber/.test(errors[0].message)||
51+
/:versiontoolow/.test(errors[0].message));
5052
}
5153
});

‎test/parallel/test-tls-server-failed-handshake-emits-clienterror.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ const server = tls.createServer({})
2020
}).on('tlsClientError',common.mustCall(function(e){
2121
assert.ok(einstanceofError,
2222
'Instance of Error should be passed to error handler');
23+
// OpenSSL 1.0.x and 1.1.x use different error codes for junk inputs.
2324
assert.ok(
24-
/SSLroutines:SSL23_GET_CLIENT_HELLO:unknownprotocol/.test(e.message),
25+
/SSLroutines:[^:]*:(unknownprotocol|wrongversionnumber)/.test(
26+
e.message),
2527
'Expecting SSL unknown protocol');
2628

2729
server.close();

‎test/parallel/test-tls-socket-failed-handshake-emits-error.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ const server = net.createServer(function(c) {
2020
s.on('error',common.mustCall(function(e){
2121
assert.ok(einstanceofError,
2222
'Instance of Error should be passed to error handler');
23+
// OpenSSL 1.0.x and 1.1.x use different error codes for junk inputs.
2324
assert.ok(
24-
/SSLroutines:SSL23_GET_CLIENT_HELLO:unknownprotocol/.test(e.message),
25+
/SSLroutines:[^:]*:(unknownprotocol|wrongversionnumber)/.test(
26+
e.message),
2527
'Expecting SSL unknown protocol');
2628
}));
2729

0 commit comments

Comments
 (0)