1 20 21 package org.apache.directory.ldastudio.browser.core.model; 22 23 import org.apache.directory.ldapstudio.browser.core.model.Password; 24 25 import junit.framework.TestCase; 26 27 33 public class PasswordTest extends TestCase 34 { 35 38 public void testNullPassword() 39 { 40 try 41 { 42 new Password( (String )null ); 43 fail(); 44 } 45 catch ( IllegalArgumentException iae ) 46 { 47 assertTrue( true ); 48 } 49 } 50 51 52 55 public void testPasswordSHAEncrypted() 56 { 57 Password password = new Password( "{SHA}5en6G6MezRroT3XKqkdPOmY/BfQ=" ); 58 59 assertTrue( password.verify( "secret" ) ); 60 } 61 62 65 public void testPasswordSSHAEncrypted() 66 { 67 Password password = new Password( "{SSHA}mjVVxasFkk59wMW4L1Ldt+YCblfhULHs03WW7g==" ); 68 69 assertTrue( password.verify( "secret" ) ); 70 } 71 72 75 public void testPasswordMD5Encrypted() 76 { 77 Password password = new Password( "{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==" ); 78 79 assertTrue( password.verify( "secret" ) ); 80 } 81 82 85 public void testPasswordSMD5Encrypted() 86 { 87 Password password = new Password( "{SMD5}tQ9wo/VBuKsqBtylMMCcORbnYOJFMyDJ" ); 88 89 assertTrue( password.verify( "secret" ) ); 90 } 91 92 95 public void testPasswordCRYPTEncrypted() 96 { 97 Password password = new Password( "{CRYPT}qFkH8Z1woBlXw" ); 98 99 assertTrue( password.verify( "secret" ) ); 100 } 101 102 105 public void testPasswordBadAlgorithm() 106 { 107 Password password = new Password( "{CRYPTE}qFkH8Z1woBlXw" ); 108 109 assertFalse( password.verify( "secret" ) ); 110 } 111 } 112 | Popular Tags |