From f3c3b1d328ade058041416a00f658b17edfc8ccc Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 30 Nov 2019 11:28:38 -0800 Subject: [PATCH] test: add coverage for ERR_TLS_INVALID_PROTOCOL_VERSION There is currently no test that confirms that an invalid TLS protocol results in ERR_TLS_INVALID_PROTOCOL_VERSION. Add tests to check this for the `minVersion` and `maxVersion` options in `createSecureContext()`. Refs: https://codecov.io/gh/nodejs/node/src/c14c476614e3134867ddb997bdfe5a41ba668175/lib/_tls_common.js#L56 Refs: https://coverage.nodejs.org/coverage-c14c476614e31348/lib/_tls_common.js.html#L56 PR-URL: https://github.com/nodejs/node/pull/30741 Reviewed-By: Luigi Pinca Reviewed-By: Sam Roberts Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- test/parallel/test-tls-basic-validations.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/parallel/test-tls-basic-validations.js b/test/parallel/test-tls-basic-validations.js index 925c6643a1a0cc..7cc6f3bf419b3f 100644 --- a/test/parallel/test-tls-basic-validations.js +++ b/test/parallel/test-tls-basic-validations.js @@ -114,3 +114,15 @@ common.expectsInternalAssertion( } ); } + +assert.throws(() => { tls.createSecureContext({ minVersion: 'fhqwhgads' }); }, + { + code: 'ERR_TLS_INVALID_PROTOCOL_VERSION', + name: 'TypeError' + }); + +assert.throws(() => { tls.createSecureContext({ maxVersion: 'fhqwhgads' }); }, + { + code: 'ERR_TLS_INVALID_PROTOCOL_VERSION', + name: 'TypeError' + });