Example #1
0
 /** Tests the {@link PlainSaslServer#getAuthorizationID()} to retrieve the correct user. */
 @Test
 public void userPasswordReceiveTest() throws Exception {
   String testUser = "******";
   String password = "******";
   mPlainSaslServer.evaluateResponse(getUserInfo(testUser, password));
   Assert.assertEquals(testUser, mPlainSaslServer.getAuthorizationID());
 }
Example #2
0
  /*
   * Tests the {@link PlainSaslServer#evaluateResponse(byte[])} method when AuthorizeCallback is
   * not authorized.
   */
  @Test
  public void unauthorizedCallbackTest() throws Exception {
    String testUser = "******";
    String password = "******";
    mPlainSaslServer = new PlainSaslServer(new MockCallbackHandlerUnauthorized());

    mThrown.expect(SaslException.class);
    mThrown.expectMessage("Plain authentication failed: AuthorizeCallback authorized failure");
    mPlainSaslServer.evaluateResponse(getUserInfo(testUser, password));
  }
Example #3
0
 /** Tests the {@link PlainSaslServer#getAuthorizationID()} method. */
 @Test
 public void authenticationNotCompleteTest() {
   mThrown.expect(IllegalStateException.class);
   mThrown.expectMessage("PLAIN authentication not completed");
   mPlainSaslServer.getAuthorizationID();
 }
Example #4
0
 /**
  * Tests the {@link PlainSaslServer#evaluateResponse(byte[])} method when the password is not set.
  */
 @Test
 public void passwordIsNotSetTest() throws Exception {
   mThrown.expect(SaslException.class);
   mThrown.expectMessage("Plain authentication failed: No password provided");
   mPlainSaslServer.evaluateResponse(getUserInfo("tachyon", ""));
 }
Example #5
0
 /**
  * Tests the {@link PlainSaslServer#evaluateResponse(byte[])} method when the user is not set.
  *
  * @throws Exception if the bytes for the user and password cannot be retrieved
  */
 @Test
 public void userIsNotSetTest() throws Exception {
   mThrown.expect(SaslException.class);
   mThrown.expectMessage("Plain authentication failed: No authentication identity provided");
   mPlainSaslServer.evaluateResponse(getUserInfo("", "anonymous"));
 }