From f60b06f4be3042cecf2a275df88a9d51f18be060 Mon Sep 17 00:00:00 2001 From: toby Date: Wed, 15 Mar 2017 11:46:44 -0400 Subject: [PATCH] Improve ASCII armor tests for PGP messages --- test/tests/operations/PGP.js | 79 +++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/test/tests/operations/PGP.js b/test/tests/operations/PGP.js index 234b22b9..57736d1b 100644 --- a/test/tests/operations/PGP.js +++ b/test/tests/operations/PGP.js @@ -70,21 +70,6 @@ var CYBERCHEF_GENERATED_KEY_PAIRS = [ "=8R+g", "-----END PGP PRIVATE KEY BLOCK-----", ].join("\n"), - messages: [ - [ - "-----BEGIN PGP MESSAGE-----", - "Version: OpenPGP.js v2.3.6", - "Comment: http://openpgpjs.org", - "", - "wYwDmsTgRYVqFPcBA/kBfc7BnEcbKGwac/JOSK6YWzpDERR8NjJT/3R7JDsG", - "ywJB/ouaHy3e5KGDulALV6pUzcPbCC0CCl5tlFVaFYAj6+BdwR/WCb7dhlRE", - "x+vw5VKLlY6adSgtvU9aLF0nL0YlU9Pxf9wrPdo3bvxJij7S4mbGS2iybhQO", - "41ZUtWhOotI9AR/e7f2WHSt8dpl7T9Uq8trAptFWVIZkj+78Gp/8u5o8/mqV", - "9gxmOGsViKhVZ1b554nwd243IrqlzW2szg==", - "=prpZ", - "-----END PGP MESSAGE-----", - ].join("\n"), - ], }, ]; @@ -465,27 +450,45 @@ TestRegister.addTests(CYBERCHEF_GENERATED_KEY_PAIRS.map(function(keyPair) { }; })); -CYBERCHEF_GENERATED_KEY_PAIRS.forEach(function(keyPair) { - TestRegister.addTests(keyPair.messages.map(function(encryptedMessage, messageIndex) { - var testName = "Remove PGP ASCII Armor, Add PGP ASCII Armor: Message $message '$name'"; - testName = testName.replace("$message", messageIndex); - testName = testName.replace("$name", keyPair.name); +PGP_TEST_KEY_PAIRS.forEach(function(keyPair) { + TestRegister.addTests( + ["", "hello world"].map(function(message, messageIndex) { + var testName = "PGP Encrypt, Remove PGP ASCII Armor, Add PGP ASCII Armor, PGP Decrypt: Message $message '$name'"; + testName = testName.replace("$message", messageIndex); + testName = testName.replace("$name", keyPair.name); - return { - name: testName, - input: encryptedMessage, - expectedOutput: encryptedMessage, - ignoreWhitespace: true, - recipeConfig: [ - { - op: "Remove PGP ASCII Armor", - args: [], - }, - { - op: "Add PGP ASCII Armor", - args: ["Message"], - }, - ], - }; - })); -}); + return { + name: testName, + input: message, + expectedOutput: message, + ignoreWhitespace: true, + recipeConfig: [ + { + op: "PGP Encrypt", + args: [keyPair.pub], + }, + { + op: "Remove PGP ASCII Armor", + args: [], + }, + { + op: "To Hex", + args: ["None"], + }, + { + op: "From Hex", + args: ["None"], + }, + { + op: "Add PGP ASCII Armor", + args: ["Message"], + }, + { + op: "PGP Decrypt", + args: [keyPair.sec, keyPair.password], + }, + ], + }; + }) + ) +}); \ No newline at end of file