From c10a9f1b9764572fd03a89d825ae64c2e0b7ef16 Mon Sep 17 00:00:00 2001 From: pezhmanparsaee Date: Wed, 24 Mar 2021 17:40:42 +0430 Subject: [PATCH 1/3] test: crypto KeyObject.from() ERR_INVALID_ARG_TYPE --- test/parallel/test-crypto-key-objects.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index fdb63afa7659f3..48f15033bab61a 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -64,6 +64,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 of type CryptoKey. Received type ' + + "string ('invalid_key')" + }); +} + { const keybuf = randomBytes(32); const key = createSecretKey(keybuf); From 2837ff631e6fd2f619eac036edcbd8d0118b89f6 Mon Sep 17 00:00:00 2001 From: pezhmanparsaee Date: Wed, 24 Mar 2021 20:10:53 +0430 Subject: [PATCH 2/3] test: crypto KeyObject.from() ERR_INVALID_ARG_TYPE --- test/parallel/test-crypto-key-objects.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index 48f15033bab61a..983ce7b8d32e1e 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -69,8 +69,8 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', name: 'TypeError', code: 'ERR_INVALID_ARG_TYPE', message: - 'The "key" argument must be of type CryptoKey. Received type ' + - "string ('invalid_key')" + 'The "key" argument must be an instance of CryptoKey. Received type ' + + "string ('no_valid_key')" }); } From d8a6f1f541ecf343458c500dfa4de060c836c831 Mon Sep 17 00:00:00 2001 From: pezhmanparsaee Date: Wed, 24 Mar 2021 20:19:03 +0430 Subject: [PATCH 3/3] fix message of thrown error --- test/parallel/test-crypto-key-objects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index 983ce7b8d32e1e..0441da159d9447 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -70,7 +70,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', code: 'ERR_INVALID_ARG_TYPE', message: 'The "key" argument must be an instance of CryptoKey. Received type ' + - "string ('no_valid_key')" + "string ('invalid_key')" }); }