KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > web > security > authorization > XACMLWebIntegrationUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.web.security.authorization;
23
24 import java.net.HttpURLConnection JavaDoc;
25 import java.net.URL JavaDoc;
26
27 import junit.extensions.TestSetup;
28 import junit.framework.Test;
29 import junit.framework.TestSuite;
30
31 import org.jboss.test.JBossTestCase;
32 import org.jboss.test.JBossTestSetup;
33 import org.jboss.test.util.web.HttpUtils;
34
35 //$Id: XACMLWebIntegrationUnitTestCase.java 45948 2006-06-28 02:30:30Z asaldhana $
36

37 /**
38  * Test the XACML Integration in the Web layer
39  * @author <a HREF="mailto:Anil.Saldhana@jboss.org">Anil Saldhana</a>
40  * @since Jun 20, 2006
41  * @version $Revision: 45948 $
42  */

43 public class XACMLWebIntegrationUnitTestCase extends JBossTestCase
44 {
45    public XACMLWebIntegrationUnitTestCase(String JavaDoc name)
46    {
47       super(name);
48    }
49    
50    public static Test suite() throws Exception JavaDoc
51    {
52       TestSuite suite = new TestSuite();
53       suite.addTest(new TestSuite(XACMLWebIntegrationUnitTestCase.class));
54       // Create an initializer for the test suite
55
TestSetup wrapper = new JBossTestSetup(suite)
56       {
57          protected void setUp() throws Exception JavaDoc
58          {
59             super.setUp();
60             deploy("xacml-requestattrib.war");
61             deploy("xacml-subjectrole.war");
62             String JavaDoc url = getResourceURL("web/xacml/app-policy-service.xml");
63             deploy(url);
64          }
65          protected void tearDown() throws Exception JavaDoc
66          {
67             String JavaDoc url = getResourceURL("web/xacml/app-policy-service.xml");
68             undeploy(url);
69             undeploy("xacml-requestattrib.war");
70             undeploy("xacml-subjectrole.war");
71             super.tearDown();
72          }
73       };
74       return wrapper;
75    }
76    
77    public void testRequestAttributePresence() throws Throwable JavaDoc
78    {
79       URL JavaDoc url = new URL JavaDoc(HttpUtils.getBaseURL()+"xacml-requestattrib/test?status=employed");
80       HttpUtils.accessURL(url, "JBoss XACML Test", HttpURLConnection.HTTP_OK);
81       url = new URL JavaDoc(HttpUtils.getBaseURL()+"xacml-requestattrib/test");
82       HttpUtils.accessURL(url, "JBoss XACML Test", HttpURLConnection.HTTP_FORBIDDEN);
83    }
84    
85    public void testSubjectRBAC() throws Throwable JavaDoc
86    {
87       URL JavaDoc url = new URL JavaDoc(HttpUtils.getBaseURL()+"xacml-subjectrole/test");
88       HttpUtils.accessURL(url, "JBoss XACML Test", HttpURLConnection.HTTP_OK);
89    }
90 }
91
Popular Tags