1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.fhw.cabaweb.junittests;
21
22 import org.fhw.cabaweb.tools.Password;
23
24 import junit.framework.TestCase;
25
26 /***
27 * Klasse für den Test der Passwortfunktionen
28 *
29 * @author <a href="mailto:thomas.vogt@tvc-software.com">Thomas Vogt</a>
30 * @version Version 1.0 10.03.2004
31 */
32 public class PasswordTest extends TestCase
33 {
34
35 public static void main(String args[])
36 {
37
38 junit.textui.TestRunner.run(PasswordTest.class);
39 }
40
41 public void testPasswortGenerator()
42 {
43 assertNotNull("", Password.passwortGenerator(0));
44 assertNotNull("", Password.passwortGenerator(8));
45 }
46
47 public void testGenerateMD5()
48 {
49 assertNotNull("", Password.generateMD5(null));
50 assertNotNull("", Password.generateMD5(""));
51 assertNotNull("", Password.generateMD5("test"));
52 assertEquals(Password.generateMD5("test"), Password.generateMD5("test"));
53 assertEquals(Password.generateMD5("1234test1234"), Password.generateMD5("1234test1234"));
54 }
55
56 public void testCompareMD5Hashes()
57 {
58 assertEquals(new Boolean(true), Password.compareMD5Hashes("", ""));
59 assertEquals(
60 new Boolean(true),
61 Password.compareMD5Hashes("d41d8cd98f00b204e9800998ecf8427e", "d41d8cd98f00b204e9800998ecf8427e"));
62 assertEquals(
63 new Boolean(true),
64 Password.compareMD5Hashes("daa912465bf0b1fc24a2edfb147eb899", "daa912465bf0b1fc24a2edfb147eb899"));
65 assertEquals(
66 new Boolean(false),
67 Password.compareMD5Hashes("daa912465bf0b1fc24a2edfb147eb899", "daa912465bf0b1fc24a2edfb147eb898"));
68 }
69
70 public void testCompareMD5HashToString()
71 {
72 assertEquals(new Boolean(true), Password.compareMD5HashToString("d41d8cd98f00b204e9800998ecf8427e", ""));
73 assertEquals(new Boolean(true), Password.compareMD5HashToString("098f6bcd4621d373cade4e832627b4f6", "test"));
74 assertEquals(new Boolean(false), Password.compareMD5HashToString("098f6bcd4621d373cade4e832627b4f6", "test2"));
75 }
76
77 }