You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/01/25 14:54:41 UTC

svn commit: r1726627 - /qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/

Author: kwall
Date: Mon Jan 25 13:54:40 2016
New Revision: 1726627

URL: http://svn.apache.org/viewvc?rev=1726627&view=rev
Log:
QPID-7015: [Java Broker Tests] Add system test that ensure ability to login correctly (messaging) with Scram-SHA based authentication providers

Added:
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManagerTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationManagerTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha1AuthenticationManagerTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha256AuthenticationManagerTest.java

Added: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManagerTest.java?rev=1726627&view=auto
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManagerTest.java (added)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManagerTest.java Mon Jan 25 13:54:40 2016
@@ -0,0 +1,102 @@
+/*
+ * 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.server.security.auth.manager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.JMSException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.User;
+import org.apache.qpid.systest.rest.RestTestHelper;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.test.utils.TestBrokerConfiguration;
+
+public abstract class AbstractAuthenticationManagerTest extends QpidBrokerTestCase
+{
+    @Override
+    protected void setUp() throws Exception
+    {
+        TestBrokerConfiguration config = getDefaultBrokerConfiguration();
+        config.addHttpManagementConfiguration();
+
+        Map<String, Object> authProviderAttrs = getAuthenticationProviderAttributes();
+        config.addObjectConfiguration(AuthenticationProvider.class, authProviderAttrs);
+
+        config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT,
+                                  Port.AUTHENTICATION_PROVIDER, getAuthenticationProviderName());
+
+        super.setUp();
+    }
+
+    protected abstract String getAuthenticationProviderName();
+
+    protected abstract Map<String, Object> getAuthenticationProviderAttributes();
+
+    public void testConnect_Success() throws Exception
+    {
+        createUser("myuser", "mypassword");
+        getConnection("myuser", "mypassword");
+    }
+
+    public void testConnect_WrongPassword() throws Exception
+    {
+        createUser("myuser", "mypassword");
+        try
+        {
+            getConnection("myuser", "badpassword");
+            fail("Exception not thrown");
+        }
+        catch(JMSException je)
+        {
+            // PASS
+        }
+    }
+
+    public void testConnect_UnknownUser() throws Exception
+    {
+        createUser("myuser", "mypassword");
+        try
+        {
+            getConnection("unknown", "mypassword");
+            fail("Exception not thrown");
+        }
+        catch(JMSException je)
+        {
+            // PASS
+        }
+    }
+
+    private void createUser(final String user, final String password) throws Exception
+    {
+        RestTestHelper restTestHelper = new RestTestHelper(getDefaultBroker().getHttpPort());
+
+        final Map<String, Object> userAttr = new HashMap<>();
+        userAttr.put(User.NAME, user);
+        userAttr.put(User.PASSWORD, password);
+
+        String url = "user/" + getAuthenticationProviderName();
+        restTestHelper.submitRequest(url, "POST", userAttr, HttpServletResponse.SC_CREATED);
+    }
+}

Added: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationManagerTest.java?rev=1726627&view=auto
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationManagerTest.java (added)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationManagerTest.java Mon Jan 25 13:54:40 2016
@@ -0,0 +1,45 @@
+/*
+ * 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.server.security.auth.manager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.model.AuthenticationProvider;
+
+public class MD5AuthenticationManagerTest extends AbstractAuthenticationManagerTest
+{
+    @Override
+    protected String getAuthenticationProviderName()
+    {
+        return "mymd5";
+    }
+
+    @Override
+    protected Map<String, Object> getAuthenticationProviderAttributes()
+    {
+        Map<String, Object> authProviderAttrs = new HashMap<>();
+        authProviderAttrs.put(AuthenticationProvider.TYPE, "MD5");
+        authProviderAttrs.put(AuthenticationProvider.NAME, getAuthenticationProviderName());
+        return authProviderAttrs;
+    }
+
+}

Added: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha1AuthenticationManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha1AuthenticationManagerTest.java?rev=1726627&view=auto
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha1AuthenticationManagerTest.java (added)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha1AuthenticationManagerTest.java Mon Jan 25 13:54:40 2016
@@ -0,0 +1,44 @@
+/*
+ * 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.server.security.auth.manager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.model.AuthenticationProvider;
+
+public class ScramSha1AuthenticationManagerTest extends AbstractAuthenticationManagerTest
+{
+    @Override
+    protected String getAuthenticationProviderName()
+    {
+        return "myscram1";
+    }
+
+    @Override
+    protected Map<String, Object> getAuthenticationProviderAttributes()
+    {
+        Map<String, Object> authProviderAttrs = new HashMap<>();
+        authProviderAttrs.put(AuthenticationProvider.TYPE, ScramSHA1AuthenticationManager.PROVIDER_TYPE);
+        authProviderAttrs.put(AuthenticationProvider.NAME, getAuthenticationProviderName());
+        return authProviderAttrs;
+    }
+
+}

Added: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha256AuthenticationManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha256AuthenticationManagerTest.java?rev=1726627&view=auto
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha256AuthenticationManagerTest.java (added)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSha256AuthenticationManagerTest.java Mon Jan 25 13:54:40 2016
@@ -0,0 +1,45 @@
+/*
+ * 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.server.security.auth.manager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.server.model.AuthenticationProvider;
+
+public class ScramSha256AuthenticationManagerTest extends AbstractAuthenticationManagerTest
+{
+    @Override
+    protected String getAuthenticationProviderName()
+    {
+        return "myscram256";
+    }
+
+    @Override
+    protected Map<String, Object> getAuthenticationProviderAttributes()
+    {
+        Map<String, Object> authProviderAttrs = new HashMap<>();
+        authProviderAttrs.put(AuthenticationProvider.TYPE, ScramSHA256AuthenticationManager.PROVIDER_TYPE);
+        authProviderAttrs.put(AuthenticationProvider.NAME, getAuthenticationProviderName());
+        return authProviderAttrs;
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org