summaryrefslogtreecommitdiff
path: root/qpid/java/systests
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2013-04-26 16:53:46 +0000
committerAlex Rudyy <orudyy@apache.org>2013-04-26 16:53:46 +0000
commit327d76b59565ece44018864787dfad695fcda50a (patch)
tree7ac922f114ef28a4418f97c73e72dbf241d719c9 /qpid/java/systests
parent64ab8be9c34528ef71ca5c58ff075ed57a48c9e0 (diff)
downloadqpid-python-327d76b59565ece44018864787dfad695fcda50a.tar.gz
QPID-4777: Add UI to view and edit web management configuration
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1476288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java3
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java3
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java5
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java69
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java3
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java60
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java3
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java3
8 files changed, 141 insertions, 8 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
index ae7c648197..861b246d54 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.security.access.FileAccessControlProviderConstants;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -56,7 +57,7 @@ public class AccessControlProviderRestTest extends QpidRestTestCase
getRestTestHelper().configureTemporaryPasswordFile(this, ALLOWED_USER, DENIED_USER, OTHER_USER);
getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT,
- "httpBasicAuthenticationEnabled", true);
+ HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
}
public void testCreateAccessControlProvider() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java
index 907b476bc4..05dee47893 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.Port;
@@ -39,7 +40,7 @@ public class AnonymousAccessRestTest extends QpidRestTestCase
// set anonymous authentication provider on http port for the tests
config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.AUTHENTICATION_PROVIDER,
TestBrokerConfiguration.ENTRY_NAME_ANONYMOUS_PROVIDER);
- config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", false);
+ config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, false);
// reset credentials
getRestTestHelper().setUsernameAndPassword(null, null);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java
index ea63cc7f4e..1df1796e73 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BasicAuthRestTest.java
@@ -30,6 +30,7 @@ import java.util.Collections;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -86,7 +87,7 @@ public class BasicAuthRestTest extends QpidRestTestCase
public void testBasicAuthWhenDisabledWithHttp() throws Exception
{
configure(false);
- getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", false);
+ getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, false);
super.setUp();
// Try the attempt with authentication, it should fail because
@@ -99,7 +100,7 @@ public class BasicAuthRestTest extends QpidRestTestCase
{
configure(false);
- getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+ getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
super.setUp();
// Try the attempt with authentication, it should succeed because
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
new file mode 100644
index 0000000000..3a0b834cc2
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/HttpManagementRestTest.java
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.qpid.systest.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.management.plugin.HttpManagement;
+import org.apache.qpid.test.utils.TestBrokerConfiguration;
+
+public class HttpManagementRestTest extends QpidRestTestCase
+{
+
+ public void testGetHttpManagement() throws Exception
+ {
+ Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+ "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+ assertEquals("Unexpected session timeout", HttpManagement.DEFAULT_TIMEOUT_IN_SECONDS,
+ details.get(HttpManagement.TIME_OUT));
+ assertEquals("Unexpected http basic auth enabled", true,
+ details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https basic auth enabled", HttpManagement.DEFAULT_HTTPS_BASIC_AUTHENTICATION_ENABLED,
+ details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected http sasl auth enabled", HttpManagement.DEFAULT_HTTP_SASL_AUTHENTICATION_ENABLED,
+ details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https sasl auth enabled", HttpManagement.DEFAULT_HTTPS_SASL_AUTHENTICATION_ENABLED,
+ details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+ }
+
+ public void testUpdateAttributes() throws Exception
+ {
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+ attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.TIME_OUT, 10000);
+
+ getRestTestHelper().submitRequest("/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
+
+ Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+ "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+ assertEquals("Unexpected session timeout", 10000, details.get(HttpManagement.TIME_OUT));
+ assertEquals("Unexpected http basic auth enabled", true, details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https basic auth enabled", false, details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected http sasl auth enabled", false, details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https sasl auth enabled", false, details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java
index e5aacbba4b..4a652f2997 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory;
@@ -98,7 +99,7 @@ public class QpidRestTestCase extends QpidBrokerTestCase
// set password authentication provider on http port for the tests
config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.AUTHENTICATION_PROVIDER,
TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
- config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+ config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
}
public RestTestHelper getRestTestHelper()
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
index 220d2bc574..acad55417a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
@@ -74,7 +75,7 @@ public class BrokerACLTest extends QpidRestTestCase
"ACL DENY-LOG ALL ALL";
getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT,
- "httpBasicAuthenticationEnabled", true);
+ HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
}
/* === AuthenticationProvider === */
@@ -877,6 +878,63 @@ public class BrokerACLTest extends QpidRestTestCase
assertEquals("Setting of access control provider attributes should be denied", 403, responseCode);
}
+ /* === HTTP management === */
+
+ public void testSetHttpManagementAttributesAllowed() throws Exception
+ {
+ getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+ attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.TIME_OUT, 10000);
+
+ int responseCode = getRestTestHelper().submitRequest(
+ "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
+ assertEquals("Setting of http management should be allowed", 200, responseCode);
+
+ Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+ "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+ assertEquals("Unexpected session timeout", 10000, details.get(HttpManagement.TIME_OUT));
+ assertEquals("Unexpected http basic auth enabled", true, details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https basic auth enabled", false, details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected http sasl auth enabled", false, details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https sasl auth enabled", false, details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+ }
+
+ public void testSetHttpManagementAttributesDenied() throws Exception
+ {
+ getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(HttpManagement.NAME, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+ attributes.put(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED, false);
+ attributes.put(HttpManagement.TIME_OUT, 10000);
+
+ int responseCode = getRestTestHelper().submitRequest(
+ "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "PUT", attributes);
+ assertEquals("Setting of http management should be denied", 403, responseCode);
+
+ Map<String, Object> details = getRestTestHelper().getJsonAsSingletonList(
+ "/rest/plugin/" + TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT);
+
+ assertEquals("Unexpected session timeout", HttpManagement.DEFAULT_TIMEOUT_IN_SECONDS,
+ details.get(HttpManagement.TIME_OUT));
+ assertEquals("Unexpected http basic auth enabled", true,
+ details.get(HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https basic auth enabled", HttpManagement.DEFAULT_HTTPS_BASIC_AUTHENTICATION_ENABLED,
+ details.get(HttpManagement.HTTPS_BASIC_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected http sasl auth enabled", HttpManagement.DEFAULT_HTTP_SASL_AUTHENTICATION_ENABLED,
+ details.get(HttpManagement.HTTP_SASL_AUTHENTICATION_ENABLED));
+ assertEquals("Unexpected https sasl auth enabled", HttpManagement.DEFAULT_HTTPS_SASL_AUTHENTICATION_ENABLED,
+ details.get(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED));
+ }
+
/* === Utility Methods === */
private int createPort(String portName) throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java
index 3fceb27a4b..9a578d01fb 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/GroupRestACLTest.java
@@ -29,6 +29,7 @@ import java.util.Properties;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.security.acl.AbstractACLTestCase;
import org.apache.qpid.systest.rest.QpidRestTestCase;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -60,7 +61,7 @@ public class GroupRestACLTest extends QpidRestTestCase
protected void customizeConfiguration() throws ConfigurationException, IOException
{
super.customizeConfiguration();
- getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+ getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
}
@Override
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java
index 3b81df6fd1..4c4e219695 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/UserRestACLTest.java
@@ -29,6 +29,7 @@ import java.util.Properties;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.plugin.HttpManagement;
import org.apache.qpid.server.security.acl.AbstractACLTestCase;
import org.apache.qpid.systest.rest.QpidRestTestCase;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -62,7 +63,7 @@ public class UserRestACLTest extends QpidRestTestCase
protected void customizeConfiguration() throws ConfigurationException, IOException
{
super.customizeConfiguration();
- getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, "httpBasicAuthenticationEnabled", true);
+ getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
}
@Override