Index: testsuite/src/main/org/jboss/test/security/test/authorization/HttpRequestJmxAuthenticationUnitTestCase.java =================================================================== --- testsuite/src/main/org/jboss/test/security/test/authorization/HttpRequestJmxAuthenticationUnitTestCase.java (revision 0) +++ testsuite/src/main/org/jboss/test/security/test/authorization/HttpRequestJmxAuthenticationUnitTestCase.java (revision 0) @@ -0,0 +1,110 @@ +package org.jboss.test.security.test.authorization; + +import java.net.*; + +import junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.jboss.test.JBossTestCase; +import org.jboss.test.JBossTestSetup; + +public class HttpRequestJmxAuthenticationUnitTestCase extends JBossTestCase { + + private URL u; + private HttpURLConnection con; + private static final String GET = "GET"; + private static final String POST = "POST"; + private static final String HEAD = "HEAD"; + private static final String OPTIONS = "OPTIONS"; + private static final String PUT = "PUT"; + private static final String DELETE = "DELETE"; + private static final String TRACE = "TRACE"; + private static final String TEST_JMX_CONSOLE = "jmx-console-secure"; + + public HttpRequestJmxAuthenticationUnitTestCase(String name){ + super(name); + } + + public static Test suite() throws Exception + { + TestSuite suite = new TestSuite(); + suite.addTest(new TestSuite(HttpRequestJmxAuthenticationUnitTestCase.class)); + // Create an initializer for the test suite + TestSetup wrapper = new JBossTestSetup(suite) + { + @Override + protected void setUp() throws Exception + { + super.setUp(); + deploy(TEST_JMX_CONSOLE+".war"); + } + + @Override + protected void tearDown() throws Exception + { + undeploy(TEST_JMX_CONSOLE+".war"); + super.tearDown(); + } + }; + return wrapper; + } + + public void testGet() throws Exception { + con.setRequestMethod(GET); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + public void testPost() throws Exception { + con.setRequestMethod(POST); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + public void testHead() throws Exception { + con.setRequestMethod(HEAD); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + public void testOptions() throws Exception { + con.setRequestMethod(OPTIONS); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + public void testPut() throws Exception { + con.setRequestMethod(PUT); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + public void testTrace() throws Exception { + con.setRequestMethod(TRACE); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + public void testDelete() throws Exception { + con.setRequestMethod(DELETE); + con.connect(); + assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode()); + } + + protected void setUp() throws Exception { + u = new URL("http://" + getServerHost() + ":8080/"+TEST_JMX_CONSOLE); + con = (HttpURLConnection) u.openConnection(); + try { + con.setDoInput(true); + con.setRequestProperty("Cookie","MODIFY ME IF NEEDED"); + } finally { + con.disconnect(); + } + } + + protected void tearDown(){ + if (con != null) + con.disconnect(); + } +} Index: testsuite/src/resources/security/jmx/jmx-console.war/WEB-INF/jboss-web.xml =================================================================== --- testsuite/src/resources/security/jmx/jmx-console.war/WEB-INF/jboss-web.xml (revision 0) +++ testsuite/src/resources/security/jmx/jmx-console.war/WEB-INF/jboss-web.xml (revision 0) @@ -0,0 +1,12 @@ + + + + + java:/jaas/jmx-console + jmx-console-secure + Index: testsuite/src/resources/security/jmx/jmx-console.war/WEB-INF/web.xml =================================================================== --- testsuite/src/resources/security/jmx/jmx-console.war/WEB-INF/web.xml (revision 0) +++ testsuite/src/resources/security/jmx/jmx-console.war/WEB-INF/web.xml (revision 0) @@ -0,0 +1,122 @@ + + + + The standard web descriptor for the html adaptor + + + HtmlAdaptor + org.jboss.jmx.adaptor.html.HtmlAdaptorServlet + + + ClusteredConsoleServlet + org.jboss.jmx.adaptor.html.ClusteredConsoleServlet + + The JGroups protocol stack config + jgProps + UDP(ip_mcast=true;ip_ttl=16;loopback=false;mcast_addr=${jboss.partition.udpGroup:228.1.2.3};mcast_port=${jboss.jmxconsolepartition.mcast_port:46666}): +org.jboss.jmx.adaptor.control.FindView + + + + + DisplayMBeans + /displayMBeans.jsp + + + InspectMBean + /inspectMBean.jsp + + + DisplayOpResult + /displayOpResult.jsp + + + ClusterView + /cluster/clusterView.jsp + + + ProfileServiceDebugServlet + org.jboss.profileservice.web.DebugServlet + + + + HtmlAdaptor + /HtmlAdaptor + + + ClusteredConsoleServlet + /cluster/ClusteredConsole + + + DisplayMBeans + /DisplayMBeans + + + InspectMBean + /InspectMBean + + + DisplayOpResult + /DisplayOpResult + + + ProfileServiceDebugServlet + /ProfileServiceDebugServlet + + + + + 500 + /genericError.jsp + + + + + + HtmlAdaptor + An example security config that only allows users with the + role JBossAdmin to access the HTML JMX console web application + + /* + + + JBossAdmin + + + + + BASIC + JBoss JMX Console + + + + JBossAdmin + + Index: testsuite/imports/sections/security.xml =================================================================== --- testsuite/imports/sections/security.xml (revision 102787) +++ testsuite/imports/sections/security.xml (working copy) @@ -358,6 +358,18 @@ + + + + + + + + + + +