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 2018/01/17 12:07:01 UTC

[1/4] qpid-broker-j git commit: QPID-8046: [Broker-J] Allow SASL mechanisms PLAIN and XOAUTH2 to not require initial response

Repository: qpid-broker-j
Updated Branches:
  refs/heads/7.0.x 66faf8edd -> 0dd791195


QPID-8046: [Broker-J] Allow SASL mechanisms PLAIN and XOAUTH2 to not require initial response

Cherry picked from 4eb2ea6


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/de509dd9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/de509dd9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/de509dd9

Branch: refs/heads/7.0.x
Commit: de509dd955229a395c086a7cca874dc55306648a
Parents: 66faf8e
Author: Alex Rudyy <or...@apache.org>
Authored: Tue Nov 21 15:00:50 2017 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Wed Jan 17 12:06:21 2018 +0000

----------------------------------------------------------------------
 .../auth/sasl/oauth2/OAuth2Negotiator.java      | 26 +++++++++++++-----
 .../auth/sasl/plain/PlainNegotiator.java        | 28 +++++++++++++++-----
 .../auth/sasl/oauth2/OAuth2NegotiatorTest.java  | 15 ++++++++++-
 .../auth/sasl/plain/PlainNegotiatorTest.java    | 21 +++++++++++++++
 4 files changed, 77 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/de509dd9/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2Negotiator.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2Negotiator.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2Negotiator.java
index 955136c..db2f262 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2Negotiator.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2Negotiator.java
@@ -31,12 +31,18 @@ import org.apache.qpid.server.security.auth.sasl.SaslNegotiator;
 
 public class OAuth2Negotiator implements SaslNegotiator
 {
+    enum State
+    {
+        INITIAL,
+        CHALLENGE_SENT,
+        COMPLETE
+    }
 
     public static final String MECHANISM = "XOAUTH2";
     private static final String BEARER_PREFIX = "Bearer ";
     private final NamedAddressSpace _addressSpace;
     private OAuth2AuthenticationProvider<?> _authenticationProvider;
-    private volatile boolean _isComplete;
+    private volatile State _state = State.INITIAL;
 
     public OAuth2Negotiator(OAuth2AuthenticationProvider<?> authenticationProvider,
                             final NamedAddressSpace addressSpace)
@@ -48,16 +54,24 @@ public class OAuth2Negotiator implements SaslNegotiator
     @Override
     public AuthenticationResult handleResponse(final byte[] response)
     {
-        if (_isComplete)
+        if (_state == State.COMPLETE)
         {
             return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,
-                                            new IllegalStateException(
-                                                    "Multiple Authentications not permitted."));
+                                            new IllegalStateException("Multiple Authentications not permitted."));
         }
-        else
+        else if (_state == State.INITIAL && (response == null || response.length == 0))
+        {
+            _state = State.CHALLENGE_SENT;
+            return new AuthenticationResult(new byte[0], AuthenticationResult.AuthenticationStatus.CONTINUE);
+        }
+
+        _state = State.COMPLETE;
+        if (response == null || response.length == 0)
         {
-            _isComplete = true;
+            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,
+                                            new IllegalArgumentException("Invalid OAuth2 client response."));
         }
+
         Map<String, String> responsePairs = splitResponse(response);
 
         String auth = responsePairs.get("auth");

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/de509dd9/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
index 065080f..e56f8ca 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
@@ -29,11 +29,18 @@ import org.apache.qpid.server.security.auth.sasl.SaslNegotiator;
 
 public class PlainNegotiator implements SaslNegotiator
 {
+    enum State
+    {
+        INITIAL,
+        CHALLENGE_SENT,
+        COMPLETE
+    }
+
     public static final String MECHANISM = "PLAIN";
     private static final String UTF8 = StandardCharsets.UTF_8.name();
 
     private UsernamePasswordAuthenticationProvider _usernamePasswordAuthenticationProvider;
-    private volatile boolean _isComplete;
+    private volatile State _state = State.INITIAL;
     private volatile String _username;
 
     public PlainNegotiator(final UsernamePasswordAuthenticationProvider usernamePasswordAuthenticationProvider)
@@ -44,16 +51,25 @@ public class PlainNegotiator implements SaslNegotiator
     @Override
     public AuthenticationResult handleResponse(final byte[] response)
     {
-        if (_isComplete)
+        if (_state == State.COMPLETE)
         {
             return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,
-                                            new IllegalStateException(
-                                                    "Multiple Authentications not permitted."));
+                                            new IllegalStateException("Multiple Authentications not permitted."));
+        }
+        else if (_state == State.INITIAL && (response == null || response.length == 0))
+        {
+            _state = State.CHALLENGE_SENT;
+            return new AuthenticationResult(new byte[0], AuthenticationResult.AuthenticationStatus.CONTINUE);
         }
-        else
+
+        _state = State.COMPLETE;
+        if (response == null || response.length == 0)
         {
-            _isComplete = true;
+            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,
+                                            new IllegalArgumentException(
+                                                    "Invalid PLAIN encoding, authzid null terminator not found"));
         }
+
         int authzidNullPosition = findNullPosition(response, 0);
         if (authzidNullPosition < 0)
         {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/de509dd9/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2NegotiatorTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2NegotiatorTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2NegotiatorTest.java
index 4dea6c4..d1e1d2a 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2NegotiatorTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/oauth2/OAuth2NegotiatorTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.security.auth.sasl.oauth2;
 
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
@@ -29,7 +30,6 @@ import static org.mockito.Mockito.when;
 
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.manager.oauth2.OAuth2AuthenticationProvider;
-
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class OAuth2NegotiatorTest extends QpidTestCase
@@ -94,4 +94,17 @@ public class OAuth2NegotiatorTest extends QpidTestCase
                      secondResult.getStatus());
     }
 
+    public void testHandleNoInitialResponse() throws Exception
+    {
+        final AuthenticationResult result = _negotiator.handleResponse(new byte[0]);
+        assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, result.getStatus());
+        assertArrayEquals("Unexpected authentication challenge", new byte[0], result.getChallenge());
+    }
+
+    public void testHandleNoInitialResponseNull() throws Exception
+    {
+        final AuthenticationResult result = _negotiator.handleResponse(null);
+        assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, result.getStatus());
+        assertArrayEquals("Unexpected authentication challenge", new byte[0], result.getChallenge());
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/de509dd9/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
index 78229b6..5162073 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
@@ -20,6 +20,7 @@
 
 package org.apache.qpid.server.security.auth.sasl.plain;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -72,4 +73,24 @@ public class PlainNegotiatorTest extends QpidTestCase
         final AuthenticationResult secondResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
         assertEquals("Unexpected second authentication result", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
     }
+
+    public void testHandleNoInitialResponse() throws Exception
+    {
+        final AuthenticationResult result = _negotiator.handleResponse(new byte[0]);
+        assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, result.getStatus());
+        assertArrayEquals("Unexpected authentication challenge", new byte[0], result.getChallenge());
+
+        final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
+        assertEquals("Unexpected first authentication result", _expectedResult, firstResult);
+    }
+
+    public void testHandleNoInitialResponseNull() throws Exception
+    {
+        final AuthenticationResult result = _negotiator.handleResponse(null);
+        assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, result.getStatus());
+        assertArrayEquals("Unexpected authentication challenge", new byte[0], result.getChallenge());
+
+        final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
+        assertEquals("Unexpected first authentication result", _expectedResult, firstResult);
+    }
 }
\ No newline at end of file


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


[3/4] qpid-broker-j git commit: QPID-8046: [Broker-J] [PlainNegotiator] Eliminate redundant UTF-8/UnsupportedEncodingException catch block

Posted by kw...@apache.org.
QPID-8046: [Broker-J] [PlainNegotiator] Eliminate redundant UTF-8/UnsupportedEncodingException catch block

Cherry picked from fcca9d2


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/4b9fb37a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/4b9fb37a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/4b9fb37a

Branch: refs/heads/7.0.x
Commit: 4b9fb37abbe882193b16595ed7b8e9d8383f59e1
Parents: 30ca170
Author: Keith Wall <kw...@apache.org>
Authored: Wed Jan 17 11:29:35 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Wed Jan 17 12:06:52 2018 +0000

----------------------------------------------------------------------
 .../auth/sasl/plain/PlainNegotiator.java         | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4b9fb37a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
index e56f8ca..d5fe74e 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiator.java
@@ -20,7 +20,7 @@
 
 package org.apache.qpid.server.security.auth.sasl.plain;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.qpid.server.security.auth.AuthenticationResult;
@@ -37,7 +37,7 @@ public class PlainNegotiator implements SaslNegotiator
     }
 
     public static final String MECHANISM = "PLAIN";
-    private static final String UTF8 = StandardCharsets.UTF_8.name();
+    private static final Charset UTF8 = StandardCharsets.UTF_8;
 
     private UsernamePasswordAuthenticationProvider _usernamePasswordAuthenticationProvider;
     private volatile State _state = State.INITIAL;
@@ -86,17 +86,10 @@ public class PlainNegotiator implements SaslNegotiator
         }
 
         String password;
-        try
-        {
-            _username = new String(response, authzidNullPosition + 1, authcidNullPosition - authzidNullPosition - 1, UTF8);
-            // TODO: should not get pwd as a String but as a char array...
-            int passwordLen = response.length - authcidNullPosition - 1;
-            password = new String(response, authcidNullPosition + 1, passwordLen, UTF8);
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            throw new RuntimeException("JVM does not support UTF8", e);
-        }
+        _username = new String(response, authzidNullPosition + 1, authcidNullPosition - authzidNullPosition - 1, UTF8);
+        // TODO: should not get pwd as a String but as a char array...
+        int passwordLen = response.length - authcidNullPosition - 1;
+        password = new String(response, authcidNullPosition + 1, passwordLen, UTF8);
         return _usernamePasswordAuthenticationProvider.authenticate(_username, password);
     }
 


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


[4/4] qpid-broker-j git commit: NO-JIRA: update year in web management console

Posted by kw...@apache.org.
NO-JIRA: update year in web management console


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/0dd79119
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/0dd79119
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/0dd79119

Branch: refs/heads/7.0.x
Commit: 0dd791195161d8b047643320666d7bf797e56825
Parents: 4b9fb37
Author: Keith Wall <kw...@apache.org>
Authored: Wed Jan 17 11:56:25 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Wed Jan 17 12:06:52 2018 +0000

----------------------------------------------------------------------
 broker-plugins/management-http/src/main/java/resources/footer.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0dd79119/broker-plugins/management-http/src/main/java/resources/footer.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/footer.html b/broker-plugins/management-http/src/main/java/resources/footer.html
index a7a6206..972e86f 100644
--- a/broker-plugins/management-http/src/main/java/resources/footer.html
+++ b/broker-plugins/management-http/src/main/java/resources/footer.html
@@ -19,7 +19,7 @@
  -
  -->
 
-<div class="footer"><p>&#xA9; 2004-<span class="currentYear">2017</span> The Apache Software Foundation.
+<div class="footer"><p>&#xA9; 2004-<span class="currentYear">2018</span> The Apache Software Foundation.
   <br/>
   Apache Qpid, Qpid, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of
   The Apache Software Foundation.


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


[2/4] qpid-broker-j git commit: QPID-8046: [Broker-J] Add more tests

Posted by kw...@apache.org.
QPID-8046: [Broker-J] Add more tests

Cherry picked from ca088c2


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/30ca170c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/30ca170c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/30ca170c

Branch: refs/heads/7.0.x
Commit: 30ca170c42c400b41340a81c6a69d33aa19bf189
Parents: de509dd
Author: Alex Rudyy <or...@apache.org>
Authored: Wed Nov 22 15:43:07 2017 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Wed Jan 17 12:06:45 2018 +0000

----------------------------------------------------------------------
 .../auth/sasl/plain/PlainNegotiatorTest.java    | 52 +++++++++++++++-----
 1 file changed, 41 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/30ca170c/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
index 5162073..ba53e60 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/auth/sasl/plain/PlainNegotiatorTest.java
@@ -20,7 +20,10 @@
 
 package org.apache.qpid.server.security.auth.sasl.plain;
 
+import static java.nio.charset.StandardCharsets.US_ASCII;
 import static org.junit.Assert.assertArrayEquals;
+import static org.mockito.AdditionalMatchers.not;
+import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -34,18 +37,23 @@ public class PlainNegotiatorTest extends QpidTestCase
 {
     private static final String VALID_PASSWORD = "testPassword";
     private static final String VALID_USERNAME = "testUsername";
-    private static final String VALID_RESPONSE = String.format("\0%s\0%s", VALID_USERNAME, VALID_PASSWORD);
+    public static final String RESPONSE_FORMAT_STRING = "\0%s\0%s";
+    private static final String VALID_RESPONSE = String.format(RESPONSE_FORMAT_STRING, VALID_USERNAME, VALID_PASSWORD);
     private UsernamePasswordAuthenticationProvider _authenticationProvider;
     private PlainNegotiator _negotiator;
-    private AuthenticationResult _expectedResult;
+    private AuthenticationResult _successfulResult;
+    private AuthenticationResult _errorResult;
 
     @Override
     public void setUp() throws Exception
     {
         super.setUp();
-        _expectedResult = mock(AuthenticationResult.class);
+        _successfulResult = mock(AuthenticationResult.class);
+        _errorResult = mock(AuthenticationResult.class);
         _authenticationProvider = mock(UsernamePasswordAuthenticationProvider.class);
-        when(_authenticationProvider.authenticate(eq(VALID_USERNAME), eq(VALID_PASSWORD))).thenReturn(_expectedResult);
+        when(_authenticationProvider.authenticate(eq(VALID_USERNAME), eq(VALID_PASSWORD))).thenReturn(_successfulResult);
+        when(_authenticationProvider.authenticate(eq(VALID_USERNAME), not(eq(VALID_PASSWORD)))).thenReturn(_errorResult);
+        when(_authenticationProvider.authenticate(not(eq(VALID_USERNAME)), anyString())).thenReturn(_errorResult);
         _negotiator = new PlainNegotiator(_authenticationProvider);
     }
 
@@ -61,19 +69,41 @@ public class PlainNegotiatorTest extends QpidTestCase
 
     public void testHandleResponse() throws Exception
     {
-        final AuthenticationResult result = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
+        final AuthenticationResult result = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
         verify(_authenticationProvider).authenticate(eq(VALID_USERNAME), eq(VALID_PASSWORD));
-        assertEquals("Unexpected authentication result", _expectedResult, result);
+        assertEquals("Unexpected authentication result", _successfulResult, result);
     }
 
     public void testMultipleAuthenticationAttempts() throws Exception
     {
-        final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
-        assertEquals("Unexpected first authentication result", _expectedResult, firstResult);
-        final AuthenticationResult secondResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
+        final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
+        assertEquals("Unexpected first authentication result", _successfulResult, firstResult);
+        final AuthenticationResult secondResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes(US_ASCII));
         assertEquals("Unexpected second authentication result", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
     }
 
+    public void testHandleInvalidUser() throws Exception
+    {
+        final AuthenticationResult result = _negotiator.handleResponse(String.format(RESPONSE_FORMAT_STRING, "invalidUser", VALID_PASSWORD).getBytes(US_ASCII));
+        assertEquals("Unexpected authentication result", _errorResult, result);
+    }
+
+    public void testHandleInvalidPassword() throws Exception
+    {
+        final AuthenticationResult result = _negotiator.handleResponse(String.format(RESPONSE_FORMAT_STRING, VALID_USERNAME, "invalidPassword").getBytes(US_ASCII));
+        assertEquals("Unexpected authentication result", _errorResult, result);
+    }
+
+    public void testHandleNeverSendAResponse() throws Exception
+    {
+        final AuthenticationResult firstResult = _negotiator.handleResponse(new byte[0]);
+        assertEquals("Unexpected authentication status", AuthenticationResult.AuthenticationStatus.CONTINUE, firstResult.getStatus());
+        assertArrayEquals("Unexpected authentication challenge", new byte[0], firstResult.getChallenge());
+
+        final AuthenticationResult secondResult = _negotiator.handleResponse(new byte[0]);
+        assertEquals("Unexpected first authentication result", AuthenticationResult.AuthenticationStatus.ERROR, secondResult.getStatus());
+    }
+
     public void testHandleNoInitialResponse() throws Exception
     {
         final AuthenticationResult result = _negotiator.handleResponse(new byte[0]);
@@ -81,7 +111,7 @@ public class PlainNegotiatorTest extends QpidTestCase
         assertArrayEquals("Unexpected authentication challenge", new byte[0], result.getChallenge());
 
         final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
-        assertEquals("Unexpected first authentication result", _expectedResult, firstResult);
+        assertEquals("Unexpected first authentication result", _successfulResult, firstResult);
     }
 
     public void testHandleNoInitialResponseNull() throws Exception
@@ -91,6 +121,6 @@ public class PlainNegotiatorTest extends QpidTestCase
         assertArrayEquals("Unexpected authentication challenge", new byte[0], result.getChallenge());
 
         final AuthenticationResult firstResult = _negotiator.handleResponse(VALID_RESPONSE.getBytes());
-        assertEquals("Unexpected first authentication result", _expectedResult, firstResult);
+        assertEquals("Unexpected first authentication result", _successfulResult, firstResult);
     }
 }
\ No newline at end of file


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