You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xi...@apache.org on 2010/07/27 16:27:58 UTC
svn commit: r979723 - in /geronimo/server/trunk/testsuite/javaee6-testsuite:
./ servlet3.0-security-test/ servlet3.0-security-test/src/
servlet3.0-security-test/src/main/ servlet3.0-security-test/src/main/java/
servlet3.0-security-test/src/main/java/or...
Author: xiaming
Date: Tue Jul 27 14:27:57 2010
New Revision: 979723
URL: http://svn.apache.org/viewvc?rev=979723&view=rev
Log:
GERONIMO-5453 commit servlet 3.0 security test code to trunk which is provided by LiWenQin
Added:
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/
geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml (with props)
Modified:
geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml
Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml?rev=979723&r1=979722&r2=979723&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml Tue Jul 27 14:27:57 2010
@@ -54,6 +54,8 @@
<modules>
<module>beanvalidation-test</module>
<module>servlet3.0-test</module>
+ <module>servlet3.0-security-test</module>
+ <module>ejb3.1lite-test</module>
</modules>
</project>
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml Tue Jul 27 14:27:57 2010
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.geronimo.testsuite</groupId>
+ <artifactId>javaee6-testsuite</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>servlet3.0-security-test</artifactId>
+ <name>Geronimo TestSuite :: Java EE 6 Testsuite :: Test Servlet 3.0 Security</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
+ <version>3.1_4</version>
+ </dependency>
+ </dependencies>
+
+<profiles>
+ <profile>
+ <id>it</id>
+ <activation>
+ <property>
+ <name>it</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <suiteXmlFile>
+ ${project.build.testOutputDirectory}/testng.xml
+ </suiteXmlFile>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.geronimo.buildsupport</groupId>
+ <artifactId>geronimo-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy-wars</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>deploy-module</goal>
+ </goals>
+ <configuration>
+ <moduleArchive>${project.build.directory}/${project.artifactId}-${project.version}.war</moduleArchive>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>undeploy-war-as-moduleId</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>undeploy-module</goal>
+ </goals>
+ <configuration>
+ <moduleId>${project.groupId}/${project.artifactId}/${project.version}/car</moduleId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+</profiles>
+</project>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,39 @@
+/**
+ * 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.geronimo.testsuite.servlet30.main;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.annotation.WebServlet;
+
+@WebServlet(name = "WebServlet", urlPatterns = {"/WebServlet1", "/WebServlet2"} )
+public class AnnotationWebServlet extends javax.servlet.http.HttpServlet{
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("AnnotationWebServlet.doGet");
+ }
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("AnnotationWebServlet.doPost");
+ }
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,51 @@
+/**
+ * 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.geronimo.testsuite.servlet30.main;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet implementation class for Servlet: SampleServlet
+ *
+ * @web.servlet
+ * name="SampleServlet"
+ * display-name="SampleServlet"
+ *
+ * @web.servlet-mapping
+ * url-pattern="/SampleServlet"
+ *
+ */
+public class SampleServlet1 extends javax.servlet.http.HttpServlet {
+
+ private static final long serialVersionUID = 9018839728530599983L;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("SampleServlet1.doGet");
+ }
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("SampleServlet1.doPost");
+ }
+}
\ No newline at end of file
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,43 @@
+/**
+ * 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.geronimo.testsuite.servlet30.main;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.HttpMethodConstraint;
+import javax.servlet.annotation.ServletSecurity;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@ServletSecurity(httpMethodConstraints = { @HttpMethodConstraint(value = "POST", rolesAllowed = "RoleB") })
+public class SampleServlet2 extends javax.servlet.http.HttpServlet {
+
+ private static final long serialVersionUID = 7870791395515797291L;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("SampleServlet2.doGet");
+ }
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("SampleServlet2.doPost");
+ }
+}
\ No newline at end of file
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,46 @@
+/**
+ * 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.geronimo.testsuite.servlet30.main;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SampleServlet3 extends HttpServlet {
+
+ private static final long serialVersionUID = -4328073983584515406L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ PrintWriter printWriter = resp.getWriter();
+ printWriter.write("SampleServlet3.doGet");
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ PrintWriter printWriter = resp.getWriter();
+ printWriter.write("SampleServlet3.doPost");
+ }
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,48 @@
+/**
+ * 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.geronimo.testsuite.servlet30.main;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.annotation.HttpMethodConstraint;
+import javax.servlet.annotation.ServletSecurity;
+import javax.servlet.annotation.HttpConstraint;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+@WebServlet("/SampleServlet4")
+@ServletSecurity(httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = "RoleB") })
+public class SampleServlet4 extends HttpServlet{
+
+ private static final long serialVersionUID = 1L;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("SampleServlet4.doGet");
+ }
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter printWriter = response.getWriter();
+ printWriter.write("SampleServlet4.doPost");
+ }
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,62 @@
+/**
+ * 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.geronimo.testsuite.servlet30.main;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.HttpConstraintElement;
+import javax.servlet.HttpMethodConstraintElement;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletSecurityElement;
+import javax.servlet.ServletRegistration.Dynamic;
+import javax.servlet.annotation.ServletSecurity;
+import javax.servlet.annotation.WebListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@WebListener
+public class SampleServletContextListener implements ServletContextListener {
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ }
+
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+
+ ServletContext servletContext = servletContextEvent.getServletContext();
+
+ //dynamic register /SampleServlet3Dynamic and security constraint
+ Dynamic servlet3Dynamic = servletContext.addServlet("SampleServlet3Dynamic", SampleServlet3.class);
+ servlet3Dynamic.addMapping("/SampleServlet3Dynamic", "/TestDynamic");
+ HttpConstraintElement httpConstraintElement = new HttpConstraintElement();
+ List<HttpMethodConstraintElement> httpMethodConstraintElements = new ArrayList<HttpMethodConstraintElement>();
+ httpMethodConstraintElements.add(new HttpMethodConstraintElement("GET", new HttpConstraintElement(ServletSecurity.TransportGuarantee.NONE, "RoleC")));
+ ServletSecurityElement servletSecurityElement = new ServletSecurityElement(httpConstraintElement, httpMethodConstraintElements);
+ Set<String> uneffectedUrlPatterns = servlet3Dynamic.setServletSecurity(servletSecurityElement);
+ if (uneffectedUrlPatterns.size() == 0) {
+ throw new RuntimeException("/SampleServlet3Dynamic should be returned as it is defined in the web.xml file");
+ }
+ }
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml Tue Jul 27 14:27:57 2010
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
+ <dep:environment>
+ <dep:moduleId>
+ <dep:groupId>${project.groupId}</dep:groupId>
+ <dep:artifactId>${project.artifactId}</dep:artifactId>
+ <dep:version>${project.version}</dep:version>
+ <dep:type>car</dep:type>
+ </dep:moduleId>
+ </dep:environment>
+ <context-root>/servlet30</context-root>
+ <security-realm-name>demo-properties-realm</security-realm-name>
+ <security use-context-handler="false">
+ <role-mappings>
+ <role role-name="RoleA">
+ <realm realm-name="cts-properties-realm">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="alan"/>
+ </realm>
+ </role>
+ <role role-name="RoleB">
+ <realm realm-name="cts-properties-realm">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="george"/>
+ </realm>
+ </role>
+ <role role-name="RoleC">
+ <realm realm-name="cts-properties-realm">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="gracie"/>
+ </realm>
+ </role>
+ </role-mappings>
+ </security>
+ <gbean name="demo-properties-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm" xsi:type="dep:gbeanType" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <attribute name="realmName">demo-properties-realm</attribute>
+ <reference name="ServerInfo">
+ <name>ServerInfo</name>
+ </reference>
+ <xml-reference name="LoginModuleConfiguration">
+ <log:login-config xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-1.2">
+ <log:login-module control-flag="REQUIRED" wrap-principals="false">
+ <log:login-domain-name>demo-properties-realm</log:login-domain-name>
+ <log:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</log:login-module-class>
+ <log:option name="usersURI">var/security/demo_users.properties</log:option>
+ <log:option name="groupsURI">var/security/demo_groups.properties</log:option>
+ </log:login-module>
+ </log:login-config>
+ </xml-reference>
+ </gbean>
+</web-app>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml Tue Jul 27 14:27:57 2010
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" metadata-complete="false">
+ <display-name>SampleServlet</display-name>
+ <servlet>
+ <description></description>
+ <display-name>SampleServlet1</display-name>
+ <servlet-name>SampleServlet1</servlet-name>
+ <servlet-class>org.apache.geronimo.testsuite.servlet30.main.SampleServlet1</servlet-class>
+ </servlet>
+ <servlet>
+ <description></description>
+ <display-name>SampleServlet2</display-name>
+ <servlet-name>SampleServlet2</servlet-name>
+ <servlet-class>org.apache.geronimo.testsuite.servlet30.main.SampleServlet2</servlet-class>
+ </servlet>
+ <servlet>
+ <description></description>
+ <display-name>SampleServlet3</display-name>
+ <servlet-name>SampleServlet3</servlet-name>
+ <servlet-class>org.apache.geronimo.testsuite.servlet30.main.SampleServlet3</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SampleServlet1</servlet-name>
+ <url-pattern>/SampleServlet1</url-pattern>
+ <url-pattern>/SampleServlet1/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>SampleServlet2</servlet-name>
+ <url-pattern>/SampleServlet2</url-pattern>
+ <url-pattern>/SampleServlet2/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>SampleServlet3</servlet-name>
+ <url-pattern>/SampleServlet3</url-pattern>
+ <url-pattern>/SampleServlet3/*</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>resource1</web-resource-name>
+ <url-pattern>/SampleServlet1</url-pattern>
+ <url-pattern>/SampleServlet3Dynamic</url-pattern>
+ <http-method-omission>POST</http-method-omission>
+ </web-resource-collection>
+ <auth-constraint/>
+ </security-constraint>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>resource2</web-resource-name>
+ <url-pattern>/SampleServlet2</url-pattern>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>RoleA</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>demo-properties-realm</realm-name>
+ </login-config>
+ <security-role>
+ <role-name>RoleA</role-name>
+ </security-role>
+ <security-role>
+ <role-name>RoleB</role-name>
+ </security-role>
+ <security-role>
+ <role-name>RoleC</role-name>
+ </security-role>
+</web-app>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java Tue Jul 27 14:27:57 2010
@@ -0,0 +1,201 @@
+/**
+ * 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.geronimo.testsuite.servlets;
+
+import java.net.HttpURLConnection;
+
+import javax.servlet.annotation.HttpMethodConstraint;
+import javax.servlet.annotation.ServletSecurity;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class ServletsTest {
+
+/**In web.xml, it reads as follows:
+ * <security-constraint>
+ * <web-resource-collection>
+ * <web-resource-name>resource1</web-resource-name>
+ * <url-pattern>/SampleServlet</url-pattern>
+ * <url-pattern>/SampleServlet3Dynamic</url-pattern>
+ * <http-method-omission>POST</http-method-omission>
+ * </web-resource-collection>
+ * <auth-constraint/>
+ * </security-constraint>
+ * The Test1 and Test2 tests the description above.
+ */
+
+ /**
+ * Test1
+ * test <http-method-omission>
+ */
+ @Test
+ public void test_SampleServlet_POST_Sucess() throws Exception {
+ Assert.assertEquals( invoke("/SampleServlet1", "POST", "alan", "starcraft"), HttpURLConnection.HTTP_OK);
+ }
+
+ /**
+ * Test2
+ */
+ @Test
+ public void test_SampleServlet1_GET_Fail() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet1", "GET", "alan", "starcraft"), HttpURLConnection.HTTP_FORBIDDEN);
+ }
+
+ /**
+ * Test3
+ * <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>resource2</web-resource-name>
+ <url-pattern>/SampleServlet2</url-pattern>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>RoleA</role-name>
+ </auth-constraint>
+ </security-constraint>
+ */
+ @Test
+ public void test_SampleServlet2_GET_RoleA_Success() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet2" , "GET", "alan" , "starcraft" ) , HttpURLConnection.HTTP_OK);
+ }
+
+ /**
+ * Test4
+ */
+ @Test
+ public void test_SampleServlet2_GET_RoleB_Fail() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet2" , "GET", "george" , "bone" ) , HttpURLConnection.HTTP_FORBIDDEN);
+ }
+
+ /**
+ * Test5
+ * @WebServlet("/SampleServlet4")
+ * @ServletSecurity(httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = "RoleB") })
+ * public class SampleServlet4 extends HttpServlet{
+ */
+ @Test
+ public void test_SampleServlet4_POST_RoleB_Success() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet4", "POST", "george", "bone"), HttpURLConnection.HTTP_OK);
+ }
+
+ /**
+ * Test6
+ */
+ @Test
+ public void test_SampleServlet4_POST_RoleC_Fail() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet4", "POST", "gracie", "biscuit"), HttpURLConnection.HTTP_FORBIDDEN);
+ }
+
+ /**
+ * Test7
+ */
+ @Test
+ public void test_SampleServlet3_All_Success() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet3", "POST", "unknown", "unknown"), HttpURLConnection.HTTP_OK);
+ }
+
+ /**
+ * Test8
+ * URL "/SampleServlet3Dynamic" are set both in web.xml and ServletRegistration.Dynamic
+ * IN web.xml,GET access is forbidden by all users.
+ * In ServletRegistration.Dynamic, GET access is allowled by RoleC
+ * But web.xml content's priority is higher.
+ */
+ @Test
+ public void test_SampleServlet3Dynamic_GET_RoleC_Fail() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet3Dynamic", "GET", "gracie", "biscuit"), HttpURLConnection.HTTP_FORBIDDEN);
+ }
+
+
+ /**
+ * Test9
+ */
+ @Test
+ public void test_SampleServlet3Dynamic_POST_RoleAll_Success() throws Exception {
+ Assert.assertEquals(invoke("/SampleServlet3Dynamic", "POST", "unknown", "unknown"), HttpURLConnection.HTTP_OK);
+ }
+
+
+ /**
+ * Test10
+ * Test @WebServlet annotation feature in Servlet 3.0
+ */
+ @Test
+ public void test_annotation_WebServlet() throws Exception{
+ Assert.assertEquals(invoke("/WebServlet1", "POST", "unknown", "unknown"), HttpURLConnection.HTTP_OK);
+ }
+
+ /**
+ * Test11
+ * Test @WebServlet annotation feature in Servlet 3.0
+ * Test mapping two url in @WebServlet
+ * (name = "WebServlet", urlPatterns = {"/WebServlet1", "/WebServlet2"} )
+ */
+ @Test
+ public void test_annotation_WebServlet2() throws Exception{
+ Assert.assertEquals(invoke("/WebServlet2", "GET", "unknown", "unknown"), HttpURLConnection.HTTP_OK);
+ }
+
+
+
+ /**
+ * Test12
+ * In ServletRegistration.Dynamic, GET access is allowled by RoleC
+ */
+ @Test
+ public void test_TestDynamic_GET_RoleC_Sucess() throws Exception{
+ Assert.assertEquals(invoke("/TestDynamic", "GET", "gracie", "biscuit"), HttpURLConnection.HTTP_OK);
+ }
+
+ /**
+ * Test13
+ */
+ @Test
+ public void test_TestDynamic_GET_RoleB_Fail() throws Exception{
+ Assert.assertEquals(invoke("/TestDynamic", "GET", "george", "bone"), HttpURLConnection.HTTP_FORBIDDEN);
+ }
+
+ private int invoke(String address, String methodName, String userName, String password) throws Exception {
+ HttpClient client = new HttpClient();
+ Credentials defaultcreds = new UsernamePasswordCredentials(userName, password);
+ client.getState().setCredentials(AuthScope.ANY, defaultcreds);
+ String url = "http://localhost:8080/servlet30" + address;
+ HttpMethodBase httpMethod;
+ if (methodName.equals("GET")) {
+ httpMethod = new GetMethod(url);
+ } else {
+ httpMethod = new PostMethod(url);
+ }
+ return client.executeMethod(httpMethod);
+ }
+
+}
\ No newline at end of file
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml?rev=979723&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml Tue Jul 27 14:27:57 2010
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+
+<suite name="Suite1" verbose="5">
+ <test name="web-testsuite.servlets">
+ <packages>
+ <package name="org.apache.geronimo.testsuite.servlets"/>
+ </packages>
+ </test>
+</suite>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml