Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add missing test about crypto.Decipheriv()
- Call constructor without new keyword
- Call constructor with cipher is not string
- Call constructor with cipher is string and key is not string
- Call constructor with cipher is strong, key is string and iv is not string
  • Loading branch information
Leko committed Dec 4, 2017
commit b7dee5e3b40ddf06e73dc02011dae99af552c434
36 changes: 36 additions & 0 deletions test/parallel/test-crypto-cipheriv-decipheriv.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,42 @@ function testCipher3(key, iv) {
});
}

{
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(
() => new Decipheriv(null),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "cipher" argument must be of type string'
});

common.expectsError(
() => new Decipheriv('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(
() => new Decipheriv('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');
Expand Down