This is an automated email from the ASF dual-hosted git repository.
otto 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 f86c1477ff NIFI-14866 Reduced use of external test files in Standard
Processors (#10210)
f86c1477ff is described below
commit f86c1477ffdb51d6873fb9535b3772ac31736662
Author: David Handermann <[email protected]>
AuthorDate: Sun Aug 17 07:30:14 2025 -0500
NIFI-14866 Reduced use of external test files in Standard Processors
(#10210)
- Removed unused certificate file
- Replaced JPEG with a short binary array
- Replaced XML files with inline string for SplitXml
Signed-off by: Otto Fowler <[email protected]>
---
.../nifi-standard-processors/pom.xml | 3 -
.../nifi/processors/standard/SplitXmlTest.java | 24 +--
.../nifi/processors/standard/TestRouteText.java | 8 +-
.../src/test/resources/localhost.cer | Bin 829 -> 0 bytes
.../src/test/resources/simple.jpg | Bin 25248 -> 0 bytes
.../src/test/resources/xxe_from_report.xml | 2 -
.../src/test/resources/xxe_template.xml | 230 ---------------------
7 files changed, 12 insertions(+), 255 deletions(-)
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
index 3f4b62f109..b4a90590c1 100644
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
+++
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
@@ -598,7 +598,6 @@
<exclude>src/test/resources/ExecuteCommand/TestLogStdErr.jar</exclude>
<exclude>src/test/resources/ExecuteCommand/TestSuccess.jar</exclude>
<exclude>src/test/resources/hello.txt</exclude>
- <exclude>src/test/resources/localhost.cer</exclude>
<exclude>src/test/resources/randombytes-1</exclude>
<exclude>src/test/resources/ScanAttribute/dictionary-with-empty-new-lines</exclude>
<exclude>src/test/resources/ScanAttribute/dictionary-with-extra-info</exclude>
@@ -832,8 +831,6 @@
<exclude>src/test/resources/TestXml/namespaceSplit1.xml</exclude>
<exclude>src/test/resources/TestXml/namespaceSplit2.xml</exclude>
<exclude>src/test/resources/TestXml/xml-bundle-1</exclude>
-
<exclude>src/test/resources/xxe_from_report.xml</exclude>
- <exclude>src/test/resources/xxe_template.xml</exclude>
<exclude>src/test/resources/PutDatabaseRecordIT/create-person-table.sql</exclude>
</excludes>
</configuration>
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/SplitXmlTest.java
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/SplitXmlTest.java
index 95ccf7524d..9ebd570c21 100644
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/SplitXmlTest.java
+++
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/SplitXmlTest.java
@@ -21,10 +21,12 @@ import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import java.io.IOException;
-import java.nio.file.Paths;
+class SplitXmlTest {
+
+ private static final String DOCTYPE_DOCUMENT = """
+ <!DOCTYPE ANY SYSTEM "http://localhost">
+ """;
-public class SplitXmlTest {
private TestRunner runner;
@BeforeEach
@@ -33,20 +35,8 @@ public class SplitXmlTest {
}
@Test
- void testShouldHandleXXEInTemplate() throws IOException {
- final String xxeTemplateFilepath =
"src/test/resources/xxe_template.xml";
- assertExternalEntitiesFailure(xxeTemplateFilepath);
- }
-
- @Test
- void testShouldHandleRemoteCallXXE() throws IOException {
- final String xxeTemplateFilepath =
"src/test/resources/xxe_from_report.xml";
- assertExternalEntitiesFailure(xxeTemplateFilepath);
- }
-
- private void assertExternalEntitiesFailure(final String filePath) throws
IOException {
- runner.setProperty(SplitXml.SPLIT_DEPTH, "3");
- runner.enqueue(Paths.get(filePath));
+ void testDocumentTypeDisallowed() {
+ runner.enqueue(DOCTYPE_DOCUMENT);
runner.run();
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java
index a836e17c78..0512c0c5d0 100644
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java
+++
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java
@@ -91,13 +91,15 @@ public class TestRouteText {
assertTrue(expectedRelationships.contains(relationship.getName()));
}
- runner.enqueue(Paths.get("src/test/resources/simple.jpg"));
+ final byte[] binary = new byte[]{-1, -40, -1, -32};
+
+ runner.enqueue(binary);
runner.run();
runner.assertTransferCount("unmatched", 1);
runner.assertTransferCount("original", 1);
- final MockFlowFile outOriginal =
runner.getFlowFilesForRelationship("original").get(0);
-
outOriginal.assertContentEquals(Paths.get("src/test/resources/simple.jpg"));
+ final MockFlowFile outOriginal =
runner.getFlowFilesForRelationship("original").getFirst();
+ outOriginal.assertContentEquals(binary);
}
@Test
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/localhost.cer
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/localhost.cer
deleted file mode 100755
index 56c16fc304..0000000000
Binary files
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/localhost.cer
and /dev/null differ
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/simple.jpg
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/simple.jpg
deleted file mode 100644
index 18da83786f..0000000000
Binary files
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/simple.jpg
and /dev/null differ
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/xxe_from_report.xml
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/xxe_from_report.xml
deleted file mode 100644
index 42b22a0f3f..0000000000
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/xxe_from_report.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<!DOCTYPE ANY SYSTEM "http://some.external.nifi.apache.org:8888/xxe">
-<a>1</b>
\ No newline at end of file
diff --git
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/xxe_template.xml
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/xxe_template.xml
deleted file mode 100644
index 82674e0e1a..0000000000
---
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/resources/xxe_template.xml
+++ /dev/null
@@ -1,230 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE netspi
[<!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
-<template>
- <name>&xxe;</name>
- <description>A simple template which generates flowfiles and logs them.
</description>
- <groupId>3a204982-015e-1000-eaa2-19d352ec8394</groupId>
- <snippet>
- <connections>
- <id>0fbe8be5-306c-3b6c-0000-000000000000</id>
- <parentGroupId>21ae0bd6-5db6-3a47-0000-000000000000</parentGroupId>
- <backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
- <backPressureObjectThreshold>10000</backPressureObjectThreshold>
- <destination>
- <groupId>21ae0bd6-5db6-3a47-0000-000000000000</groupId>
- <id>fd90023d-a235-30f6-0000-000000000000</id>
- <type>PROCESSOR</type>
- </destination>
- <flowFileExpiration>0 sec</flowFileExpiration>
- <labelIndex>1</labelIndex>
- <name></name>
- <selectedRelationships>success</selectedRelationships>
- <source>
- <groupId>21ae0bd6-5db6-3a47-0000-000000000000</groupId>
- <id>ff49910d-06bb-37ee-0000-000000000000</id>
- <type>PROCESSOR</type>
- </source>
- <zIndex>0</zIndex>
- </connections>
- <processors>
- <id>fd90023d-a235-30f6-0000-000000000000</id>
- <parentGroupId>21ae0bd6-5db6-3a47-0000-000000000000</parentGroupId>
- <position>
- <x>0.0</x>
- <y>318.3128613789876</y>
- </position>
- <bundle>
- <artifact>nifi-standard-nar</artifact>
- <group>org.apache.nifi</group>
- <version>1.4.0-SNAPSHOT</version>
- </bundle>
- <config>
- <bulletinLevel>WARN</bulletinLevel>
- <comments></comments>
- <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
- <descriptors>
- <entry>
- <key>Log Level</key>
- <value>
- <name>Log Level</name>
- </value>
- </entry>
- <entry>
- <key>Log Payload</key>
- <value>
- <name>Log Payload</name>
- </value>
- </entry>
- <entry>
- <key>Attributes to Log</key>
- <value>
- <name>Attributes to Log</name>
- </value>
- </entry>
- <entry>
- <key>attributes-to-log-regex</key>
- <value>
- <name>attributes-to-log-regex</name>
- </value>
- </entry>
- <entry>
- <key>Attributes to Ignore</key>
- <value>
- <name>Attributes to Ignore</name>
- </value>
- </entry>
- <entry>
- <key>attributes-to-ignore-regex</key>
- <value>
- <name>attributes-to-ignore-regex</name>
- </value>
- </entry>
- <entry>
- <key>Log prefix</key>
- <value>
- <name>Log prefix</name>
- </value>
- </entry>
- <entry>
- <key>character-set</key>
- <value>
- <name>character-set</name>
- </value>
- </entry>
- </descriptors>
- <executionNode>ALL</executionNode>
- <lossTolerant>false</lossTolerant>
- <penaltyDuration>30 sec</penaltyDuration>
- <properties>
- <entry>
- <key>Log Level</key>
- <value>info</value>
- </entry>
- <entry>
- <key>Log Payload</key>
- <value>true</value>
- </entry>
- <entry>
- <key>Attributes to Log</key>
- </entry>
- <entry>
- <key>attributes-to-log-regex</key>
- <value>.*</value>
- </entry>
- <entry>
- <key>Attributes to Ignore</key>
- </entry>
- <entry>
- <key>attributes-to-ignore-regex</key>
- </entry>
- <entry>
- <key>Log prefix</key>
- </entry>
- <entry>
- <key>character-set</key>
- <value>UTF-8</value>
- </entry>
- </properties>
- <runDurationMillis>0</runDurationMillis>
- <schedulingPeriod>0 sec</schedulingPeriod>
- <schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
- <yieldDuration>1 sec</yieldDuration>
- </config>
- <name>LogAttribute</name>
- <relationships>
- <autoTerminate>true</autoTerminate>
- <name>success</name>
- </relationships>
- <state>STOPPED</state>
- <style></style>
- <type>org.apache.nifi.processors.standard.LogAttribute</type>
- </processors>
- <processors>
- <id>ff49910d-06bb-37ee-0000-000000000000</id>
- <parentGroupId>21ae0bd6-5db6-3a47-0000-000000000000</parentGroupId>
- <position>
- <x>1.1368683772161603E-13</x>
- <y>0.0</y>
- </position>
- <bundle>
- <artifact>nifi-standard-nar</artifact>
- <group>org.apache.nifi</group>
- <version>1.4.0-SNAPSHOT</version>
- </bundle>
- <config>
- <bulletinLevel>WARN</bulletinLevel>
- <comments></comments>
- <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
- <descriptors>
- <entry>
- <key>File Size</key>
- <value>
- <name>File Size</name>
- </value>
- </entry>
- <entry>
- <key>Batch Size</key>
- <value>
- <name>Batch Size</name>
- </value>
- </entry>
- <entry>
- <key>Data Format</key>
- <value>
- <name>Data Format</name>
- </value>
- </entry>
- <entry>
- <key>Unique FlowFiles</key>
- <value>
- <name>Unique FlowFiles</name>
- </value>
- </entry>
- <entry>
- <key>generate-ff-custom-text</key>
- <value>
- <name>generate-ff-custom-text</name>
- </value>
- </entry>
- </descriptors>
- <executionNode>ALL</executionNode>
- <lossTolerant>false</lossTolerant>
- <penaltyDuration>30 sec</penaltyDuration>
- <properties>
- <entry>
- <key>File Size</key>
- <value>0B</value>
- </entry>
- <entry>
- <key>Batch Size</key>
- <value>1</value>
- </entry>
- <entry>
- <key>Data Format</key>
- <value>Text</value>
- </entry>
- <entry>
- <key>Unique FlowFiles</key>
- <value>false</value>
- </entry>
- <entry>
- <key>generate-ff-custom-text</key>
- <value>This is a plaintext message. </value>
- </entry>
- </properties>
- <runDurationMillis>0</runDurationMillis>
- <schedulingPeriod>1 sec</schedulingPeriod>
- <schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
- <yieldDuration>1 sec</yieldDuration>
- </config>
- <name>GenerateFlowFile</name>
- <relationships>
- <autoTerminate>false</autoTerminate>
- <name>success</name>
- </relationships>
- <state>STOPPED</state>
- <style></style>
- <type>org.apache.nifi.processors.standard.GenerateFlowFile</type>
- </processors>
- </snippet>
- <timestamp>09/05/2017 14:51:01 PDT</timestamp>
-</template>