01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.authentication;
04:
05: import fitnesse.testutil.*;
06:
07: public class PasswordTest extends AbstractRegex {
08: private Password password;
09:
10: public void setUp() throws Exception {
11: password = new Password("testDir/password.txt");
12: }
13:
14: public void testArgsJustUser() throws Exception {
15: password = new Password();
16: boolean valid = password.args(new String[] { "splinter" });
17: assertTrue(valid);
18: assertEquals("splinter", password.getUsername());
19: assertEquals("passwords.txt", password.getFilename());
20: }
21:
22: public void testArgsWithFilename() throws Exception {
23: boolean valid = password.args(new String[] { "-f",
24: "somefile.txt", "shredder" });
25: assertTrue(valid);
26: assertEquals("shredder", password.getUsername());
27: assertEquals("somefile.txt", password.getFilename());
28: }
29:
30: public void testbadArgs() throws Exception {
31: boolean valid = password.args(new String[] {});
32: assertFalse(valid);
33: valid = password
34: .args(new String[] { "-d", "filename", "beebop" });
35: assertFalse(valid);
36: }
37:
38: public void testArgsWithNewCipher() throws Exception {
39: boolean valid = password
40: .args(new String[] { "-c",
41: "fitnesse.authentication.TransparentCipher",
42: "shredder" });
43: assertTrue(valid);
44: assertEquals(TransparentCipher.class, password.getCipher()
45: .getClass());
46:
47: }
48: }
|