You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/10/08 19:55:49 UTC

[GitHub] [nifi] exceptionfactory commented on a change in pull request #5332: NIFI-9080 Converted nifi-commons to use JUnit 5.

exceptionfactory commented on a change in pull request #5332:
URL: https://github.com/apache/nifi/pull/5332#discussion_r725261880



##########
File path: nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java
##########
@@ -1820,10 +1817,12 @@ public void testHash() {
         assertEquals("5753a498f025464d72e088a9d5d6e872592d5f91", RecordPath.compile("hash(/firstName, 'SHA-1')").evaluate(record).getSelectedFields().findFirst().get().getValue());
     }
 
-    @Test(expected = RecordPathException.class)
+    @Test
     public void testHashFailure() {
         final Record record = getCaseTestRecord();
-        assertEquals("61409aa1fd47d4a5332de23cbf59a36f", RecordPath.compile("hash(/firstName, 'NOT_A_ALGO')").evaluate(record).getSelectedFields().findFirst().get().getValue());
+        //assertEquals("61409aa1fd47d4a5332de23cbf59a36f", RecordPath.compile("hash(/firstName, 'NOT_A_ALGO')").evaluate(record).getSelectedFields().findFirst().get().getValue());

Review comment:
       Is there a reason why this was commented out?

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/BcryptCipherProviderGroovyTest.groovy
##########
@@ -610,7 +596,7 @@ class BcryptCipherProviderGroovyTest {
         assert decryptMsg =~ "The salt must be of the format"
     }
 
-    @Ignore("This test can be run on a specific machine to evaluate if the default work factor is sufficient")
+    @Disabled("This test can be run on a specific machine to evaluate if the default work factor is sufficient")

Review comment:
       This should be enabled using a conditional property.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/PBKDF2CipherProviderGroovyTest.groovy
##########
@@ -164,8 +155,8 @@ class PBKDF2CipherProviderGroovyTest {
     @Test
     void testGetCipherWithUnlimitedStrengthShouldBeInternallyConsistent() throws Exception {
         // Arrange
-        Assume.assumeTrue("Test is being skipped due to this JVM lacking JCE Unlimited Strength Jurisdiction Policy file.",
-                CipherUtility.isUnlimitedStrengthCryptoSupported())
+        assumeTrue(CipherUtility.isUnlimitedStrengthCryptoSupported(),
+                "Test is being skipped due to this JVM lacking JCE Unlimited Strength Jurisdiction Policy file.")

Review comment:
       This can be removed.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/ScryptSecureHasherTest.groovy
##########
@@ -239,7 +252,7 @@ class ScryptSecureHasherTest extends GroovyTestCase {
      * This test can have the minimum time threshold updated to determine if the performance
      * is still sufficient compared to the existing threat model.
      */
-    @Ignore("Long running test")
+    @Disabled("Long running test")

Review comment:
       Enabled on system property.

##########
File path: nifi-commons/nifi-record/pom.xml
##########
@@ -28,4 +28,12 @@
         on any external libraries.
     </description>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-junit-jupiter</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+

Review comment:
       Is this dependency necessary?

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/PBKDF2SecureHasherTest.groovy
##########
@@ -242,7 +249,7 @@ class PBKDF2SecureHasherTest extends GroovyTestCase {
      * This test can have the minimum time threshold updated to determine if the performance
      * is still sufficient compared to the existing threat model.
      */
-    @Ignore("Long running test")
+    @Disabled("Long running test")

Review comment:
       Enabled on system property.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/HashServiceTest.groovy
##########
@@ -428,9 +402,9 @@ class HashServiceTest extends GroovyTestCase {
         // Act
         def generatedHashes = algorithms.collectEntries { HashAlgorithm algorithm ->
             // Get a new InputStream for each iteration, or it will calculate the hash of an empty input on iterations 1 - n
-            InputStream input = inputFile.newInputStream()
+            InputStream input = new ByteArrayInputStream(sb.toString().bytes)
             String hash = HashService.hashValueStreaming(algorithm, input)
-            logger.info("${algorithm.getName().padLeft(11)}(${inputFile.path}) [${hash.length() / 2}] = ${hash}")
+//            logger.info("${algorithm.getName().padLeft(11)}(${inputFile.path}) [${hash.length() / 2}] = ${hash}")

Review comment:
       This log line should be removed

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/Argon2SecureHasherTest.groovy
##########
@@ -46,30 +43,35 @@ class Argon2SecureHasherTest extends GroovyTestCase {
         Hex.decode(hex?.replaceAll("[^0-9a-fA-F]", ""))
     }
 
-    @Ignore("Cannot override static salt")
+    @Disabled("Cannot override static salt")
     @Test
     void testShouldMatchReferenceVectors() {
-        // Arrange
-        int hashLength = 32
-        int memory = 32
-        int parallelism = 4
-        int iterations = 3
-        logger.info("Generating Argon2 hash for hash length: ${hashLength} B, mem: ${memory} KiB, parallelism: ${parallelism}, iterations: ${iterations}")
-
-        Argon2SecureHasher a2sh = new Argon2SecureHasher(hashLength, memory, parallelism, iterations)
-        // Override the static salt for the published test vector
-//        a2sh.staticSalt = [0x02] * 16
-
-        // Act
-        byte[] hash = a2sh.hashRaw([0x01] * 32 as byte[])
-        logger.info("Generated hash: ${Hex.encode(hash)}")
-
-        // Assert
-        assert hash == decodeHex("0d 64 0d f5 8d 78 76 6c 08 c0 37 a3 4a 8b 53 c9 d0 " +
-                "1e f0 45 2d 75 b6 5e b5 25 20 e9 6b 01 e6 59")
-
-        // Clean up
-//        Argon2SecureHasher.staticSalt = "NiFi Static Salt".bytes
+        /*
+         * TODO: Fix?
+         * Commented out because surefire is ignoring @Disabled
+         */
+
+//        // Arrange
+//        int hashLength = 32
+//        int memory = 32
+//        int parallelism = 4
+//        int iterations = 3
+//        logger.info("Generating Argon2 hash for hash length: ${hashLength} B, mem: ${memory} KiB, parallelism: ${parallelism}, iterations: ${iterations}")
+//
+//        Argon2SecureHasher a2sh = new Argon2SecureHasher(hashLength, memory, parallelism, iterations)
+//        // Override the static salt for the published test vector
+////        a2sh.staticSalt = [0x02] * 16
+//
+//        // Act
+//        byte[] hash = a2sh.hashRaw([0x01] * 32 as byte[])
+//        logger.info("Generated hash: ${Hex.encode(hash)}")
+//
+//        // Assert
+//        assert hash == decodeHex("0d 64 0d f5 8d 78 76 6c 08 c0 37 a3 4a 8b 53 c9 d0 " +
+//                "1e f0 45 2d 75 b6 5e b5 25 20 e9 6b 01 e6 59")
+//
+//        // Clean up
+////        Argon2SecureHasher.staticSalt = "NiFi Static Salt".bytes

Review comment:
       These commented lines should be corrected, or perhaps removed if that test method is unreliable.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/BcryptSecureHasherTest.groovy
##########
@@ -263,7 +250,7 @@ class BcryptSecureHasherTest extends GroovyTestCase {
      * This test can have the minimum time threshold updated to determine if the performance
      * is still sufficient compared to the existing threat model.
      */
-    @Ignore("Long running test")
+    @Disabled("Long running test")

Review comment:
       Enabled using a conditional property.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/PBKDF2CipherProviderGroovyTest.groovy
##########
@@ -468,7 +459,7 @@ class PBKDF2CipherProviderGroovyTest {
         }
     }
 
-    @Ignore("This test can be run on a specific machine to evaluate if the default iteration count is sufficient")
+    @Disabled("This test can be run on a specific machine to evaluate if the default iteration count is sufficient")

Review comment:
       Enabled on system property.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/NiFiLegacyCipherProviderGroovyTest.groovy
##########
@@ -124,8 +110,8 @@ class NiFiLegacyCipherProviderGroovyTest {
     @Test
     void testGetCipherWithUnlimitedStrengthShouldBeInternallyConsistent() throws Exception {
         // Arrange
-        Assume.assumeTrue("Test is being skipped due to this JVM lacking JCE Unlimited Strength Jurisdiction Policy file.",
-                CipherUtility.isUnlimitedStrengthCryptoSupported())
+        assumeTrue(CipherUtility.isUnlimitedStrengthCryptoSupported(),
+                "Test is being skipped due to this JVM lacking JCE Unlimited Strength Jurisdiction Policy file.")

Review comment:
       This can be removed.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/Argon2SecureHasherTest.groovy
##########
@@ -297,9 +299,14 @@ class Argon2SecureHasherTest extends GroovyTestCase {
      * This test can have the minimum time threshold updated to determine if the performance
      * is still sufficient compared to the existing threat model.
      */
-    @Ignore("Long running test")
+    @Disabled("Long running test")
     @Test
     void testDefaultCostParamsShouldBeSufficient() {
+        if (true) {
+            return //TODO: junit5-fix
+            //This appears to be necessitated by a collision between the vintage and jupiter engines in the surefire plugin
+        }

Review comment:
       This needs to be corrected, it looks like it should be flagged with EnabledOnSystemProperty given that it is a performance test.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/crypto/ScryptCipherProviderGroovyTest.groovy
##########
@@ -621,7 +612,7 @@ class ScryptCipherProviderGroovyTest {
         assert isScryptSalt
     }
 
-    @Ignore("This test can be run on a specific machine to evaluate if the default parameters are sufficient")
+    @Disabled("This test can be run on a specific machine to evaluate if the default parameters are sufficient")

Review comment:
       Enabled on system property.

##########
File path: nifi-commons/nifi-site-to-site-client/src/test/java/org/apache/nifi/remote/client/socket/TestSiteToSiteClient.java
##########
@@ -41,10 +40,14 @@
 import java.util.Map;
 import java.util.Set;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 public class TestSiteToSiteClient {
 
     @Test
-    @Ignore("For local testing only; not really a unit test but a manual test")
+    @Disabled("For local testing only; not really a unit test but a manual test")

Review comment:
       Recommend removing this method or converting to an Integration Test class.

##########
File path: nifi-commons/nifi-security-utils/src/test/groovy/org/apache/nifi/security/util/scrypt/ScryptGroovyTest.groovy
##########
@@ -180,7 +165,7 @@ class ScryptGroovyTest {
         assert calculatedHash == HASH
     }
 
-    @Ignore("This test was just to exercise the heap and debug OOME issues")
+    @Disabled("This test was just to exercise the heap and debug OOME issues")

Review comment:
       Enabled on system property.




-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org