mirror of https://github.com/apache/nifi.git
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 <exceptionfactory@apache.org>
This commit is contained in:
parent
2fbe10b4bc
commit
9566d3fa78
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue