test: set clientOpts.port property

Currently this test will overwrite the clientOpts object with the port,
instead of setting the port property on the clientOpts object which
looks like the original intent.

Doing this the test fails reporting that the fake-cnnic-root-cert has
expired. This is indeed true:
$ openssl x509 -in test/fixtures/keys/fake-cnnic-root-cert.pem \
-text -noout
Certificate:
        ...
        Validity
            Not Before: Jun  9 17:15:16 2015 GMT
            Not After : Mar 29 17:15:16 2018 GMT

This commit sets the errorCode to CERT_HAS_EXPIRED. I tried updating the
certificate using test/fixtures/keys/Makefile but then no error is
thrown and I'm currently looking into this.

PR-URL: https://github.com/nodejs/node/pull/19767
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Daniel Bevenius 2018-04-03 10:35:45 +02:00 committed by James M Snell
parent 5879f480b1
commit 7a33c2cc7c

View File

@ -28,7 +28,7 @@ const testCases = [
rejectUnauthorized: true,
ca: [loadPEM('fake-cnnic-root-cert')]
},
errorCode: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
errorCode: 'CERT_HAS_EXPIRED'
},
// Test 1: for the fix of node#2061
// agent6-cert.pem is signed by intermediate cert of ca3.
@ -58,7 +58,7 @@ function runTest(tindex) {
const server = tls.createServer(tcase.serverOpts, (s) => {
s.resume();
}).listen(0, common.mustCall(function() {
tcase.clientOpts = this.address().port;
tcase.clientOpts.port = this.address().port;
const client = tls.connect(tcase.clientOpts);
client.on('error', common.mustCall((e) => {
assert.strictEqual(e.code, tcase.errorCode);