test: crypto KeyObject.from() ERR_INVALID_ARG_TYPE

PR-URL: https://github.com/nodejs/node/pull/37890
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
pezhmanparsaee authored and Michaël Zasso committed 2021-05-03 13:34:46 +02:00
1 parent 9ad611c0b2
commit 67e9e71f75
1 file changed
+10
+10
View File
@@ -66,6 +66,16 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
});
}
{
assert.throws(() => KeyObject.from('invalid_key'), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE',
message:
'The "key" argument must be an instance of CryptoKey. Received type ' +
"string ('invalid_key')"
});
}
{
const keybuf = randomBytes(32);
const key = createSecretKey(keybuf);