summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database')
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java7
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java58
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java3
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java6
4 files changed, 30 insertions, 44 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java
index 2ab15d4872..33740af1e7 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java
@@ -21,13 +21,12 @@
package org.apache.qpid.server.security.auth.database;
import junit.framework.TestCase;
-
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.login.AccountNotFoundException;
-
import org.apache.commons.codec.binary.Base64;
+
import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.login.AccountNotFoundException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java
index aa85cac758..abb0b15a76 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java
@@ -21,8 +21,6 @@
package org.apache.qpid.server.security.auth.database;
import junit.framework.TestCase;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
import java.io.UnsupportedEncodingException;
@@ -32,9 +30,9 @@ import java.io.UnsupportedEncodingException;
public class HashedUserTest extends TestCase
{
- String USERNAME = "username";
- String PASSWORD = "password";
- String B64_ENCODED_PASSWORD = "cGFzc3dvcmQ=";
+ private String USERNAME = "username";
+ private String PASSWORD = "password";
+ private String B64_ENCODED_PASSWORD = "cGFzc3dvcmQ=";
public void testToLongArrayConstructor()
{
@@ -47,49 +45,39 @@ public class HashedUserTest extends TestCase
{
assertEquals("User Data should be length 2, username, password", e.getMessage());
}
- catch (UnsupportedEncodingException e)
- {
- fail(e.getMessage());
- }
+
}
public void testArrayConstructor()
{
- try
- {
- HashedUser user = new HashedUser(new String[]{USERNAME, B64_ENCODED_PASSWORD});
- assertEquals("Username incorrect", USERNAME, user.getName());
- int index = 0;
-
- char[] hash = B64_ENCODED_PASSWORD.toCharArray();
-
- try
- {
- for (byte c : user.getEncodedPassword())
- {
- assertEquals("Password incorrect", hash[index], (char) c);
- index++;
- }
- }
- catch (Exception e)
- {
- fail(e.getMessage());
- }
+ HashedUser user = new HashedUser(new String[]{USERNAME, B64_ENCODED_PASSWORD});
+ assertEquals("Username incorrect", USERNAME, user.getName());
+ int index = 0;
- hash = PASSWORD.toCharArray();
+ char[] hash = B64_ENCODED_PASSWORD.toCharArray();
- index=0;
- for (char c : user.getPassword())
+ try
+ {
+ for (byte c : user.getEncodedPassword())
{
- assertEquals("Password incorrect", hash[index], c);
+ assertEquals("Password incorrect", hash[index], (char) c);
index++;
}
-
}
- catch (UnsupportedEncodingException e)
+ catch (Exception e)
{
fail(e.getMessage());
}
+
+ hash = PASSWORD.toCharArray();
+
+ index=0;
+ for (char c : user.getPassword())
+ {
+ assertEquals("Password incorrect", hash[index], c);
+ index++;
+ }
+
}
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java
index a3dad19bb4..b8601f0e5c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java
@@ -22,10 +22,9 @@ package org.apache.qpid.server.security.auth.database;
import junit.framework.TestCase;
-import javax.security.auth.login.AccountNotFoundException;
-
import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+import javax.security.auth.login.AccountNotFoundException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java
index 7f0843d46e..44faa57dbe 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java
@@ -28,8 +28,8 @@ import junit.framework.TestCase;
public class PlainUserTest extends TestCase
{
- String USERNAME = "username";
- String PASSWORD = "password";
+ private String USERNAME = "username";
+ private String PASSWORD = "password";
public void testTooLongArrayConstructor()
{
@@ -54,7 +54,7 @@ public class PlainUserTest extends TestCase
try
{
- for (byte c : user.getPasswordBytes())
+ for (byte c : user.getEncodedPassword())
{
assertEquals("Password incorrect", password[index], (char) c);
index++;