Skip to content

Commit

Permalink
test: crypto createClass instanceof Class
Browse files Browse the repository at this point in the history
The crypto classes are also exposed as createClass for each class. This
tests that each of them returns an instance of the class in question.

PR-URL: nodejs/node#8188
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
bengl authored and addaleax committed Sep 30, 2017
1 parent 14c9585 commit 9462ec1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/parallel/test-crypto-classes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';
const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');

// 'ClassName' : ['args', 'for', 'constructor']
const TEST_CASES = {
'Hash': ['sha1'],
'Hmac': ['sha1', 'Node'],
'Cipheriv': ['des-ede3-cbc', '0123456789abcd0123456789', '12345678'],
'Decipheriv': ['des-ede3-cbc', '0123456789abcd0123456789', '12345678'],
'Sign': ['RSA-SHA1'],
'Verify': ['RSA-SHA1'],
'DiffieHellman': [1024],
'DiffieHellmanGroup': ['modp5'],
'Credentials': []
};

if (!common.hasFipsCrypto) {
TEST_CASES.Cipher = ['aes192', 'secret'];
TEST_CASES.Decipher = ['aes192', 'secret'];
}

for (const [clazz, args] of Object.entries(TEST_CASES)) {
assert(crypto[`create${clazz}`](...args) instanceof crypto[clazz]);
}

0 comments on commit 9462ec1

Please sign in to comment.