-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tls clientcertengine tests
- Loading branch information
1 parent
7d49bd0
commit 121245f
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
test/parallel/test-tls-clientcertengine-invalid-arg-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const tls = require('tls'); | ||
|
||
{ | ||
assert.throws( | ||
() => { tls.createSecureContext({ clientCertEngine: 0 }); }, | ||
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', | ||
message: / Received type number$/ })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
// Monkey-patch SecureContext | ||
const binding = process.binding('crypto'); | ||
const NativeSecureContext = binding.SecureContext; | ||
|
||
binding.SecureContext = function() { | ||
const rv = new NativeSecureContext(); | ||
rv.setClientCertEngine = undefined; | ||
return rv; | ||
}; | ||
|
||
const assert = require('assert'); | ||
const tls = require('tls'); | ||
|
||
{ | ||
assert.throws( | ||
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); }, | ||
common.expectsError({ | ||
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED', | ||
message: 'Custom engines not supported by this OpenSSL' | ||
}) | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
test/parallel/test-tls-server-setoptions-clientcertengine.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const tls = require('tls'); | ||
|
||
{ | ||
const server = tls.createServer(); | ||
assert.strictEqual(server.clientCertEngine, undefined); | ||
server.setOptions({ clientCertEngine: 'Cannonmouth' }); | ||
assert.strictEqual(server.clientCertEngine, 'Cannonmouth'); | ||
} |
121245f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SEMVER-MINOR
PR-URL: #14903
Reviewed-By: Daniel Bevenius [email protected]
Reviewed-By: Fedor Indutny [email protected]
Reviewed-By: Anna Henningsen [email protected]
Reviewed-By: Ben Noordhuis [email protected]