[jboss-cvs] JBossAS SVN: r68271 - in projects/metadata/trunk/src: test/java/org/jboss/test/metadata/web and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 14 03:33:13 EST 2007
Author: scott.stark at jboss.org
Date: 2007-12-14 03:33:12 -0500 (Fri, 14 Dec 2007)
New Revision: 68271
Added:
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/web/WebApp24UnitTestCase.java
projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/web/WebApp24_testSecurityConstraint.xml
Modified:
projects/metadata/trunk/src/main/java/org/jboss/metadata/web/spec/WebResourceCollectionsMetaData.java
Log:
JBAS-5069, The WebResourceCollectionsMetaData needs to be a list rather than a set.
Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/web/spec/WebResourceCollectionsMetaData.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/web/spec/WebResourceCollectionsMetaData.java 2007-12-14 05:10:33 UTC (rev 68270)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/web/spec/WebResourceCollectionsMetaData.java 2007-12-14 08:33:12 UTC (rev 68271)
@@ -21,17 +21,17 @@
*/
package org.jboss.metadata.web.spec;
-import org.jboss.metadata.javaee.support.AbstractMappedMetaData;
+import java.util.ArrayList;
/**
+ * The security-constraint/web-resource-collection list
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
-public class WebResourceCollectionsMetaData extends AbstractMappedMetaData<WebResourceCollectionMetaData>
+public class WebResourceCollectionsMetaData extends ArrayList<WebResourceCollectionMetaData>
{
private static final long serialVersionUID = 1;
public WebResourceCollectionsMetaData()
{
- super("web app security-constraint/web-resource-collection");
}
}
\ No newline at end of file
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/web/WebApp24UnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/web/WebApp24UnitTestCase.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/web/WebApp24UnitTestCase.java 2007-12-14 08:33:12 UTC (rev 68271)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metadata.web;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
+import org.jboss.metadata.web.jboss.JBoss50DTDWebMetaData;
+import org.jboss.metadata.web.spec.AuthConstraintMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.TransportGuaranteeType;
+import org.jboss.metadata.web.spec.Web23MetaData;
+import org.jboss.metadata.web.spec.Web24MetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+import org.jboss.test.metadata.javaee.AbstractJavaEEEverythingTest;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+
+/**
+ * Tests of 2.4 web-app elements
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class WebApp24UnitTestCase extends AbstractJavaEEEverythingTest
+{
+
+ public WebApp24UnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static SchemaBindingResolver initResolver()
+ {
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addClassBindingForLocation("web-app_2_4.xsd", Web24MetaData.class);
+ return resolver;
+ }
+
+ public void testSecurityConstraint() throws Exception
+ {
+ WebMetaData webApp = unmarshal();
+ List<SecurityConstraintMetaData> scs = webApp.getSecurityContraints();
+ assertEquals(8, scs.size());
+ // SC1
+ SecurityConstraintMetaData sc1 = scs.get(0);
+ WebResourceCollectionsMetaData sc1WRC = sc1.getResourceCollections();
+ assertEquals(2, sc1WRC.size());
+ WebResourceCollectionMetaData sc1WRC1 = sc1WRC.get(0);
+ assertEquals(Collections.emptyList(), sc1WRC1.getHttpMethods());
+ List<String> sc1WRC1URLs = sc1WRC1.getUrlPatterns();
+ assertEquals(4, sc1WRC1URLs.size());
+ assertEquals("/excluded/*", sc1WRC1URLs.get(0));
+ assertEquals("/restricted/get-only/excluded/*", sc1WRC1URLs.get(1));
+ assertEquals("/restricted/post-only/excluded/*", sc1WRC1URLs.get(2));
+ assertEquals("/restricted/any/excluded/*", sc1WRC1URLs.get(3));
+ WebResourceCollectionMetaData sc1WRC2 = sc1WRC.get(1);
+ List<String> sc1WRC2URLs = sc1WRC2.getUrlPatterns();
+ assertEquals(1, sc1WRC2URLs.size());
+ assertEquals("/restricted/*", sc1WRC2URLs.get(0));
+ List<String> sc1WRC2Http = sc1WRC2.getHttpMethods();
+ ArrayList<String> sc1WRC2HttpExpected = new ArrayList<String>();
+ sc1WRC2HttpExpected.add("DELETE");
+ sc1WRC2HttpExpected.add("PUT");
+ sc1WRC2HttpExpected.add("HEAD");
+ sc1WRC2HttpExpected.add("OPTIONS");
+ sc1WRC2HttpExpected.add("TRACE");
+ sc1WRC2HttpExpected.add("GET");
+ sc1WRC2HttpExpected.add("POST");
+ assertEquals(sc1WRC2HttpExpected, sc1WRC2Http);
+ AuthConstraintMetaData sc1AC = sc1.getAuthConstraint();
+ List<String> sc1Roles = sc1AC.getRoleNames();
+ assertEquals(null, sc1Roles);
+ TransportGuaranteeType sc1TG = sc1.getTransportGuarantee();
+ assertEquals(TransportGuaranteeType.NONE, sc1TG);
+ sc1Roles = sc1.getRoleNames();
+ assertEquals(0, sc1Roles.size());
+ assertTrue(sc1.isExcluded());
+ assertFalse(sc1.isUnchecked());
+ // SC2
+ SecurityConstraintMetaData sc2 = scs.get(1);
+ // SC8
+ SecurityConstraintMetaData sc8 = scs.get(7);
+ AuthConstraintMetaData sc8AC = sc8.getAuthConstraint();
+ assertEquals(null, sc8AC);
+ WebResourceCollectionMetaData sc8ACWRC = sc8.getResourceCollections().get(0);
+ assertEquals("/restricted/not/*", sc8ACWRC.getUrlPatterns().get(0));
+ assertFalse(sc8.isExcluded());
+ assertTrue(sc8.isUnchecked());
+ }
+
+ protected WebMetaData unmarshal() throws Exception
+ {
+ return unmarshal(Web24MetaData.class);
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/web/WebApp24UnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/web/WebApp24_testSecurityConstraint.xml
===================================================================
--- projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/web/WebApp24_testSecurityConstraint.xml (rev 0)
+++ projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/web/WebApp24_testSecurityConstraint.xml 2007-12-14 08:33:12 UTC (rev 68271)
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4"
+ 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">
+
+ <description>Tests of various security-constraints</description>
+
+ <servlet>
+ <servlet-name>ConstraintsServlet</servlet-name>
+ <servlet-class>org.jboss.test.security.servlets.ConstraintsServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ConstraintsServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint id="SC1">
+ <display-name>excluded</display-name>
+ <web-resource-collection>
+ <web-resource-name>No Access</web-resource-name>
+ <url-pattern>/excluded/*</url-pattern>
+ <url-pattern>/restricted/get-only/excluded/*</url-pattern>
+ <url-pattern>/restricted/post-only/excluded/*</url-pattern>
+ <url-pattern>/restricted/any/excluded/*</url-pattern>
+ </web-resource-collection>
+ <web-resource-collection>
+ <web-resource-name>No Access</web-resource-name>
+ <url-pattern>/restricted/*</url-pattern>
+ <http-method>DELETE</http-method>
+ <http-method>PUT</http-method>
+ <http-method>HEAD</http-method>
+ <http-method>OPTIONS</http-method>
+ <http-method>TRACE</http-method>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint id="no-roles">
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-constraint id="SC2">
+ <display-name>unchecked</display-name>
+ <web-resource-collection>
+ <web-resource-name>All Access</web-resource-name>
+ <url-pattern>/unchecked/*</url-pattern>
+ <http-method>DELETE</http-method>
+ <http-method>PUT</http-method>
+ <http-method>HEAD</http-method>
+ <http-method>OPTIONS</http-method>
+ <http-method>TRACE</http-method>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-constraint id="SC3">
+ <display-name>Restricted GET</display-name>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Get Only</web-resource-name>
+ <url-pattern>/restricted/get-only/*</url-pattern>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>GetRole</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+ <security-constraint id="SC4">
+ <display-name>Excluded GET</display-name>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Get Only</web-resource-name>
+ <url-pattern>/restricted/get-only/*</url-pattern>
+ <http-method>DELETE</http-method>
+ <http-method>PUT</http-method>
+ <http-method>HEAD</http-method>
+ <http-method>OPTIONS</http-method>
+ <http-method>TRACE</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint />
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-constraint id="SC5">
+ <display-name>Restricted POST</display-name>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Post Only</web-resource-name>
+ <url-pattern>/restricted/post-only/*</url-pattern>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>PostRole</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+ <security-constraint id="SC6">
+ <display-name>Excluded POST</display-name>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Post Only</web-resource-name>
+ <url-pattern>/restricted/post-only/*</url-pattern>
+ <http-method>DELETE</http-method>
+ <http-method>PUT</http-method>
+ <http-method>HEAD</http-method>
+ <http-method>OPTIONS</http-method>
+ <http-method>TRACE</http-method>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint />
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-constraint id="SC7">
+ <display-name>Restricted ANY</display-name>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Any</web-resource-name>
+ <url-pattern>/restricted/any/*</url-pattern>
+ <http-method>DELETE</http-method>
+ <http-method>PUT</http-method>
+ <http-method>HEAD</http-method>
+ <http-method>OPTIONS</http-method>
+ <http-method>TRACE</http-method>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-constraint id="SC8">
+ <display-name>Unrestricted</display-name>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Any</web-resource-name>
+ <url-pattern>/restricted/not/*</url-pattern>
+ <http-method>DELETE</http-method>
+ <http-method>PUT</http-method>
+ <http-method>HEAD</http-method>
+ <http-method>OPTIONS</http-method>
+ <http-method>TRACE</http-method>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>GetRole</role-name>
+ </security-role>
+ <security-role>
+ <role-name>PostRole</role-name>
+ </security-role>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>WebConstraintsUnitTestCase</realm-name>
+ </login-config>
+</web-app>
Property changes on: projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/web/WebApp24_testSecurityConstraint.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list