directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r529229 - in /directory/ldapstudio/trunk/ldapstudio-browser-core/src/test: ./ java/ java/org/ java/org/apache/ java/org/apache/directory/ java/org/apache/directory/ldastudio/ java/org/apache/directory/ldastudio/browser/ java/org/apache/dire...
Date Mon, 16 Apr 2007 13:01:16 GMT
Author: elecharny
Date: Mon Apr 16 06:01:15 2007
New Revision: 529229

URL: http://svn.apache.org/viewvc?view=rev&rev=529229
Log:
Added tests for the Password class

Added:
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/model/
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/model/PasswordTest.java

Added: directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/model/PasswordTest.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/model/PasswordTest.java?view=auto&rev=529229
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/model/PasswordTest.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/test/java/org/apache/directory/ldastudio/browser/core/model/PasswordTest.java
Mon Apr 16 06:01:15 2007
@@ -0,0 +1,111 @@
+/*
+ *   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.directory.ldastudio.browser.core.model;
+
+import org.apache.directory.ldapstudio.browser.core.model.Password;
+
+import junit.framework.TestCase;
+
+/**
+ * Test all the encryption algorithmes
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordTest extends TestCase
+{
+    /**
+     * Null Password should not be accepted
+     */
+    public void testNullPassword()
+    {
+        try
+        {
+            new Password( (String)null );
+            fail();
+        }
+        catch ( IllegalArgumentException iae )
+        {
+            assertTrue( true );
+        }
+    }
+    
+    
+    /**
+     * 
+     */
+    public void testPasswordSHAEncrypted()
+    {
+        Password password = new Password( "{SHA}5en6G6MezRroT3XKqkdPOmY/BfQ=" );
+            
+        assertTrue( password.verify( "secret" ) );
+    }
+
+    /**
+     * 
+     */
+    public void testPasswordSSHAEncrypted()
+    {
+        Password password = new Password( "{SSHA}mjVVxasFkk59wMW4L1Ldt+YCblfhULHs03WW7g=="
);
+            
+        assertTrue( password.verify( "secret" ) );
+    }
+
+    /**
+     * 
+     */
+    public void testPasswordMD5Encrypted()
+    {
+        Password password = new Password( "{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==" );
+            
+        assertTrue( password.verify( "secret" ) );
+    }
+
+    /**
+     * 
+     */
+    public void testPasswordSMD5Encrypted()
+    {
+        Password password = new Password( "{SMD5}tQ9wo/VBuKsqBtylMMCcORbnYOJFMyDJ" );
+            
+        assertTrue( password.verify( "secret" ) );
+    }
+
+    /**
+     * 
+     */
+    public void testPasswordCRYPTEncrypted()
+    {
+        Password password = new Password( "{CRYPT}qFkH8Z1woBlXw" );
+            
+        assertTrue( password.verify( "secret" ) );
+    }
+
+    /**
+     * 
+     */
+    public void testPasswordBadAlgorithm()
+    {
+        Password password = new Password( "{CRYPTE}qFkH8Z1woBlXw" );
+
+        assertFalse( password.verify( "secret" ) );
+    }
+}



Mime
View raw message