Skip to content

Commit d729e52

Browse files
akito0107MylesBorins
authored andcommitted
test: improve crypto coverage
* call Certificate function directly * check exception when sign option is undefined PR-URL: #11280 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 77f23ec commit d729e52

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/parallel/test-crypto-certificate.js

+3
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ assert.strictEqual(certificate.exportChallenge(spkacFail), '');
3737
function stripLineEndings(obj) {
3838
return obj.replace(/\n/g, '');
3939
}
40+
41+
// direct call Certificate() should return instance
42+
assert(crypto.Certificate() instanceof crypto.Certificate);

test/parallel/test-crypto-sign-verify.js

+7
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,10 @@ var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
7070
verified = verStream.verify(certPem, s3);
7171
assert.strictEqual(verified, true, 'sign and verify (stream)');
7272
}
73+
74+
// Test throws exception when key options is null
75+
{
76+
assert.throws(() => {
77+
crypto.createSign('RSA-SHA1').update('Test123').sign(null, 'base64');
78+
}, /^Error: No key provided to sign$/);
79+
}

0 commit comments

Comments
 (0)