From 93bbd521fe6c7d58f353e8214c07e79554b56256 Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 22:03:04 +0900 Subject: [PATCH 1/9] test: add test call crypt.Sign without new --- test/parallel/test-crypto-sign-verify.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 5f0f8d8c7ebc04..3ebe5e0a8a6ee2 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -15,6 +15,12 @@ const certPem = fixtures.readSync('test_cert.pem', 'ascii'); const keyPem = fixtures.readSync('test_key.pem', 'ascii'); const modSize = 1024; +{ + const Sign = crypto.Sign + const instance = Sign('SHA256') + assert.ok(instance instanceof Sign, 'call sign constructor without new') +} + // Test signing and verifying { const s1 = crypto.createSign('SHA1') From fddf884ef24d4aaf6fd1d4ad052c1bf871b97deb Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 22:03:20 +0900 Subject: [PATCH 2/9] test: add test call crypt.Verify without new --- test/parallel/test-crypto-sign-verify.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 3ebe5e0a8a6ee2..7e4f029b3e9a10 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -21,6 +21,12 @@ const modSize = 1024; assert.ok(instance instanceof Sign, 'call sign constructor without new') } +{ + const Verify = crypto.Verify + const instance = Verify('SHA256') + assert.ok(instance instanceof Verify, 'call sign constructor without new') +} + // Test signing and verifying { const s1 = crypto.createSign('SHA1') From e6a004e3e02a40d6a4b592212f4a1d5bd6804140 Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 22:19:32 +0900 Subject: [PATCH 3/9] test: add test padding is undefined --- test/parallel/test-crypto-sign-verify.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 7e4f029b3e9a10..936adf8420c54f 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -27,6 +27,17 @@ const modSize = 1024; assert.ok(instance instanceof Verify, 'call sign constructor 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"' + }) + // Test signing and verifying { const s1 = crypto.createSign('SHA1') From dbfb9659dfa7f1e70e45e7ebff58c75b7b74acc5 Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 22:20:18 +0900 Subject: [PATCH 4/9] test: add test saltLength is undefined --- test/parallel/test-crypto-sign-verify.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 936adf8420c54f..9398cb58add236 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -38,6 +38,17 @@ common.expectsError( 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 { const s1 = crypto.createSign('SHA1') From 355029e1c2d1c456fda028f18d1c8dc1966645a0 Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 22:57:52 +0900 Subject: [PATCH 5/9] test: add missing semi coron --- test/parallel/test-crypto-sign-verify.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 9398cb58add236..b5c7df0814d85f 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -16,15 +16,15 @@ const keyPem = fixtures.readSync('test_key.pem', 'ascii'); const modSize = 1024; { - const Sign = crypto.Sign - const instance = Sign('SHA256') - assert.ok(instance instanceof Sign, 'call sign constructor without new') + const Sign = crypto.Sign; + const instance = Sign('SHA256'); + assert.ok(instance instanceof Sign, 'call sign constructor without new'); } { - const Verify = crypto.Verify - const instance = Verify('SHA256') - assert.ok(instance instanceof Verify, 'call sign constructor without new') + const Verify = crypto.Verify; + const instance = Verify('SHA256'); + assert.ok(instance instanceof Verify, 'call sign constructor without new'); } common.expectsError( @@ -36,7 +36,7 @@ common.expectsError( code: 'ERR_INVALID_OPT_VALUE', type: Error, message: 'The value "undefined" is invalid for option "padding"' - }) + }); common.expectsError( () => crypto.createVerify('SHA256').verify({ @@ -47,7 +47,7 @@ common.expectsError( code: 'ERR_INVALID_OPT_VALUE', type: Error, message: 'The value "undefined" is invalid for option "saltLength"' - }) + }); // Test signing and verifying { From dabbdf990fc8978dd007116b2e6c3ad7eaf99f5d Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 2 Dec 2017 23:24:21 +0900 Subject: [PATCH 6/9] test: Fix typo sign -> verify --- test/parallel/test-crypto-sign-verify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index b5c7df0814d85f..54b734f5e2e414 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -24,7 +24,7 @@ const modSize = 1024; { const Verify = crypto.Verify; const instance = Verify('SHA256'); - assert.ok(instance instanceof Verify, 'call sign constructor without new'); + assert.ok(instance instanceof Verify, 'call verify constructor without new'); } common.expectsError( From 0b80e146f3aa48117fb5e8dac8c7004ed1f51e2c Mon Sep 17 00:00:00 2001 From: Leko Date: Sun, 3 Dec 2017 01:45:42 +0900 Subject: [PATCH 7/9] test: add expected behavior to assertion error message --- test/parallel/test-crypto-sign-verify.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 54b734f5e2e414..08d02ef44a151d 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -18,13 +18,15 @@ const modSize = 1024; { const Sign = crypto.Sign; const instance = Sign('SHA256'); - assert.ok(instance instanceof Sign, 'call sign constructor without new'); + assert.ok(instance instanceof Sign, 'Sign is expected to return a new \ + instance when called without `new` keyword'); } { const Verify = crypto.Verify; const instance = Verify('SHA256'); - assert.ok(instance instanceof Verify, 'call verify constructor without new'); + assert.ok(instance instanceof Verify, 'Verify is expected to return a new \ + instance when called without `new` keyword'); } common.expectsError( From fc3ffc925d858638d0f13d0cd093c287d4404ca2 Mon Sep 17 00:00:00 2001 From: Leko Date: Sun, 3 Dec 2017 01:55:28 +0900 Subject: [PATCH 8/9] test: use + to break strings and fix indent --- test/parallel/test-crypto-sign-verify.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 08d02ef44a151d..c11e2009aac1ba 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -18,15 +18,15 @@ const modSize = 1024; { const Sign = crypto.Sign; const instance = Sign('SHA256'); - assert.ok(instance instanceof Sign, 'Sign is expected to return a new \ - instance when called without `new` keyword'); + assert.ok(instance instanceof Sign, 'Sign is expected to return a new ' + + 'instance when called without `new`'); } { const Verify = crypto.Verify; const instance = Verify('SHA256'); - assert.ok(instance instanceof Verify, 'Verify is expected to return a new \ - instance when called without `new` keyword'); + assert.ok(instance instanceof Verify, 'Verify is expected to return a new ' + + 'instance when called without `new`'); } common.expectsError( From 2d8ea1ac82bab04ba1d8a2ae2b14abfbf6456d53 Mon Sep 17 00:00:00 2001 From: Leko Date: Sun, 3 Dec 2017 01:56:04 +0900 Subject: [PATCH 9/9] test: Use assert instead of assert.ok --- test/parallel/test-crypto-sign-verify.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index c11e2009aac1ba..abdbcd3a1e5350 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -18,15 +18,15 @@ const modSize = 1024; { const Sign = crypto.Sign; const instance = Sign('SHA256'); - assert.ok(instance instanceof Sign, 'Sign is expected to return a new ' + - 'instance when called without `new`'); + 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.ok(instance instanceof Verify, 'Verify is expected to return a new ' + - 'instance when called without `new`'); + assert(instance instanceof Verify, 'Verify is expected to return a new ' + + 'instance when called without `new`'); } common.expectsError(