Project

General

Profile

« Previous | Next » 

Revision 8423

Added by Jing Tao over 10 years ago

Add a test method to test authentication.

View differences:

test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java
59 59
         TestSuite suite = new TestSuite();
60 60
         suite.addTest(new AuthFileTest("testAddGroup"));
61 61
         suite.addTest(new AuthFileTest("testAddUser"));
62
         suite.addTest(new AuthFileTest("testAuthenticate"));
62 63
         return suite;
63 64
     }
64 65
     
......
94 95
         }
95 96
         
96 97
     }
98
     
99
     /**
100
      * Test the authentication method
101
      * @throws Exception
102
      */
103
     public void testAuthenticate() throws Exception {
104
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
105
         boolean success = authFile.authenticate(USERNAME, PASSWORD);
106
         if(!success) {
107
             assertTrue("The authentication should succeed.", false);
108
         }
109
         success = authFile.authenticate(USERNAME, "hello");
110
         if(success) {
111
             assertTrue("The authentication should NOT succeed.", false);
112
         }
113
         success = authFile.authenticate("hello", PASSWORD);
114
         if(success) {
115
             assertTrue("The authentication should NOT succeed.", false);
116
         }
117
     }
97 118
}

Also available in: Unified diff