From a10962187f3885e691e053839402ccf7a40e852c Mon Sep 17 00:00:00 2001 From: khriztianmoreno Date: Fri, 21 Jun 2019 17:15:06 -0500 Subject: [PATCH] test: eliminate duplicate statements PR-URL: https://github.com/nodejs/node/pull/28342 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- test/parallel/test-crypto-rsa-dsa.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js index 120a9f1f94f..ab5ed544d4e 100644 --- a/test/parallel/test-crypto-rsa-dsa.js +++ b/test/parallel/test-crypto-rsa-dsa.js @@ -38,6 +38,7 @@ const decryptError = { { const input = 'I AM THE WALRUS'; const bufferToEncrypt = Buffer.from(input); + const bufferPassword = Buffer.from('password'); let encryptedBuffer = crypto.publicEncrypt(rsaPubPem, bufferToEncrypt); @@ -66,12 +67,12 @@ const decryptError = { encryptedBuffer = crypto.privateEncrypt({ key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, bufferToEncrypt); decryptedBufferWithPassword = crypto.publicDecrypt({ key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, encryptedBuffer); assert.strictEqual(decryptedBufferWithPassword.toString(), input); @@ -79,20 +80,20 @@ const decryptError = { encryptedBuffer = crypto.privateEncrypt({ padding: crypto.constants.RSA_PKCS1_PADDING, key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, bufferToEncrypt); decryptedBufferWithPassword = crypto.publicDecrypt({ padding: crypto.constants.RSA_PKCS1_PADDING, key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, encryptedBuffer); assert.strictEqual(decryptedBufferWithPassword.toString(), input); // Omitting padding should be okay because RSA_PKCS1_PADDING is the default. decryptedBufferWithPassword = crypto.publicDecrypt({ key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, encryptedBuffer); assert.strictEqual(decryptedBufferWithPassword.toString(), input); @@ -101,13 +102,13 @@ const decryptError = { encryptedBuffer = crypto.privateEncrypt({ padding: crypto.constants.RSA_NO_PADDING, key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, Buffer.from(plaintext)); decryptedBufferWithPassword = crypto.publicDecrypt({ padding: crypto.constants.RSA_NO_PADDING, key: rsaKeyPemEncrypted, - passphrase: Buffer.from('password') + passphrase: bufferPassword }, encryptedBuffer); assert.strictEqual(decryptedBufferWithPassword.toString(), plaintext);