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 junit.framework.TestCase;
06: import java.io.*;
07:
08: public class MultiUserAuthenticatorTest extends TestCase {
09: private File passwd;
10:
11: private PrintStream ps;
12:
13: private final String passwordFilename = "testpasswd";
14:
15: private MultiUserAuthenticator a;
16:
17: protected void setUp() throws Exception {
18: passwd = new File(passwordFilename);
19: ps = new PrintStream(new FileOutputStream(passwd));
20: ps.println("uncle:bob");
21: ps.println("micah:boy");
22: ps.close();
23: a = new MultiUserAuthenticator(passwordFilename);
24: }
25:
26: protected void tearDown() throws Exception {
27: passwd.delete();
28: }
29:
30: public void testBuildAuthenticator() throws Exception {
31: assertEquals(2, a.userCount());
32: assertEquals("bob", a.getPasswd("uncle"));
33: assertEquals("boy", a.getPasswd("micah"));
34: }
35:
36: public void testAuthenticRequest() throws Exception {
37: assertTrue(a.isAuthenticated("uncle", "bob"));
38: }
39:
40: public void testInauthenticRequest() throws Exception {
41: assertFalse(a.isAuthenticated("bill", "boob"));
42: }
43: }
|