From 760f1bbd522e928a3810ed07d708dfc197535c28 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Wed, 17 Dec 2008 10:24:54 +0000 Subject: QPID-1536 : Reverted r727057 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@727336 13f79535-47bb-0310-9956-ffa450edef68 --- .../auth/database/Base64HashedUserTest.java | 93 --------------------- ...Base64MD5PasswordFilePrincipalDatabaseTest.java | 5 +- .../security/auth/database/HashedUserTest.java | 95 ++++++++++++++++++++++ 3 files changed, 97 insertions(+), 96 deletions(-) delete mode 100644 java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64HashedUserTest.java create mode 100644 java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java (limited to 'java/broker/src/test') diff --git a/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64HashedUserTest.java b/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64HashedUserTest.java deleted file mode 100644 index 4c69edcac7..0000000000 --- a/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64HashedUserTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * 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.database; - -import junit.framework.TestCase; - -import java.io.UnsupportedEncodingException; - -/* - Note User is mainly tested by Base64MD5PFPDTest this is just to catch the extra methods - */ -public class Base64HashedUserTest extends TestCase -{ - - String USERNAME = "username"; - String PASSWORD = "password"; - String HASHED_PASSWORD = "cGFzc3dvcmQ="; - - public void testToLongArrayConstructor() - { - try - { - Base64HashedUser user = new Base64HashedUser(new String[]{USERNAME, PASSWORD, USERNAME}); - fail("Error expected"); - } - catch (IllegalArgumentException e) - { - assertEquals("User Data should be length 2, username, password", e.getMessage()); - } - catch (UnsupportedEncodingException e) - { - fail(e.getMessage()); - } - } - - public void testArrayConstructor() - { - try - { - Base64HashedUser user = new Base64HashedUser(new String[]{USERNAME, HASHED_PASSWORD}); - assertEquals("Username incorrect", USERNAME, user.getName()); - int index = 0; - - char[] hash = HASHED_PASSWORD.toCharArray(); - - try - { - for (byte c : user.getEncodedPassword()) - { - assertEquals("Password incorrect", hash[index], (char) c); - index++; - } - } - catch (Exception e) - { - fail(e.getMessage()); - } - - hash = PASSWORD.toCharArray(); - - index=0; - for (char c : user.getPassword()) - { - assertEquals("Password incorrect", hash[index], c); - index++; - } - - } - catch (UnsupportedEncodingException e) - { - fail(e.getMessage()); - } - } -} - diff --git a/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java b/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java index 6af042dee6..b5034d9f5d 100644 --- a/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java +++ b/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java @@ -228,9 +228,8 @@ public class Base64MD5PasswordFilePrincipalDatabaseTest extends TestCase assertNotNull(testUser); - String NEW_PASSWORD = "guest"; - - String NEW_PASSWORD_HASH = "CE4DQ6BIb/BVMN9scFyLtA=="; + String NEW_PASSWORD = "NewPassword"; + String NEW_PASSWORD_HASH = "TmV3UGFzc3dvcmQ="; try { _database.updatePassword(testUser, NEW_PASSWORD.toCharArray()); diff --git a/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java b/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java new file mode 100644 index 0000000000..a7d951cb5b --- /dev/null +++ b/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java @@ -0,0 +1,95 @@ +/* + * + * 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.database; + +import junit.framework.TestCase; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +import java.io.UnsupportedEncodingException; + +/* + Note User is mainly tested by Base64MD5PFPDTest this is just to catch the extra methods + */ +public class HashedUserTest extends TestCase +{ + + String USERNAME = "username"; + String PASSWORD = "password"; + String HASHED_PASSWORD = "cGFzc3dvcmQ="; + + public void testToLongArrayConstructor() + { + try + { + HashedUser user = new HashedUser(new String[]{USERNAME, PASSWORD, USERNAME}); + fail("Error expected"); + } + catch (IllegalArgumentException e) + { + 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, HASHED_PASSWORD}); + assertEquals("Username incorrect", USERNAME, user.getName()); + int index = 0; + + char[] hash = HASHED_PASSWORD.toCharArray(); + + try + { + for (byte c : user.getEncodedPassword()) + { + assertEquals("Password incorrect", hash[index], (char) c); + index++; + } + } + catch (Exception e) + { + fail(e.getMessage()); + } + + hash = PASSWORD.toCharArray(); + + index=0; + for (char c : user.getPassword()) + { + assertEquals("Password incorrect", hash[index], c); + index++; + } + + } + catch (UnsupportedEncodingException e) + { + fail(e.getMessage()); + } + } +} + -- cgit v1.2.1