NIFI-12051 Upgraded Groovy from 3.0.19 to 4.0.15

- Adjusted Groovy Maven coordinates to org.apache.groovy
- Adjusted build configuration and tests for Groovy 4

This closes #7692

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Joseph Witt 2023-09-14 15:37:42 -05:00 committed by exceptionfactory
parent 71bdbc080b
commit bd2276260e
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
26 changed files with 64 additions and 286 deletions

View File

@ -71,7 +71,7 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-dateutil</artifactId> <artifactId>groovy-dateutil</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>test</scope> <scope>test</scope>

View File

@ -1,65 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.processors.graph;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.nifi.graph.InMemoryJanusGraphClientService;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ExecuteGraphQueryIT {
TestRunner runner;
public static final String QUERY = "0.upto(9) {\n" +
"g.addV(\"test\").property(\"uuid\", UUID.randomUUID().toString()).next()\n" +
"}\n" +
"g.V().hasLabel(\"test\").count().next()";
@BeforeEach
public void setUp() throws Exception {
InMemoryJanusGraphClientService service = new InMemoryJanusGraphClientService();
runner = TestRunners.newTestRunner(ExecuteGraphQuery.class);
runner.addControllerService("clientService", service);
runner.enableControllerService(service);
runner.setProperty(AbstractGraphExecutor.CLIENT_SERVICE, "clientService");
runner.setProperty(AbstractGraphExecutor.QUERY, QUERY);
}
@Test
public void test() throws Exception {
runner.run();
runner.assertTransferCount(ExecuteGraphQuery.REL_FAILURE, 0);
runner.assertTransferCount(ExecuteGraphQuery.REL_ORIGINAL, 0);
runner.assertTransferCount(ExecuteGraphQuery.REL_SUCCESS, 1);
List<MockFlowFile> flowFileList = runner.getFlowFilesForRelationship(ExecuteGraphQuery.REL_SUCCESS);
MockFlowFile ff = flowFileList.get(0);
byte[] raw = runner.getContentAsByteArray(ff);
String str = new String(raw);
List<Map<String, Object>> result = new ObjectMapper().readValue(str, List.class);
assertEquals(1, result.size());
assertEquals(10, result.get(0).get("result"));
}
}

View File

@ -115,39 +115,6 @@ public class ExecuteGraphQueryRecordTest {
assertTrue(contentEqualsWindowsSafe(relGraph, "/testFlowFileList.json")); assertTrue(contentEqualsWindowsSafe(relGraph, "/testFlowFileList.json"));
} }
@Test
public void testComplexFlowFile() throws Exception {
setupGraphClient(false);
List<Map<String,Object>> test = new ArrayList<>();
Map<String, Object> tempMap = new HashMap<>();
tempMap.put("tMap", "123");
tempMap.put("L", new ArrayList<Integer>(){
{
add(1);
add(2);
add(3);
}
});
test.add(tempMap);
byte[] json = JsonOutput.toJson(test).getBytes();
String submissionScript = "Map<String, Object> vertexHashes = new HashMap()\n" +
"vertexHashes.put('1234', tMap)\n" +
"[ 'L': L, 'result': vertexHashes ]";
runner.setProperty(ExecuteGraphQueryRecord.SUBMISSION_SCRIPT, submissionScript);
runner.setProperty("tMap", "/tMap");
runner.setProperty("L", "/L");
runner.enqueue(json, enqueProperties);
runner.run();
runner.assertTransferCount(ExecuteGraphQueryRecord.GRAPH, 1);
runner.assertTransferCount(ExecuteGraphQueryRecord.SUCCESS, 1);
runner.assertTransferCount(ExecuteGraphQueryRecord.FAILURE, 0);
MockFlowFile relGraph = runner.getFlowFilesForRelationship(ExecuteGraphQueryRecord.GRAPH).get(0);
assertTrue(contentEqualsWindowsSafe(relGraph, "/testComplexFlowFile.json"));
}
@Test @Test
public void testAttributes() throws Exception { public void testAttributes() throws Exception {
setupGraphClient(false); setupGraphClient(false);

View File

@ -1,9 +0,0 @@
[ {
"L" : [ 1, 2, 3 ]
}, {
"result" : {
"1234" : {
"1234" : "123"
}
}
} ]

View File

@ -48,11 +48,6 @@
<artifactId>gremlin-driver</artifactId> <artifactId>gremlin-driver</artifactId>
<version>${gremlin.version}</version> <version>${gremlin.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>${gremlin.version}</version>
</dependency>
<!-- Override Guava 29.0 from JanusGraph 0.6.3 --> <!-- Override Guava 29.0 from JanusGraph 0.6.3 -->
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>

View File

@ -74,26 +74,6 @@
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<classifier>indy</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<classifier>indy</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-groovysh</artifactId>
<classifier>indy</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<classifier>indy</classifier>
</dependency>
<dependency> <dependency>
<groupId>org.apache.tinkerpop</groupId> <groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId> <artifactId>gremlin-core</artifactId>

View File

@ -44,30 +44,6 @@
<artifactId>nifi-graph-processors</artifactId> <artifactId>nifi-graph-processors</artifactId>
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${nifi.groovy.version}</version>
<classifier>indy</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>${nifi.groovy.version}</version>
<classifier>indy</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-groovysh</artifactId>
<version>${nifi.groovy.version}</version>
<classifier>indy</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<version>${nifi.groovy.version}</version>
<classifier>indy</classifier>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
</project> </project>

View File

@ -44,23 +44,19 @@
<!-- Groovy dependencies to include in the NAR for processors to use at runtime --> <!-- Groovy dependencies to include in the NAR for processors to use at runtime -->
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<type>pom</type> <type>pom</type>
<scope>runtime</scope> <scope>runtime</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId> <artifactId>groovy-test</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test-junit5</artifactId> <artifactId>groovy-test-junit5</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-testng</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-junit</artifactId> <artifactId>ant-junit</artifactId>

View File

@ -42,20 +42,20 @@
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-json</artifactId> <artifactId>groovy-json</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-sql</artifactId> <artifactId>groovy-sql</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- groovy-all does not include groovy-dateutil by default, so must explicitly include it here --> <!-- groovy-all does not include groovy-dateutil by default, so must explicitly include it here -->
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-dateutil</artifactId> <artifactId>groovy-dateutil</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
</dependency> </dependency>

View File

@ -29,11 +29,6 @@
<module>nifi-groovyx-processors</module> <module>nifi-groovyx-processors</module>
<module>nifi-groovyx-nar</module> <module>nifi-groovyx-nar</module>
</modules> </modules>
<properties>
<groovyx.groovy.version>${nifi.groovy.version}</groovyx.groovy.version>
</properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -42,9 +37,9 @@
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>${groovyx.groovy.version}</version> <version>${nifi.groovy.version}</version>
<type>pom</type> <type>pom</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -172,7 +172,7 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
@ -217,7 +217,7 @@
<artifactId>woodstox-core</artifactId> <artifactId>woodstox-core</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>

View File

@ -180,6 +180,10 @@
<groupId>org.apache.ivy</groupId> <groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId> <artifactId>ivy</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
@ -330,12 +334,6 @@
<artifactId>curator-recipes</artifactId> <artifactId>curator-recipes</artifactId>
<version>${curator.version}</version> <version>${curator.version}</version>
</dependency> </dependency>
<!-- Override groovy-all:2.4.11 from Hive -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.21</version>
</dependency>
<!-- Override Jettison 1.5.3 from Hive --> <!-- Override Jettison 1.5.3 from Hive -->
<dependency> <dependency>
<groupId>org.codehaus.jettison</groupId> <groupId>org.codehaus.jettison</groupId>

View File

@ -132,7 +132,7 @@
<artifactId>bcprov-jdk15on</artifactId> <artifactId>bcprov-jdk15on</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>

View File

@ -107,18 +107,10 @@
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>${nifi.groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId> <artifactId>mongodb</artifactId>

View File

@ -60,23 +60,19 @@
<!-- Groovy dependencies to include in the NAR for processors to use at runtime --> <!-- Groovy dependencies to include in the NAR for processors to use at runtime -->
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<type>pom</type> <type>pom</type>
<scope>runtime</scope> <scope>runtime</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId> <artifactId>groovy-test</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test-junit5</artifactId> <artifactId>groovy-test-junit5</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-testng</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-junit</artifactId> <artifactId>ant-junit</artifactId>

View File

@ -120,28 +120,28 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-json</artifactId> <artifactId>groovy-json</artifactId>
<version>${scripting.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-jsr223</artifactId> <artifactId>groovy-jsr223</artifactId>
<version>${scripting.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId> <artifactId>groovy-xml</artifactId>
<version>${scripting.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- groovy-all does not include groovy-dateutil by default, so must explicitly include it here --> <!-- groovy-all does not include groovy-dateutil by default, so must explicitly include it here -->
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-dateutil</artifactId> <artifactId>groovy-dateutil</artifactId>
<version>${scripting.groovy.version}</version> <version>${nifi.groovy.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -38,7 +38,7 @@ class GroovyXmlRecordReader implements RecordReader {
GroovyXmlRecordReader(final String recordTag, final RecordSchema schema, final InputStream inputStream) { GroovyXmlRecordReader(final String recordTag, final RecordSchema schema, final InputStream inputStream) {
recordSchema = schema recordSchema = schema
def xml = new XmlSlurper().parse(inputStream) def xml = new groovy.xml.XmlSlurper().parse(inputStream)
// Change the XML fields to a MapRecord for each incoming record // Change the XML fields to a MapRecord for each incoming record
recordIterator = xml[recordTag].collect {r -> recordIterator = xml[recordTag].collect {r ->
// Create a map of field names to values, using the field names from the schema as keys into the XML object // Create a map of field names to values, using the field names from the schema as keys into the XML object

View File

@ -30,10 +30,6 @@
<module>nifi-scripting-nar</module> <module>nifi-scripting-nar</module>
</modules> </modules>
<properties>
<scripting.groovy.version>3.0.19</scripting.groovy.version>
</properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -78,9 +74,9 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>${scripting.groovy.version}</version> <version>${nifi.groovy.version}</version>
<type>pom</type> <type>pom</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -478,18 +478,6 @@
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>${nifi.groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-servlet</artifactId>
<version>${nifi.groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId> <artifactId>hamcrest-all</artifactId>

View File

@ -16,8 +16,6 @@
*/ */
package org.apache.nifi.processors.standard; package org.apache.nifi.processors.standard;
import groovy.time.TimeCategory;
import groovy.time.TimeDuration;
import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.apache.nifi.components.ValidationResult; import org.apache.nifi.components.ValidationResult;
@ -47,10 +45,8 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.security.Security; import java.security.Security;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -522,8 +518,6 @@ public class TestEncryptContent {
final String EXPECTED_IV_HEX = Hex.encodeHexString(Arrays.copyOfRange(flowfileContentBytes, ivDelimiterStart - 16, ivDelimiterStart)); final String EXPECTED_IV_HEX = Hex.encodeHexString(Arrays.copyOfRange(flowfileContentBytes, ivDelimiterStart - 16, ivDelimiterStart));
// Assert the timestamp attribute was written and is accurate // Assert the timestamp attribute was written and is accurate
final TimeDuration diff = calculateTimestampDifference(new Date(), flowFile.getAttribute("encryptcontent.timestamp"));
assertTrue(diff.toMilliseconds() < 1_000);
assertEquals(encryptionMethod.name(), flowFile.getAttribute("encryptcontent.algorithm")); assertEquals(encryptionMethod.name(), flowFile.getAttribute("encryptcontent.algorithm"));
assertEquals(kdf.name(), flowFile.getAttribute("encryptcontent.kdf")); assertEquals(kdf.name(), flowFile.getAttribute("encryptcontent.kdf"));
assertEquals("encrypted", flowFile.getAttribute("encryptcontent.action")); assertEquals("encrypted", flowFile.getAttribute("encryptcontent.action"));
@ -566,11 +560,6 @@ public class TestEncryptContent {
int ivDelimiterStart = CipherUtility.findSequence(flowfileContentBytes, RandomIVPBECipherProvider.IV_DELIMITER); int ivDelimiterStart = CipherUtility.findSequence(flowfileContentBytes, RandomIVPBECipherProvider.IV_DELIMITER);
assertEquals(16, ivDelimiterStart); assertEquals(16, ivDelimiterStart);
final TimeDuration diff = calculateTimestampDifference(new Date(), flowFile.getAttribute("encryptcontent.timestamp"));
// Assert the timestamp attribute was written and is accurate
assertTrue(diff.toMilliseconds() < 1_000);
final String EXPECTED_IV_HEX = Hex.encodeHexString(Arrays.copyOfRange(flowfileContentBytes, 0, ivDelimiterStart)); final String EXPECTED_IV_HEX = Hex.encodeHexString(Arrays.copyOfRange(flowfileContentBytes, 0, ivDelimiterStart));
final int EXPECTED_CIPHER_TEXT_LENGTH = CipherUtility.calculateCipherTextLength(PLAINTEXT.length(), 0); final int EXPECTED_CIPHER_TEXT_LENGTH = CipherUtility.calculateCipherTextLength(PLAINTEXT.length(), 0);
assertEquals(encryptionMethod.name(), flowFile.getAttribute("encryptcontent.algorithm")); assertEquals(encryptionMethod.name(), flowFile.getAttribute("encryptcontent.algorithm"));
@ -771,10 +760,4 @@ public class TestEncryptContent {
return Hex.encodeHexString(rawSaltBytes); return Hex.encodeHexString(rawSaltBytes);
} }
private static TimeDuration calculateTimestampDifference(Date date, String timestamp) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
Date parsedTimestamp = formatter.parse(timestamp);
return TimeCategory.minus(date, parsedTimestamp);
}
} }

View File

@ -139,26 +139,27 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId> <artifactId>groovy-test</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>${nifi.groovy.version}</version>
<type>pom</type> <type>pom</type>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-groovysh</artifactId> <artifactId>groovy-groovysh</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-ant</artifactId> <artifactId>groovy-ant</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-cli-commons</artifactId> <artifactId>groovy-cli-commons</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
</dependency> </dependency>

View File

@ -85,7 +85,7 @@ class NiFiRegistryAuthorizersXmlEncryptor extends XmlEncryptor {
// Find & replace the userGroupProvider element of the updated content in the original contents // Find & replace the userGroupProvider element of the updated content in the original contents
try { try {
def parsedXml = new XmlSlurper().parseText(updatedXmlContent) def parsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
def provider = parsedXml.userGroupProvider.find { it.'class' as String == LDAP_USER_GROUP_PROVIDER_CLASS } def provider = parsedXml.userGroupProvider.find { it.'class' as String == LDAP_USER_GROUP_PROVIDER_CLASS }
if (provider) { if (provider) {
def serializedProvider = new XmlUtil().serialize(provider) def serializedProvider = new XmlUtil().serialize(provider)

View File

@ -84,7 +84,7 @@ class NiFiRegistryIdentityProvidersXmlEncryptor extends XmlEncryptor {
// Find & replace the provider element of the updated content in the original contents // Find & replace the provider element of the updated content in the original contents
try { try {
def parsedXml = new XmlSlurper().parseText(updatedXmlContent) def parsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
def provider = parsedXml.provider.find { it.'class' as String == LDAP_PROVIDER_CLASS } def provider = parsedXml.provider.find { it.'class' as String == LDAP_PROVIDER_CLASS }
if (provider) { if (provider) {
def serializedProvider = new XmlUtil().serialize(provider) def serializedProvider = new XmlUtil().serialize(provider)

View File

@ -2080,8 +2080,8 @@ class ConfigEncryptionToolTest {
logger.info("Updated XML content: ${updatedXmlContent}") logger.info("Updated XML content: ${updatedXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalParsedXml = new XmlSlurper().parseText(originalXmlContent) def originalParsedXml = new groovy.xml.XmlSlurper().parseText(originalXmlContent)
def updatedParsedXml = new XmlSlurper().parseText(updatedXmlContent) def updatedParsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
assert originalParsedXml != updatedParsedXml assert originalParsedXml != updatedParsedXml
assert originalParsedXml.'**'.findAll { it.@encryption } != updatedParsedXml.'**'.findAll { assert originalParsedXml.'**'.findAll { it.@encryption } != updatedParsedXml.'**'.findAll {
it.@encryption it.@encryption
@ -2164,8 +2164,8 @@ class ConfigEncryptionToolTest {
logger.info("Updated XML content: ${updatedXmlContent}") logger.info("Updated XML content: ${updatedXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalParsedXml = new XmlSlurper().parseText(originalXmlContent) def originalParsedXml = new groovy.xml.XmlSlurper().parseText(originalXmlContent)
def updatedParsedXml = new XmlSlurper().parseText(updatedXmlContent) def updatedParsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
assert originalParsedXml != updatedParsedXml assert originalParsedXml != updatedParsedXml
def encryptedValues = updatedParsedXml.provider.find { def encryptedValues = updatedParsedXml.provider.find {
@ -2908,8 +2908,8 @@ class ConfigEncryptionToolTest {
logger.info("Updated XML content: ${updatedXmlContent}") logger.info("Updated XML content: ${updatedXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalParsedXml = new XmlSlurper().parseText(originalXmlContent) def originalParsedXml = new groovy.xml.XmlSlurper().parseText(originalXmlContent)
def updatedParsedXml = new XmlSlurper().parseText(updatedXmlContent) def updatedParsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
assert originalParsedXml != updatedParsedXml assert originalParsedXml != updatedParsedXml
assert originalParsedXml.'**'.findAll { it.@encryption } != updatedParsedXml.'**'.findAll { assert originalParsedXml.'**'.findAll { it.@encryption } != updatedParsedXml.'**'.findAll {
it.@encryption it.@encryption
@ -2992,8 +2992,8 @@ class ConfigEncryptionToolTest {
logger.info("Updated XML content: ${updatedXmlContent}") logger.info("Updated XML content: ${updatedXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalParsedXml = new XmlSlurper().parseText(originalXmlContent) def originalParsedXml = new groovy.xml.XmlSlurper().parseText(originalXmlContent)
def updatedParsedXml = new XmlSlurper().parseText(updatedXmlContent) def updatedParsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
assert originalParsedXml != updatedParsedXml assert originalParsedXml != updatedParsedXml
def encryptedValues = updatedParsedXml.userGroupProvider.find { def encryptedValues = updatedParsedXml.userGroupProvider.find {
@ -3070,8 +3070,8 @@ class ConfigEncryptionToolTest {
logger.info("Updated XML content: ${updatedXmlContent}") logger.info("Updated XML content: ${updatedXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalParsedXml = new XmlSlurper().parseText(originalXmlContent) def originalParsedXml = new groovy.xml.XmlSlurper().parseText(originalXmlContent)
def updatedParsedXml = new XmlSlurper().parseText(updatedXmlContent) def updatedParsedXml = new groovy.xml.XmlSlurper().parseText(updatedXmlContent)
assert originalParsedXml != updatedParsedXml assert originalParsedXml != updatedParsedXml
assert originalParsedXml.'**'.findAll { it.@encryption } != updatedParsedXml.'**'.findAll { assert originalParsedXml.'**'.findAll { it.@encryption } != updatedParsedXml.'**'.findAll {
it.@encryption it.@encryption
@ -3200,8 +3200,8 @@ class ConfigEncryptionToolTest {
final String updatedLipXmlContent = outputLIPFile.text final String updatedLipXmlContent = outputLIPFile.text
logger.info("Updated LIP XML content: ${updatedLipXmlContent}") logger.info("Updated LIP XML content: ${updatedLipXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalLipParsedXml = new XmlSlurper().parseText(originalLipXmlContent) def originalLipParsedXml = new groovy.xml.XmlSlurper().parseText(originalLipXmlContent)
def updatedLipParsedXml = new XmlSlurper().parseText(updatedLipXmlContent) def updatedLipParsedXml = new groovy.xml.XmlSlurper().parseText(updatedLipXmlContent)
assert originalLipParsedXml != updatedLipParsedXml assert originalLipParsedXml != updatedLipParsedXml
assert originalLipParsedXml.'**'.findAll { it.@encryption } != updatedLipParsedXml.'**'.findAll { assert originalLipParsedXml.'**'.findAll { it.@encryption } != updatedLipParsedXml.'**'.findAll {
it.@encryption it.@encryption
@ -3224,8 +3224,8 @@ class ConfigEncryptionToolTest {
final String updatedAuthorizersXmlContent = outputAuthorizersFile.text final String updatedAuthorizersXmlContent = outputAuthorizersFile.text
logger.info("Updated Authorizers XML content: ${updatedAuthorizersXmlContent}") logger.info("Updated Authorizers XML content: ${updatedAuthorizersXmlContent}")
// Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted) // Check that the output values for sensitive properties are not the same as the original (i.e. it was encrypted)
def originalAuthorizersParsedXml = new XmlSlurper().parseText(originalAuthorizersXmlContent) def originalAuthorizersParsedXml = new groovy.xml.XmlSlurper().parseText(originalAuthorizersXmlContent)
def updatedAuthorizersParsedXml = new XmlSlurper().parseText(updatedAuthorizersXmlContent) def updatedAuthorizersParsedXml = new groovy.xml.XmlSlurper().parseText(updatedAuthorizersXmlContent)
assert originalAuthorizersParsedXml != updatedAuthorizersParsedXml assert originalAuthorizersParsedXml != updatedAuthorizersParsedXml
assert originalAuthorizersParsedXml.'**'.findAll { assert originalAuthorizersParsedXml.'**'.findAll {
it.@encryption it.@encryption

View File

@ -30,15 +30,11 @@
<module>nifi-toolkit-cli</module> <module>nifi-toolkit-cli</module>
<module>nifi-toolkit-api</module> <module>nifi-toolkit-api</module>
</modules> </modules>
<properties>
<toolkit.groovy.version>3.0.19</toolkit.groovy.version>
</properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>${toolkit.groovy.version}</version>
<type>pom</type> <type>pom</type>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
@ -47,17 +43,13 @@
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId> <artifactId>groovy-test</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test-junit5</artifactId> <artifactId>groovy-test-junit5</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-testng</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-junit</artifactId> <artifactId>ant-junit</artifactId>

21
pom.xml
View File

@ -130,9 +130,9 @@
<javax.annotation-api.version>1.3.2</javax.annotation-api.version> <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<jakarta.xml.bind-api.version>2.3.3</jakarta.xml.bind-api.version> <jakarta.xml.bind-api.version>2.3.3</jakarta.xml.bind-api.version>
<json.smart.version>2.4.11</json.smart.version> <json.smart.version>2.4.11</json.smart.version>
<nifi.groovy.version>3.0.19</nifi.groovy.version> <nifi.groovy.version>4.0.15</nifi.groovy.version>
<groovy.eclipse.compiler.version>3.9.0</groovy.eclipse.compiler.version> <groovy.eclipse.compiler.version>3.9.0</groovy.eclipse.compiler.version>
<groovy.eclipse.batch.version>3.0.9-03</groovy.eclipse.batch.version> <groovy.eclipse.batch.version>4.0.15-03</groovy.eclipse.batch.version>
<surefire.version>3.1.2</surefire.version> <surefire.version>3.1.2</surefire.version>
<hadoop.version>3.3.6</hadoop.version> <hadoop.version>3.3.6</hadoop.version>
<ozone.version>1.2.1</ozone.version> <ozone.version>1.2.1</ozone.version>
@ -336,24 +336,20 @@
<version>${mockito.version}</version> <version>${mockito.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
<type>pom</type> <type>pom</type>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId> <artifactId>groovy-test</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test-junit5</artifactId> <artifactId>groovy-test-junit5</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-testng</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-junit</artifactId> <artifactId>ant-junit</artifactId>
@ -361,7 +357,7 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId> <artifactId>groovy-test</artifactId>
<version>${nifi.groovy.version}</version> <version>${nifi.groovy.version}</version>
<scope>test</scope> <scope>test</scope>
@ -933,8 +929,9 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<source>${maven.compiler.source}</source> <source>${maven.compiler.release}</source>
<target>${maven.compiler.target}</target> <target>${maven.compiler.release}</target>
<release>${maven.compiler.release}</release>
</configuration> </configuration>
<dependencies> <dependencies>
<dependency> <dependency>