Skip to content

Commit 4a642b9

Browse files
ejc-mainjasnell
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 ebb3a09 commit 4a642b9

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

test/pummel/test-crypto-dh.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,32 @@ try {
99
return;
1010
}
1111

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

2239
var hashes = {
2340
modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',

0 commit comments

Comments
 (0)