1 22 package org.jboss.test.web.security.authorization; 23 24 import java.net.HttpURLConnection ; 25 import java.net.URL ; 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 37 43 public class XACMLWebIntegrationUnitTestCase extends JBossTestCase 44 { 45 public XACMLWebIntegrationUnitTestCase(String name) 46 { 47 super(name); 48 } 49 50 public static Test suite() throws Exception 51 { 52 TestSuite suite = new TestSuite(); 53 suite.addTest(new TestSuite(XACMLWebIntegrationUnitTestCase.class)); 54 TestSetup wrapper = new JBossTestSetup(suite) 56 { 57 protected void setUp() throws Exception 58 { 59 super.setUp(); 60 deploy("xacml-requestattrib.war"); 61 deploy("xacml-subjectrole.war"); 62 String url = getResourceURL("web/xacml/app-policy-service.xml"); 63 deploy(url); 64 } 65 protected void tearDown() throws Exception 66 { 67 String 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 78 { 79 URL url = new URL (HttpUtils.getBaseURL()+"xacml-requestattrib/test?status=employed"); 80 HttpUtils.accessURL(url, "JBoss XACML Test", HttpURLConnection.HTTP_OK); 81 url = new URL (HttpUtils.getBaseURL()+"xacml-requestattrib/test"); 82 HttpUtils.accessURL(url, "JBoss XACML Test", HttpURLConnection.HTTP_FORBIDDEN); 83 } 84 85 public void testSubjectRBAC() throws Throwable 86 { 87 URL url = new URL (HttpUtils.getBaseURL()+"xacml-subjectrole/test"); 88 HttpUtils.accessURL(url, "JBoss XACML Test", HttpURLConnection.HTTP_OK); 89 } 90 } 91 | Popular Tags |