test: improve crypto test coverage
- Call Sign without new - Call Verify without new - Call Verify#verify with options.padding !== options.padding >> 0 - Call Verify#verify with options.saltLength !== options.saltLength >> 0 PR-URL: https://github.com/nodejs/node/pull/17426 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
bf26d92c26
commit
0ab98f1e60
@ -15,6 +15,42 @@ const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
|||||||
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||||
const modSize = 1024;
|
const modSize = 1024;
|
||||||
|
|
||||||
|
{
|
||||||
|
const Sign = crypto.Sign;
|
||||||
|
const instance = Sign('SHA256');
|
||||||
|
assert(instance instanceof Sign, 'Sign is expected to return a new ' +
|
||||||
|
'instance when called without `new`');
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const Verify = crypto.Verify;
|
||||||
|
const instance = Verify('SHA256');
|
||||||
|
assert(instance instanceof Verify, 'Verify is expected to return a new ' +
|
||||||
|
'instance when called without `new`');
|
||||||
|
}
|
||||||
|
|
||||||
|
common.expectsError(
|
||||||
|
() => crypto.createVerify('SHA256').verify({
|
||||||
|
key: certPem,
|
||||||
|
padding: undefined,
|
||||||
|
}, ''),
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_OPT_VALUE',
|
||||||
|
type: Error,
|
||||||
|
message: 'The value "undefined" is invalid for option "padding"'
|
||||||
|
});
|
||||||
|
|
||||||
|
common.expectsError(
|
||||||
|
() => crypto.createVerify('SHA256').verify({
|
||||||
|
key: certPem,
|
||||||
|
saltLength: undefined,
|
||||||
|
}, ''),
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_OPT_VALUE',
|
||||||
|
type: Error,
|
||||||
|
message: 'The value "undefined" is invalid for option "saltLength"'
|
||||||
|
});
|
||||||
|
|
||||||
// Test signing and verifying
|
// Test signing and verifying
|
||||||
{
|
{
|
||||||
const s1 = crypto.createSign('SHA1')
|
const s1 = crypto.createSign('SHA1')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user