Revision 8435
Added by Jing Tao about 11 years ago
test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java | ||
---|---|---|
29 | 29 |
private static final String GROUPNAME2 = "dataone-dev"; |
30 | 30 |
private static final String GROUPNAME3 = "dev"; |
31 | 31 |
private static final String USERNAME = "uid=john,o=NCEAS,dc=ecoinformatics,dc=org"; |
32 |
private static final String USERNAME2="uid=smith,o=unaffiliated,dc=ecoinformatics,dc=org"; |
|
32 | 33 |
private static final String PASSWORD = "ecoinformatics"; |
33 | 34 |
/** |
34 | 35 |
* consstructor for the test |
... | ... | |
76 | 77 |
*/ |
77 | 78 |
public void testAddGroup() throws Exception{ |
78 | 79 |
AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH); |
79 |
authFile.addGroup(GROUPNAME); |
|
80 |
authFile.addGroup(GROUPNAME, "Developers at NCEAS");
|
|
80 | 81 |
try { |
81 |
authFile.addGroup(GROUPNAME); |
|
82 |
authFile.addGroup(GROUPNAME, "Developers at NCEAS");
|
|
82 | 83 |
assertTrue("We can't reach here since we can't add the group twice", false); |
83 | 84 |
} catch (AuthenticationException e) { |
84 | 85 |
|
... | ... | |
94 | 95 |
AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH); |
95 | 96 |
String[]groups = {GROUPNAME}; |
96 | 97 |
authFile.addUser(USERNAME, groups, PASSWORD); |
98 |
authFile.addUser(USERNAME2, null, PASSWORD); |
|
97 | 99 |
try { |
98 | 100 |
authFile.addUser(USERNAME, groups, PASSWORD); |
99 | 101 |
assertTrue("We can't reach here since we can't add the user twice", false); |
... | ... | |
201 | 203 |
} catch(AuthenticationException e) { |
202 | 204 |
System.out.println("Failed to add a user to a group "+e.getMessage()); |
203 | 205 |
} |
204 |
authFile.addGroup(GROUPNAME2); |
|
206 |
authFile.addGroup(GROUPNAME2, null);
|
|
205 | 207 |
authFile.addUserToGroup(USERNAME, GROUPNAME2); |
206 | 208 |
String[][]groups = authFile.getGroups(null, null, USERNAME); |
207 | 209 |
assertTrue("The user "+USERNAME+" should be in the group "+GROUPNAME2, groups[0][0].equals(GROUPNAME2)||groups[1][0].equals(GROUPNAME2)); |
... | ... | |
220 | 222 |
} catch(AuthenticationException e) { |
221 | 223 |
System.out.println("Failed to remove a user from a group "+e.getMessage()); |
222 | 224 |
} |
223 |
authFile.addGroup(GROUPNAME3); |
|
225 |
authFile.addGroup(GROUPNAME3, "Developers");
|
|
224 | 226 |
try { |
225 | 227 |
authFile.removeUserFromGroup(USERNAME, GROUPNAME3); |
226 | 228 |
assertTrue("Can't reach here since the user is not in the group", false); |
Also available in: Unified diff
Change the addGroup method since the API was changed.