mirror of https://github.com/apache/nifi.git
NIFI-6727 Fixed the MockProcessContext decrypt bug and added unit test.
This closes #3773. Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
parent
8abf330328
commit
39a258dc38
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="APP_FILE"/>
|
||||
<appender-ref ref="APP_FILE"/>MockProcessContext
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
|
|
Loading…
Reference in New Issue