adarmiento commented on a change in pull request #3664: NIFI-6536 
EncryptContent accepts configurable PGP symmetric cipher
URL: https://github.com/apache/nifi/pull/3664#discussion_r317791744
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEncryptContent.java
 ##########
 @@ -92,6 +102,92 @@ public void testRoundTrip() throws IOException {
         }
     }
 
+    @Test
+    public void testPgpCiphersRoundTrip() {
+        final TestRunner testRunner = TestRunners.newTestRunner(new 
EncryptContent());
+
+        List<String> pgpAlgorithms = new ArrayList<>();
+        pgpAlgorithms.add("PGP");
+        pgpAlgorithms.add("PGP_ASCII_ARMOR");
+
+        for (String algorithm : pgpAlgorithms) {
+
+            testRunner.setProperty(EncryptContent.ENCRYPTION_ALGORITHM, 
algorithm);
+            testRunner.setProperty(EncryptContent.PASSWORD, "short");
+            testRunner.setProperty(EncryptContent.KEY_DERIVATION_FUNCTION, 
KeyDerivationFunction.NONE.name());
+            // Must be allowed or short password will cause validation errors
+            testRunner.setProperty(EncryptContent.ALLOW_WEAK_CRYPTO, 
"allowed");
+
+            for (int i = 1; i < 14; i++) {
+                if (i != SymmetricKeyAlgorithmTags.SAFER) {
+                    Integer cipher = i;
+                    
testRunner.setProperty(EncryptContent.PGP_SYMMETRIC_ENCRYPTION_CIPHER, 
String.valueOf(cipher));
+                    testRunner.setProperty(EncryptContent.MODE, 
EncryptContent.ENCRYPT_MODE);
+
+                    testRunner.enqueue("A cool plaintext!");
+                    testRunner.clearTransferState();
+                    testRunner.run();
+
+                    
testRunner.assertAllFlowFilesTransferred(EncryptContent.REL_SUCCESS, 1);
+
+                    MockFlowFile flowFile = 
testRunner.getFlowFilesForRelationship(EncryptContent.REL_SUCCESS).get(0);
+                    testRunner.assertQueueEmpty();
+
+                    testRunner.setProperty(EncryptContent.MODE, 
EncryptContent.DECRYPT_MODE);
 
 Review comment:
   Good point, thanks for the tip

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to