Author: bmaxwell
Date: 2011-04-08 23:25:54 -0400 (Fri, 08 Apr 2011)
New Revision: 14048
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/Endpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/EndpointImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/JBWS2901TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/web.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/wsdl/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/wsdl/service.wsdl
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/attack-message-1.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/message.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/passwd
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
Log:
[JBPAPP-6242][JBPAPP-6243] adding test case for JBWS-2901
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2011-04-09
02:44:41 UTC (rev 14047)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2011-04-09
03:25:54 UTC (rev 14048)
@@ -630,6 +630,20 @@
<include name="jboss-web.xml"/>
</webinf>
</war>
+
+ <!-- jaxws-jbws2901 -->
+ <war destfile="${tests.output.dir}/test-libs/jaxws-jbws2901.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2901/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2901/Endpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/jbws2901/EndpointImpl.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2901/WEB-INF">
+ <include name="wsdl/service.wsdl"/>
+ </webinf>
+ <fileset dir="${tests.output.dir}/test-resources/jaxws/jbws2901">
+ <include name="passwd" />
+ </fileset>
+ </war>
<!-- jaxws-jbws2927 -->
<war warfile="${tests.output.dir}/test-libs/jaxws-jbws2927.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2927/WEB-INF/web.xml">
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/Endpoint.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/Endpoint.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/Endpoint.java 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2901;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService (name="Endpoint")
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+public interface Endpoint
+{
+ @WebMethod(operationName = "echoString", action =
"urn:EchoString")
+ String echo(String input);
+}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/EndpointImpl.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/EndpointImpl.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/EndpointImpl.java 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2901;
+
+import javax.jws.WebService;
+
+@WebService
+(
+ portName = "EndpointPort",
+ serviceName = "EndpointService",
+ wsdlLocation = "WEB-INF/wsdl/service.wsdl",
+ endpointInterface = "org.jboss.test.ws.jaxws.jbws2901.Endpoint"
+)
+public class EndpointImpl
+{
+ public String echo(String msg)
+ {
+ return msg;
+ }
+}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/JBWS2901TestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/JBWS2901TestCase.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2901/JBWS2901TestCase.java 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,98 @@
+/**
+ *
+ */
+package org.jboss.test.ws.jaxws.jbws2901;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.common.IOUtils;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+import org.jboss.test.ws.jaxws.jbws2901.Endpoint;
+/**
+ * [JBWS-2901] Disable XML external entity resolver
+ *
+ * @author <a href="mailto:bmaxwell@redhat.com">Brad Maxwell</a>
+ *
+ */
+public class JBWS2901TestCase extends JBossWSTest
+{
+ private String endpointURL = "http://" + getServerHost() +
":8080/jaxws-jbws2901/TestService";
+ private String targetNS = "http://jbws2901.jaxws.ws.test.jboss.org/";
+ private String passwdContents = "root:x:0:0:root:/root:/bin/bash";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS2901TestCase.class,
"jaxws-jbws2901.war");
+ }
+
+ public void testLegalAccess() throws Exception
+ {
+ URL wsdlURL = new URL(endpointURL + "?wsdl");
+ QName serviceName = new QName(targetNS, "EndpointService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+
+ Object retObj = port.echo("Hello");
+ assertEquals("Hello", retObj);
+ }
+
+ public void testSOAPMessage() throws Exception
+ {
+ String response = getResponse("jaxws/jbws2901/message.xml");
+ assertTrue(response.contains("HTTP/1.1 200 OK"));
+ assertTrue(response.contains("<return>Hello</return>"));
+ }
+
+ public void testSOAPMessageAttack1() throws Exception
+ {
+ String response = getResponse("jaxws/jbws2901/attack-message-1.xml");
+ assertFalse(response.contains(passwdContents));
+ }
+
+ private String getResponse(String requestFile) throws Exception
+ {
+ final String CRNL = "\r\n";
+ String content = getContent(new FileInputStream(getResourceFile(requestFile)));
+ Socket socket = new Socket();
+ socket.connect(new InetSocketAddress(getServerHost(), 8080));
+ OutputStream out = socket.getOutputStream();
+
+ // send an HTTP request to the endpoint
+ out.write(("POST /jaxws-jbws2901/TestService HTTP/1.0" +
CRNL).getBytes());
+ out.write(("Host: " + getServerHost() + ":8080" +
CRNL).getBytes());
+ out.write(("Content-Type: text/xml" + CRNL).getBytes());
+ out.write(("Content-Length: " + content.length() + CRNL).getBytes());
+ out.write((CRNL).getBytes());
+ out.write((content).getBytes());
+
+ // read the response
+ String response = getContent(socket.getInputStream());
+ socket.close();
+ System.out.println("---");
+ System.out.println(response);
+ System.out.println("---");
+ return response;
+ }
+
+ private static String getContent(InputStream is) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copyStream(baos, is);
+ return new String(baos.toByteArray());
+ }
+}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/web.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/web.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/web.xml 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.jbws2901.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/TestService</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/wsdl/service.wsdl
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/wsdl/service.wsdl
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/WEB-INF/wsdl/service.wsdl 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions name='EndpointService'
targetNamespace='http://jbws2901.jaxws.ws.test.jboss.org/'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://jbws2901.jaxws.ws.test.jboss.org/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xs:schema
targetNamespace='http://jbws2901.jaxws.ws.test.jboss.org/'
version='1.0'
xmlns:tns='http://jbws2901.jaxws.ws.test.jboss.org/'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='echoString' type='tns:echoString'/>
+ <xs:element name='echoStringResponse'
type='tns:echoStringResponse'/>
+ <xs:complexType name='echoString'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='arg0'
type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name='echoStringResponse'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='return'
type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </types>
+ <message name='Endpoint_echoString'>
+ <part element='tns:echoString' name='echoString'/>
+ </message>
+ <message name='Endpoint_echoStringResponse'>
+ <part element='tns:echoStringResponse'
name='echoStringResponse'/>
+ </message>
+ <portType name='Endpoint'>
+ <operation name='echoString' parameterOrder='echoString'>
+ <input message='tns:Endpoint_echoString'/>
+ <output message='tns:Endpoint_echoStringResponse'/>
+ </operation>
+ </portType>
+ <binding name='EndpointBinding' type='tns:Endpoint'>
+ <soap:binding style='document'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='echoString'>
+ <soap:operation soapAction='urn:EchoString'/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='EndpointService'>
+ <port binding='tns:EndpointBinding' name='EndpointPort'>
+ <soap:address location='REPLACE_WITH_ACTUAL_URL'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/attack-message-1.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/attack-message-1.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/attack-message-1.xml 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"
?>
+<!DOCTYPE x[
+<!ENTITY showme SYSTEM "http://localhost:8080/jaxws-jbws2901/passwd">
+]
+>
+<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:jbw="http://jbws2901.jaxws.ws.test.jboss.org/">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <jbw:echoString>
+ <!--Optional:-->
+ <arg0>&showme;</arg0>
+ </jbw:echoString>
+ </soapenv:Body>
+</soapenv:Envelope>
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/message.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/message.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/message.xml 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:jbw="http://jbws2901.jaxws.ws.test.jboss.org/">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <jbw:echoString>
+ <!--Optional:-->
+ <arg0>Hello</arg0>
+ </jbw:echoString>
+ </soapenv:Body>
+</soapenv:Envelope>
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/passwd
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/passwd
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2901/passwd 2011-04-09
03:25:54 UTC (rev 14048)
@@ -0,0 +1 @@
+root:x:0:0:root:/root:/bin/bash