[ 
https://issues.apache.org/jira/browse/ARTEMIS-3106?focusedWorklogId=571889&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-571889
 ]

ASF GitHub Bot logged work on ARTEMIS-3106:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Mar/21 13:45
            Start Date: 25/Mar/21 13:45
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on a change in pull request #3470:
URL: https://github.com/apache/activemq-artemis/pull/3470#discussion_r601498584



##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/sasl/SCRAMTest.java
##########
@@ -0,0 +1,192 @@
+/*
+ * 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.activemq.artemis.protocol.amqp.sasl;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.crypto.Mac;
+import javax.security.auth.login.LoginException;
+
+import org.apache.activemq.artemis.protocol.amqp.sasl.scram.SCRAMClientSASL;
+import org.apache.activemq.artemis.protocol.amqp.sasl.scram.SCRAMServerSASL;
+import 
org.apache.activemq.artemis.protocol.amqp.sasl.scram.ScramServerFunctionalityImpl;
+import org.apache.activemq.artemis.spi.core.security.scram.SCRAM;
+import org.apache.activemq.artemis.spi.core.security.scram.ScramException;
+import org.apache.activemq.artemis.spi.core.security.scram.ScramUtils;
+import org.apache.activemq.artemis.spi.core.security.scram.UserData;
+import org.apache.qpid.proton.codec.DecodeException;
+import org.hamcrest.core.IsInstanceOf;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * test cases for the SASL-SCRAM
+ */
+@RunWith(Parameterized.class)
+public class SCRAMTest {
+
+   /**
+    *
+    */
+   private final SCRAM mechanism;
+   private static final byte[] SALT = new byte[32];
+   private static final String SNONCE = "server";
+   private static final String CNONCE = "client";
+   private static final String USERNAME = "test";
+   private static final String PASSWORD = "123";
+
+   @Parameters(name = "{0}")
+   public static List<Object[]> data() {
+      List<Object[]> list = new ArrayList<>();
+      for (SCRAM scram : SCRAM.values()) {
+         list.add(new Object[] {scram});
+      }
+      return list;
+   }
+
+   public SCRAMTest(SCRAM mechanism) {
+      this.mechanism = mechanism;
+   }
+
+   @Test
+   public void testSuccess() throws NoSuchAlgorithmException {
+      TestSCRAMServerSASL serverSASL = new TestSCRAMServerSASL(mechanism, 
USERNAME, PASSWORD);
+      TestSCRAMClientSASL clientSASL = new TestSCRAMClientSASL(mechanism, 
USERNAME, PASSWORD);

Review comment:
       So this type of test indeed will rarely give a different result than the 
integration test, since its using mostly the same code doing the same thing, I 
can see why you would wonder about having both with this test in particular. 
   
   Wiring them in a circle like this doesnt really verify the behaviour is 
truly as expected, so much as that neither side blew up. I'd expect each side 
to be tested in isolation with some actual verification of its generated output.
   
   E.g for the client side, 
https://github.com/apache/qpid-jms/tree/main/qpid-jms-client/src/test/java/org/apache/qpid/jms/sasl
 contains example of the kind of client handling tests I would expect. At least 
for the SHA1 and 256 cases for example, it uses the example straight from the 
RFC to check the actual behaviour based on known input.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 571889)
    Time Spent: 16h 10m  (was: 16h)

> Support for SASL-SCRAM
> ----------------------
>
>                 Key: ARTEMIS-3106
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3106
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>          Components: AMQP
>            Reporter: Christoph Läubrich
>            Priority: Major
>          Time Spent: 16h 10m
>  Remaining Estimate: 0h
>
> With the enhancements in ARTEMIS-33 / [PR 
> 3432|https://github.com/apache/activemq-artemis/pull/3432] it would be now 
> possible to plug-in new SASL mechanism.
> One popular one is 
> [SASL-SCRAM|https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism]
>  because it allows channelbinding together with secure storage of 
> user-credential.
> I have created an [implementation of this for Artemis 
> AMQP|https://github.com/laeubi/scram-sasl/tree/artemis/artemis] based on the 
> [SCRAM SASL authentication for Java|https://github.com/ogrebgr/scram-sasl] 
> code with some enhancements/cleanups to the original.
> As the source is already Apache licensed I'd like to propose to include this 
> in the Artemis code-base. This would greatly enhance the interoperability 
> with other implementations e.g. Apache QPID. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to