This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch CXF-8671
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/CXF-8671 by this push:
new 278f733ab8 Adapt JAXRSServicesListingTest test cases to jetty 12.0.8+
changes
278f733ab8 is described below
commit 278f733ab8f3593b18c411190c91883669138374
Author: Andriy Redko <[email protected]>
AuthorDate: Fri Apr 5 09:58:06 2024 -0400
Adapt JAXRSServicesListingTest test cases to jetty 12.0.8+ changes
---
.../systest/jaxrs/JAXRSServicesListingTest.java | 27 +++++++++++++++-------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSServicesListingTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSServicesListingTest.java
index 43f167f2e3..ec167f9ea3 100644
---
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSServicesListingTest.java
+++
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSServicesListingTest.java
@@ -19,6 +19,7 @@
package org.apache.cxf.systest.jaxrs;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -29,7 +30,10 @@ import
org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class JAXRSServicesListingTest extends AbstractBusClientServerTestBase {
@@ -80,10 +84,13 @@ public class JAXRSServicesListingTest extends
AbstractBusClientServerTestBase {
"http://localhost:" + PORT +
"/service_listing/services/<script>alert(1)</script>/../../";
URL url = new URL(endpointAddress);
- try (InputStream input = url.openStream()) {
- String result = IOUtils.readStringFromStream(input);
- assertFalse(result.contains("<script>"));
- }
+ final IOException ex = assertThrows(IOException.class, () -> {
+ try (InputStream input = url.openStream()) {
+ String result = IOUtils.readStringFromStream(input);
+ assertFalse(result.contains("<script>"));
+ }
+ });
+ assertThat(ex.getMessage(), containsString("400 for URL: " +
endpointAddress));
}
@Test
@@ -93,10 +100,14 @@ public class JAXRSServicesListingTest extends
AbstractBusClientServerTestBase {
"http://localhost:" + PORT +
"/service_listing/services/<script>alert(1)</script>/../../?formatted=false";
URL url = new URL(endpointAddress);
- try (InputStream input = url.openStream()) {
- String result = IOUtils.readStringFromStream(input);
- assertFalse(result.contains("<script>"));
- }
+ // Changes sinceJetty 12.0.8+ see please
https://github.com/jetty/jetty.project/pull/11496
+ final IOException ex = assertThrows(IOException.class, () -> {
+ try (InputStream input = url.openStream()) {
+ String result = IOUtils.readStringFromStream(input);
+ assertFalse(result.contains("<script>"));
+ }
+ });
+ assertThat(ex.getMessage(), containsString("400 for URL: " +
endpointAddress));
}
@Test