diff options
author | Leko <leko.noor@gmail.com> | 2017-12-05 01:24:37 +0900 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2017-12-08 10:32:49 -0500 |
commit | 6707903faecbeadfd1fd2ca3e69650d0d9a46344 (patch) | |
tree | dd7c04a321915ad03ac755d7426cf8cecb484aed /test/parallel/test-crypto-cipheriv-decipheriv.js | |
parent | 84b7a8678690a937b70a8edcfe47208d6d402215 (diff) | |
download | android-node-v8-6707903faecbeadfd1fd2ca3e69650d0d9a46344.tar.gz android-node-v8-6707903faecbeadfd1fd2ca3e69650d0d9a46344.tar.bz2 android-node-v8-6707903faecbeadfd1fd2ca3e69650d0d9a46344.zip |
test: improve coverage for Cipheriv and Decipheriv
PR-URL: https://github.com/nodejs/node/pull/17458
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-crypto-cipheriv-decipheriv.js')
-rw-r--r-- | test/parallel/test-crypto-cipheriv-decipheriv.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js index 01f6717e67..82a144257c 100644 --- a/test/parallel/test-crypto-cipheriv-decipheriv.js +++ b/test/parallel/test-crypto-cipheriv-decipheriv.js @@ -78,6 +78,78 @@ function testCipher3(key, iv) { `encryption/decryption with key ${key} and iv ${iv}`); } +{ + const Cipheriv = crypto.Cipheriv; + const key = '123456789012345678901234'; + const iv = '12345678'; + + const instance = Cipheriv('des-ede3-cbc', key, iv); + assert(instance instanceof Cipheriv, 'Cipheriv is expected to return a new ' + + 'instance when called without `new`'); + + common.expectsError( + () => crypto.createCipheriv(null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "cipher" argument must be of type string' + }); + + common.expectsError( + () => crypto.createCipheriv('des-ede3-cbc', null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "key" argument must be one of type string, Buffer, ' + + 'TypedArray, or DataView' + }); + + common.expectsError( + () => crypto.createCipheriv('des-ede3-cbc', key, null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "iv" argument must be one of type string, Buffer, ' + + 'TypedArray, or DataView' + }); +} + +{ + const Decipheriv = crypto.Decipheriv; + const key = '123456789012345678901234'; + const iv = '12345678'; + + const instance = Decipheriv('des-ede3-cbc', key, iv); + assert(instance instanceof Decipheriv, 'Decipheriv expected to return a new' + + ' instance when called without `new`'); + + common.expectsError( + () => crypto.createDecipheriv(null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "cipher" argument must be of type string' + }); + + common.expectsError( + () => crypto.createDecipheriv('des-ede3-cbc', null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "key" argument must be one of type string, Buffer, ' + + 'TypedArray, or DataView' + }); + + common.expectsError( + () => crypto.createDecipheriv('des-ede3-cbc', key, null), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "iv" argument must be one of type string, Buffer, ' + + 'TypedArray, or DataView' + }); +} + testCipher1('0123456789abcd0123456789', '12345678'); testCipher1('0123456789abcd0123456789', Buffer.from('12345678')); testCipher1(Buffer.from('0123456789abcd0123456789'), '12345678'); |