aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Dawson <michael_dawson@ca.ibm.com>2017-06-29 19:20:11 -0400
committerMichael Dawson <michael_dawson@ca.ibm.com>2017-07-18 14:03:23 -0400
commit3ccfeb483df5a6402da9b40346a7eb33cfb4b70a (patch)
tree878d224d17cfd4e9106f0871279110a913beec1e /test
parentf406a7ebaee09c00b6dec330e17897924096c30d (diff)
downloadandroid-node-v8-3ccfeb483df5a6402da9b40346a7eb33cfb4b70a.tar.gz
android-node-v8-3ccfeb483df5a6402da9b40346a7eb33cfb4b70a.tar.bz2
android-node-v8-3ccfeb483df5a6402da9b40346a7eb33cfb4b70a.zip
tls: migrate tls.js to use internal/errors.js
Migrate tls.js to use internal/errors.js as per https://github.com/nodejs/node/issues/11273 PR-URL: https://github.com/nodejs/node/pull/13994 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-https-strict.js17
-rw-r--r--test/parallel/test-internal-errors.js6
-rw-r--r--test/parallel/test-tls-client-verify.js3
-rw-r--r--test/parallel/test-tls-sni-option.js3
-rw-r--r--test/parallel/test-tls-sni-server-client.js2
5 files changed, 14 insertions, 17 deletions
diff --git a/test/parallel/test-https-strict.js b/test/parallel/test-https-strict.js
index 060151332d..7c2f64098f 100644
--- a/test/parallel/test-https-strict.js
+++ b/test/parallel/test-https-strict.js
@@ -170,13 +170,9 @@ function allListening() {
// server1: host 'agent1', signed by ca1
makeReq('/inv1', port1, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
- makeReq('/inv1-ca1', port1,
- 'Hostname/IP doesn\'t match certificate\'s altnames: ' +
- '"Host: localhost. is not cert\'s CN: agent1"',
+ makeReq('/inv1-ca1', port1, 'ERR_TLS_CERT_ALTNAME_INVALID',
null, ca1);
- makeReq('/inv1-ca1ca2', port1,
- 'Hostname/IP doesn\'t match certificate\'s altnames: ' +
- '"Host: localhost. is not cert\'s CN: agent1"',
+ makeReq('/inv1-ca1ca2', port1, 'ERR_TLS_CERT_ALTNAME_INVALID',
null, [ca1, ca2]);
makeReq('/val1-ca1', port1, null, 'agent1', ca1);
makeReq('/val1-ca1ca2', port1, null, 'agent1', [ca1, ca2]);
@@ -193,13 +189,8 @@ function allListening() {
// server3: host 'agent3', signed by ca2
makeReq('/inv3', port3, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
- makeReq('/inv3-ca2', port3,
- 'Hostname/IP doesn\'t match certificate\'s altnames: ' +
- '"Host: localhost. is not cert\'s CN: agent3"',
- null, ca2);
- makeReq('/inv3-ca1ca2', port3,
- 'Hostname/IP doesn\'t match certificate\'s altnames: ' +
- '"Host: localhost. is not cert\'s CN: agent3"',
+ makeReq('/inv3-ca2', port3, 'ERR_TLS_CERT_ALTNAME_INVALID', null, ca2);
+ makeReq('/inv3-ca1ca2', port3, 'ERR_TLS_CERT_ALTNAME_INVALID',
null, [ca1, ca2]);
makeReq('/val3-ca2', port3, null, 'agent3', ca2);
makeReq('/val3-ca1ca2', port3, null, 'agent3', [ca1, ca2]);
diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js
index 8e06bab349..4fb99d8fa3 100644
--- a/test/parallel/test-internal-errors.js
+++ b/test/parallel/test-internal-errors.js
@@ -229,3 +229,9 @@ assert.throws(
code: 'ERR_ASSERTION',
message: /^At least one arg needs to be specified$/
}));
+
+
+// Test ERR_TLS_CERT_ALTNAME_INVALID
+assert.strictEqual(
+ errors.message('ERR_TLS_CERT_ALTNAME_INVALID', ['altname']),
+ 'Hostname/IP does not match certificate\'s altnames: altname');
diff --git a/test/parallel/test-tls-client-verify.js b/test/parallel/test-tls-client-verify.js
index 2171851665..097ec264e7 100644
--- a/test/parallel/test-tls-client-verify.js
+++ b/test/parallel/test-tls-client-verify.js
@@ -29,7 +29,6 @@ const fs = require('fs');
const path = require('path');
const tls = require('tls');
-const hosterr = /Hostname\/IP doesn't match certificate's altnames/;
const testCases =
[{ ca: ['ca1-cert'],
key: 'agent2-key',
@@ -101,7 +100,7 @@ function testServers(index, servers, clientOptions, cb) {
clientOptions.port = this.address().port;
const client = tls.connect(clientOptions, common.mustCall(function() {
const authorized = client.authorized ||
- hosterr.test(client.authorizationError);
+ (client.authorizationError === 'ERR_TLS_CERT_ALTNAME_INVALID');
console.error(`expected: ${ok} authed: ${authorized}`);
diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js
index f744b6db54..c211b695d4 100644
--- a/test/parallel/test-tls-sni-option.js
+++ b/test/parallel/test-tls-sni-option.js
@@ -141,7 +141,8 @@ function startTest() {
options.port = server.address().port;
const client = tls.connect(options, function() {
clientResults.push(
- /Hostname\/IP doesn't/.test(client.authorizationError || ''));
+ client.authorizationError &&
+ (client.authorizationError === 'ERR_TLS_CERT_ALTNAME_INVALID'));
client.destroy();
next();
diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js
index 83fd50c066..14ad9e7c83 100644
--- a/test/parallel/test-tls-sni-server-client.js
+++ b/test/parallel/test-tls-sni-server-client.js
@@ -113,7 +113,7 @@ function startTest() {
const client = tls.connect(options, function() {
clientResults.push(
client.authorizationError &&
- /Hostname\/IP doesn't/.test(client.authorizationError));
+ (client.authorizationError === 'ERR_TLS_CERT_ALTNAME_INVALID'));
client.destroy();
// Continue