Skip to content

Commit

Permalink
test: simplify test-crypto-dh-group-setters
Browse files Browse the repository at this point in the history
I can't tell why the test was written that way in the first place, but
it seems sufficient to check that setPrivateKey and setPublicKey are
both undefined.

Refs: nodejs/node-v0.x-archive#2638
Refs: #11253
PR-URL: #49404
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
tniessen authored and UlisesGascon committed Sep 10, 2023
1 parent 6740f3c commit 2a35782
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions test/parallel/test-crypto-dh-group-setters.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');

assert.throws(
function() {
crypto.getDiffieHellman('modp1').setPrivateKey('');
},
new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' +
'setPrivateKey is not a function$'),
'crypto.getDiffieHellman(\'modp1\').setPrivateKey(\'\') ' +
'failed to throw the expected error.'
);
assert.throws(
function() {
crypto.getDiffieHellman('modp1').setPublicKey('');
},
new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' +
'setPublicKey is not a function$'),
'crypto.getDiffieHellman(\'modp1\').setPublicKey(\'\') ' +
'failed to throw the expected error.'
);
// Unlike DiffieHellman, DiffieHellmanGroup does not have any setters.
const dhg = crypto.getDiffieHellman('modp1');
assert.strictEqual(dhg.constructor, crypto.DiffieHellmanGroup);
assert.strictEqual(dhg.setPrivateKey, undefined);
assert.strictEqual(dhg.setPublicKey, undefined);

0 comments on commit 2a35782

Please sign in to comment.