You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2019/10/01 19:54:17 UTC
[nifi] branch master updated: NIFI-6727 Fixed the
MockProcessContext decrypt bug and added unit test.
This is an automated email from the ASF dual-hosted git repository.
alopresto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/master by this push:
new 39a258d NIFI-6727 Fixed the MockProcessContext decrypt bug and added unit test.
39a258d is described below
commit 39a258dc38f9b037bb0ee75c8f9a3da2b12b0946
Author: Alessandro D'Armiento <al...@gmail.com>
AuthorDate: Sat Sep 28 10:11:23 2019 +0200
NIFI-6727 Fixed the MockProcessContext decrypt bug and added unit test.
This closes #3773.
Signed-off-by: Andy LoPresto <al...@apache.org>
---
.../main/java/org/apache/nifi/util/MockProcessContext.java | 2 +-
.../java/org/apache/nifi/util/TestMockProcessContext.java | 11 +++++++++++
.../nifi-resources/src/main/resources/conf/logback.xml | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java
index 3e9b7e0..e850bc8 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java
@@ -399,7 +399,7 @@ public class MockProcessContext extends MockControllerServiceLookup implements P
@Override
public String decrypt(final String encrypted) {
if (encrypted.startsWith("enc{") && encrypted.endsWith("}")) {
- return encrypted.substring(4, encrypted.length() - 2);
+ return encrypted.substring(4, encrypted.length() - 1);
}
return encrypted;
}
diff --git a/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java b/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java
index d48af63..f1137ed 100644
--- a/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java
+++ b/nifi-mock/src/test/java/org/apache/nifi/util/TestMockProcessContext.java
@@ -75,6 +75,17 @@ public class TestMockProcessContext {
assertEquals(2, proc.getUpdateCount(DummyProcessor.DEFAULTED_PROP));
}
+ @Test
+ public void testFakeEncryptionAndDecryption() {
+ final DummyProcessor proc = new DummyProcessor();
+ final MockProcessContext context = new MockProcessContext(proc);
+ String subject = "foo";
+ String encrypted = context.encrypt(subject);
+ assertEquals(encrypted, "enc{foo}");
+ String decrypted = context.decrypt(encrypted);
+ assertEquals(decrypted, subject);
+ }
+
private static class DummyProcessor extends AbstractProcessor {
static final PropertyDescriptor REQUIRED_PROP = new PropertyDescriptor.Builder()
.name("required")
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/logback.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/logback.xml
index 03d401a..cc53093 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/logback.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/logback.xml
@@ -172,7 +172,7 @@
<root level="INFO">
- <appender-ref ref="APP_FILE"/>
+ <appender-ref ref="APP_FILE"/>MockProcessContext
</root>
</configuration>