Revision 8466
Added by Jing Tao almost 11 years ago
test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java | ||
---|---|---|
94 | 94 |
public void testAddUser() throws Exception{ |
95 | 95 |
AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH); |
96 | 96 |
String[]groups = {GROUPNAME}; |
97 |
authFile.addUser(USERNAME, groups, PASSWORD); |
|
98 |
authFile.addUser(USERNAME2, null, PASSWORD); |
|
97 |
authFile.addUser(USERNAME, groups, PASSWORD, null, null, null, null);
|
|
98 |
authFile.addUser(USERNAME2, null, PASSWORD, null, null, null,null);
|
|
99 | 99 |
try { |
100 |
authFile.addUser(USERNAME, groups, PASSWORD); |
|
100 |
authFile.addUser(USERNAME, groups, PASSWORD, null, null, null, null);
|
|
101 | 101 |
assertTrue("We can't reach here since we can't add the user twice", false); |
102 | 102 |
} catch (AuthenticationException e) { |
103 | 103 |
|
... | ... | |
159 | 159 |
*/ |
160 | 160 |
public void testChangePassword() throws Exception { |
161 | 161 |
AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH); |
162 |
String password = authFile.resetPassword(USERNAME); |
|
163 | 162 |
authFile.authenticate(USERNAME, password); |
164 | 163 |
String newPassword = "hello"; |
165 |
authFile.modifyPassword(USERNAME, password, newPassword);
|
|
164 |
authFile.modifyPassWithHash(USERNAME,newPassword);
|
|
166 | 165 |
authFile.authenticate(USERNAME, newPassword); |
167 | 166 |
try { |
168 |
authFile.resetPassword("user1"); |
|
169 |
assertTrue("Can't reach here since we tried to reset the password for an unexisting user ", false); |
|
170 |
} catch (AuthenticationException e) { |
|
171 |
System.out.println("Failed to reset the password for a user: "+e.getMessage()); |
|
172 |
} |
|
173 |
try { |
|
174 |
authFile.modifyPassword("user1", "old", "new"); |
|
167 |
authFile.modifyPassWithPlain("user1", "new"); |
|
175 | 168 |
assertTrue("Can't reach here since we tried to change the password for an unexisting user ", false); |
176 | 169 |
} catch (AuthenticationException e) { |
177 | 170 |
System.out.println("Failed to change the password for a user: "+e.getMessage()); |
Also available in: Unified diff
Change the test file according to the change made in the class.