Skip to content

Commit 4509d84

Browse files
ejc-mainaddaleax
authored andcommitted
test: improve coverage in test-crypto.dh
PR-URL: #11253 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4b4bc13 commit 4509d84

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

test/pummel/test-crypto-dh.js

+26-9
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,32 @@ if (!common.hasCrypto) {
88
return;
99
}
1010

11-
assert.throws(function() {
12-
crypto.getDiffieHellman('unknown-group');
13-
});
14-
assert.throws(function() {
15-
crypto.getDiffieHellman('modp1').setPrivateKey('');
16-
});
17-
assert.throws(function() {
18-
crypto.getDiffieHellman('modp1').setPublicKey('');
19-
});
11+
assert.throws(
12+
function() {
13+
crypto.getDiffieHellman('unknown-group');
14+
},
15+
/^Error: Unknown group$/,
16+
'crypto.getDiffieHellman(\'unknown-group\') ' +
17+
'failed to throw the expected error.'
18+
);
19+
assert.throws(
20+
function() {
21+
crypto.getDiffieHellman('modp1').setPrivateKey('');
22+
},
23+
new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' +
24+
'setPrivateKey is not a function$'),
25+
'crypto.getDiffieHellman(\'modp1\').setPrivateKey(\'\') ' +
26+
'failed to throw the expected error.'
27+
);
28+
assert.throws(
29+
function() {
30+
crypto.getDiffieHellman('modp1').setPublicKey('');
31+
},
32+
new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' +
33+
'setPublicKey is not a function$'),
34+
'crypto.getDiffieHellman(\'modp1\').setPublicKey(\'\') ' +
35+
'failed to throw the expected error.'
36+
);
2037

2138
const hashes = {
2239
modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',

0 commit comments

Comments
 (0)