This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-secure-xml.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f1eb61  Sort members
8f1eb61 is described below

commit 8f1eb611707887c8f3c72e1b5559ee1fe0fcc3cb
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Sep 13 16:09:48 2026 -0700

    Sort members
---
 .../xml/secure/SecureTransformerFactoryTest.java   | 22 ++++----
 .../commons/xml/secure/SecureTransformerTest.java  | 18 +++----
 .../commons/xml/secure/TransformerHandlerTest.java | 60 +++++++++++-----------
 3 files changed, 50 insertions(+), 50 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/xml/secure/SecureTransformerFactoryTest.java 
b/src/test/java/org/apache/commons/xml/secure/SecureTransformerFactoryTest.java
index 6ca4491..7fad06d 100644
--- 
a/src/test/java/org/apache/commons/xml/secure/SecureTransformerFactoryTest.java
+++ 
b/src/test/java/org/apache/commons/xml/secure/SecureTransformerFactoryTest.java
@@ -198,17 +198,6 @@ void rejectsDelegatesThatCannotEnableSecureProcessing() {
         assertThrows(SecureException.class, () -> 
SecureTransformerFactory.secure(new RejectingFeatureFactory()));
     }
 
-    @Test
-    void rejectsNullInputOnEveryFactoryMethod() {
-        final SAXTransformerFactory factory = (SAXTransformerFactory) 
SecureTransformerFactory.newInstance();
-        assertThrows(NullPointerException.class, () -> 
factory.newTemplates(null));
-        assertThrows(NullPointerException.class, () -> 
factory.newTransformer(null));
-        assertThrows(NullPointerException.class, () -> 
factory.newTransformerHandler((Source) null));
-        assertThrows(NullPointerException.class, () -> 
factory.newTransformerHandler((Templates) null));
-        assertThrows(NullPointerException.class, () -> 
factory.newXMLFilter((Source) null));
-        assertThrows(NullPointerException.class, () -> 
factory.newXMLFilter((Templates) null));
-    }
-
     @Test
     void rejectsForeignTemplatesFromNewTransformerHandler() throws Exception {
         final SAXTransformerFactory factory = (SAXTransformerFactory) 
SecureTransformerFactory.newInstance();
@@ -235,6 +224,17 @@ public Transformer newTransformer() throws 
TransformerConfigurationException {
         }
     }
 
+    @Test
+    void rejectsNullInputOnEveryFactoryMethod() {
+        final SAXTransformerFactory factory = (SAXTransformerFactory) 
SecureTransformerFactory.newInstance();
+        assertThrows(NullPointerException.class, () -> 
factory.newTemplates(null));
+        assertThrows(NullPointerException.class, () -> 
factory.newTransformer(null));
+        assertThrows(NullPointerException.class, () -> 
factory.newTransformerHandler((Source) null));
+        assertThrows(NullPointerException.class, () -> 
factory.newTransformerHandler((Templates) null));
+        assertThrows(NullPointerException.class, () -> 
factory.newXMLFilter((Source) null));
+        assertThrows(NullPointerException.class, () -> 
factory.newXMLFilter((Templates) null));
+    }
+
     @Test
     void rejectsTemplatesThatProduceNoTransformer() {
         final Templates templates = new Templates() {
diff --git 
a/src/test/java/org/apache/commons/xml/secure/SecureTransformerTest.java 
b/src/test/java/org/apache/commons/xml/secure/SecureTransformerTest.java
index e50996b..6a746b2 100644
--- a/src/test/java/org/apache/commons/xml/secure/SecureTransformerTest.java
+++ b/src/test/java/org/apache/commons/xml/secure/SecureTransformerTest.java
@@ -61,15 +61,6 @@ void adoptsAResolverTheDelegateAlreadyCarries() throws 
Exception {
         
assertFalse(output.toString().contains(AttackTestSupport.LEAKED_MARKER), "the 
real resource must not be fetched");
     }
 
-    @Test
-    void keepsTheFloorUnderACarriedResolverThatDeclines() throws Exception {
-        // Adopting the caller's resolver must not make the floor reachable 
around: what the resolver declines stays unfetched.
-        final SecureTransformer transformer = wrap((href, base) -> null);
-        final StringWriter output = new StringWriter();
-        transformer.transform(AttackTestSupport.streamSource("<root/>"), new 
StreamResult(output));
-        
assertFalse(output.toString().contains(AttackTestSupport.LEAKED_MARKER), 
"document() the resolver declined must not be fetched");
-    }
-
     @Test
     void carriesTheAdoptedResolverThroughReset() throws Exception {
         final URIResolver carried = (href, base) -> new StreamSource(new 
StringReader("<opted-in/>"));
@@ -117,4 +108,13 @@ public void warning(final TransformerException e) {
         transformer.transform(new 
DOMSource(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()),
 new StreamResult(new StringWriter()));
         transformer.reset();
     }
+
+    @Test
+    void keepsTheFloorUnderACarriedResolverThatDeclines() throws Exception {
+        // Adopting the caller's resolver must not make the floor reachable 
around: what the resolver declines stays unfetched.
+        final SecureTransformer transformer = wrap((href, base) -> null);
+        final StringWriter output = new StringWriter();
+        transformer.transform(AttackTestSupport.streamSource("<root/>"), new 
StreamResult(output));
+        
assertFalse(output.toString().contains(AttackTestSupport.LEAKED_MARKER), 
"document() the resolver declined must not be fetched");
+    }
 }
diff --git 
a/src/test/java/org/apache/commons/xml/secure/TransformerHandlerTest.java 
b/src/test/java/org/apache/commons/xml/secure/TransformerHandlerTest.java
index 06d35be..0dfde43 100644
--- a/src/test/java/org/apache/commons/xml/secure/TransformerHandlerTest.java
+++ b/src/test/java/org/apache/commons/xml/secure/TransformerHandlerTest.java
@@ -47,28 +47,14 @@
 @Tag("trax")
 class TransformerHandlerTest {
 
-    private static String transformViaHandler(final TransformerHandler 
handler) throws Exception {
-        final StringWriter sink = new StringWriter();
-        handler.setResult(new StreamResult(sink));
-        SaxSurfaceTestSupport.feed(handler, SaxSurfaceTestSupport.rootInput());
-        return sink.toString();
-    }
-
-    @Test
-    void secureGetTransformerDoesNotLeakDocument() throws Exception {
-        // The f004 bypass: pull the inner Transformer out of the handler and 
transform directly; the floor must ride along.
-        final SAXTransformerFactory factory = 
SaxSurfaceTestSupport.secureFactory();
-        final TransformerHandler handler = 
factory.newTransformerHandler(AttackTestSupport.resourceSource("with-document.xsl"));
-        final StringWriter sink = new StringWriter();
-        
handler.getTransformer().transform(AttackTestSupport.streamSource("<root/>"), 
new StreamResult(sink));
-        assertFalse(sink.toString().contains(AttackTestSupport.LEAKED_MARKER), 
"document() through getTransformer() leaked");
-    }
-
-    @Test
-    void secureTransformerHandlerDoesNotLeakDocument() throws Exception {
-        final SAXTransformerFactory factory = 
SaxSurfaceTestSupport.secureFactory();
-        final TransformerHandler handler = 
factory.newTransformerHandler(AttackTestSupport.resourceSource("with-document.xsl"));
-        
assertFalse(transformViaHandler(handler).contains(AttackTestSupport.LEAKED_MARKER),
 "document() through TransformerHandler leaked");
+    /** Skips the test where the implementation refuses a Templates it did not 
compile itself, as Saxon does. */
+    private static TransformerHandler assumeAcceptsForeignImplementation(final 
Templates callers) {
+        try {
+            return ((SAXTransformerFactory) 
TransformerFactory.newInstance()).newTransformerHandler(callers);
+        } catch (final TransformerConfigurationException e) {
+            Assumptions.abort("the implementation does not accept a foreign 
Templates: " + e.getMessage());
+            return null;
+        }
     }
 
     /** A caller's own Templates that only configures the Transformer it hands 
out, the shape Apache CXF's XSLTJaxbProvider builds. */
@@ -89,14 +75,21 @@ public Transformer newTransformer() throws 
TransformerConfigurationException {
         };
     }
 
-    /** Skips the test where the implementation refuses a Templates it did not 
compile itself, as Saxon does. */
-    private static TransformerHandler assumeAcceptsForeignImplementation(final 
Templates callers) {
-        try {
-            return ((SAXTransformerFactory) 
TransformerFactory.newInstance()).newTransformerHandler(callers);
-        } catch (final TransformerConfigurationException e) {
-            Assumptions.abort("the implementation does not accept a foreign 
Templates: " + e.getMessage());
-            return null;
-        }
+    private static String transformViaHandler(final TransformerHandler 
handler) throws Exception {
+        final StringWriter sink = new StringWriter();
+        handler.setResult(new StreamResult(sink));
+        SaxSurfaceTestSupport.feed(handler, SaxSurfaceTestSupport.rootInput());
+        return sink.toString();
+    }
+
+    @Test
+    void secureGetTransformerDoesNotLeakDocument() throws Exception {
+        // The f004 bypass: pull the inner Transformer out of the handler and 
transform directly; the floor must ride along.
+        final SAXTransformerFactory factory = 
SaxSurfaceTestSupport.secureFactory();
+        final TransformerHandler handler = 
factory.newTransformerHandler(AttackTestSupport.resourceSource("with-document.xsl"));
+        final StringWriter sink = new StringWriter();
+        
handler.getTransformer().transform(AttackTestSupport.streamSource("<root/>"), 
new StreamResult(sink));
+        assertFalse(sink.toString().contains(AttackTestSupport.LEAKED_MARKER), 
"document() through getTransformer() leaked");
     }
 
     @Test
@@ -114,6 +107,13 @@ void secureHandlerKeepsAResolverTheCallersTemplatesSet() 
throws Exception {
         
assertFalse(transformViaHandler(handler).contains(AttackTestSupport.LEAKED_MARKER),
 "what that resolver declined must not be fetched");
     }
 
+    @Test
+    void secureTransformerHandlerDoesNotLeakDocument() throws Exception {
+        final SAXTransformerFactory factory = 
SaxSurfaceTestSupport.secureFactory();
+        final TransformerHandler handler = 
factory.newTransformerHandler(AttackTestSupport.resourceSource("with-document.xsl"));
+        
assertFalse(transformViaHandler(handler).contains(AttackTestSupport.LEAKED_MARKER),
 "document() through TransformerHandler leaked");
+    }
+
     @Test
     void secureTransformerHandlerFromTemplatesDoesNotLeakDocument() throws 
Exception {
         final SAXTransformerFactory factory = 
SaxSurfaceTestSupport.secureFactory();

Reply via email to