You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2022/03/28 18:28:48 UTC
[nifi] branch main updated: NIFI-9841 Improved Encryptor test reliability
This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 9566d3f NIFI-9841 Improved Encryptor test reliability
9566d3f is described below
commit 9566d3fa786c074491096009da075f26d7188bde
Author: Emilio Setiadarma <em...@gmail.com>
AuthorDate: Mon Mar 28 09:09:03 2022 -0700
NIFI-9841 Improved Encryptor test reliability
- Changed expected exception to ProcessException in KeyedEncryptorGroovyTest and PasswordBasedEncryptorGroovyTest to avoid intermittent failures
This closes #5911
Signed-off-by: David Handermann <ex...@apache.org>
---
.../util/crypto/KeyedEncryptorGroovyTest.groovy | 11 +++--------
.../crypto/PasswordBasedEncryptorGroovyTest.groovy | 23 +++++-----------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/KeyedEncryptorGroovyTest.groovy b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/KeyedEncryptorGroovyTest.groovy
index 1b6110b..ab2d0f7 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/KeyedEncryptorGroovyTest.groovy
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/KeyedEncryptorGroovyTest.groovy
@@ -17,6 +17,7 @@
package org.apache.nifi.security.util.crypto
import org.apache.commons.codec.binary.Hex
+import org.apache.nifi.processor.exception.ProcessException
import org.apache.nifi.processor.io.StreamCallback
import org.apache.nifi.security.util.EncryptionMethod
import org.apache.nifi.security.util.KeyDerivationFunction
@@ -211,12 +212,9 @@ class KeyedEncryptorGroovyTest {
final byte[] removedIVCipherBytes = cipherString.split(IV_DELIMITER)[1].getBytes(StandardCharsets.UTF_8)
InputStream cipherInputStream = new ByteArrayInputStream(removedIVCipherBytes)
- Exception exception = Assert.assertThrows(Exception.class, () -> {
+ Exception exception = Assert.assertThrows(ProcessException.class, () -> {
decryptionCallback.process(cipherInputStream, recoveredStream)
})
-
- // Assert
- assert exception.getCause() instanceof BytePatternNotFoundException
}
@Test
@@ -249,11 +247,8 @@ class KeyedEncryptorGroovyTest {
InputStream cipherInputStream = new ByteArrayInputStream(removedIVDelimiterCipherBytes)
- Exception exception = Assert.assertThrows(Exception.class, () -> {
+ Exception exception = Assert.assertThrows(ProcessException.class, () -> {
decryptionCallback.process(cipherInputStream, recoveredStream)
})
-
- // Assert
- assert exception.getCause() instanceof BytePatternNotFoundException
}
}
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/PasswordBasedEncryptorGroovyTest.groovy b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/PasswordBasedEncryptorGroovyTest.groovy
index 96c7435..d79474e 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/PasswordBasedEncryptorGroovyTest.groovy
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/security/util/crypto/PasswordBasedEncryptorGroovyTest.groovy
@@ -17,6 +17,7 @@
package org.apache.nifi.security.util.crypto
import org.apache.commons.codec.binary.Hex
+import org.apache.nifi.processor.exception.ProcessException
import org.apache.nifi.processor.io.StreamCallback
import org.apache.nifi.processors.standard.TestEncryptContentGroovy
import org.apache.nifi.security.util.EncryptionMethod
@@ -552,15 +553,10 @@ class PasswordBasedEncryptorGroovyTest {
InputStream cipherInputStream = new ByteArrayInputStream(cipherBytes)
cipherInputStream.skip(skipLength)
- Exception exception = Assert.assertThrows(Exception.class, () -> {
+ Exception exception = Assert.assertThrows(ProcessException.class, () -> {
decryptionCallback.process(cipherInputStream, recoveredStream)
})
- // Assert
- if (!(cipherProvider instanceof OpenSSLPKCS5CipherProvider)) {
- assert exception.getCause() instanceof IllegalArgumentException
- }
-
// This is necessary to run multiple iterations
plainStream.reset()
}
@@ -599,13 +595,10 @@ class PasswordBasedEncryptorGroovyTest {
InputStream cipherInputStream = new ByteArrayInputStream(removedDelimiterCipherString.getBytes(StandardCharsets.UTF_8))
- Exception exception = Assert.assertThrows(Exception.class, () -> {
+ Exception exception = Assert.assertThrows(ProcessException.class, () -> {
decryptionCallback.process(cipherInputStream, recoveredStream)
})
- // Assert
- assert exception.getCause() instanceof BytePatternNotFoundException
-
// This is necessary to run multiple iterations
plainStream.reset()
}
@@ -653,13 +646,10 @@ class PasswordBasedEncryptorGroovyTest {
InputStream cipherInputStream = new ByteArrayInputStream(removedIVCipherString.getBytes(StandardCharsets.UTF_8))
- Exception exception = Assert.assertThrows(Exception.class, () -> {
+ Exception exception = Assert.assertThrows(ProcessException.class, () -> {
decryptionCallback.process(cipherInputStream, recoveredStream)
})
- // Assert
- assert exception.getCause() instanceof IllegalArgumentException
-
// This is necessary to run multiple iterations
plainStream.reset()
}
@@ -698,13 +688,10 @@ class PasswordBasedEncryptorGroovyTest {
InputStream cipherInputStream = new ByteArrayInputStream(removedDelimiterCipherString.getBytes(StandardCharsets.UTF_8))
- Exception exception = Assert.assertThrows(Exception.class, () -> {
+ Exception exception = Assert.assertThrows(ProcessException.class, () -> {
decryptionCallback.process(cipherInputStream, recoveredStream)
})
- // Assert
- assert exception.getCause() instanceof BytePatternNotFoundException
-
// This is necessary to run multiple iterations
plainStream.reset()
}