Project

General

Profile

« Previous | Next » 

Revision 8479

Added by Jing Tao almost 11 years ago

Made changes according the changes in the AuthFile class.

View differences:

test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java
41 41
    private static final String EMAILADDRESS = "john@nceas.ucsb.edu";
42 42
    private static final String SURNAME = "John";
43 43
    private static final String GIVENNAME = "Joe";
44
    private static final String ORGANIZATIONNAME = "NCEAS";
44 45
    /**
45 46
     * consstructor for the test
46 47
     */
......
105 106
     public void testAddUser() throws Exception{
106 107
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
107 108
         String[]groups = {GROUPNAME};
108
         authFile.addUser(USERNAME, groups, PLAINPASSWORD, null, EMAILADDRESS, SURNAME, GIVENNAME);
109
         authFile.addUser(USERNAME, groups, PLAINPASSWORD, null, EMAILADDRESS, SURNAME, GIVENNAME, ORGANIZATIONNAME);
109 110
         //user a hash value of the PASSWORD
110
         authFile.addUser(USERNAME2, null, null, HASHEDPASSWORD2, null, null,null);
111
         authFile.addUser(USERNAME2, null, null, HASHEDPASSWORD2, null, null,null, null);
111 112
         try {
112
             authFile.addUser(USERNAME, groups, PLAINPASSWORD, null, null, null, null);
113
             authFile.addUser(USERNAME, groups, PLAINPASSWORD, null, null, null, null, null);
113 114
             assertTrue("We can't reach here since we can't add the user twice", false);
114 115
         } catch (AuthenticationException e) {
115 116
             
......
153 154
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
154 155
         String[] userInfo = authFile.getUserInfo(USERNAME, null);
155 156
         assertTrue("The common name for the user "+USERNAME+" should be "+GIVENNAME+" "+SURNAME, userInfo[0].equals(GIVENNAME+" "+SURNAME));
156
         assertTrue("The org name for the user "+USERNAME+" should be null ", userInfo[1]== null);
157
         assertTrue("The org name for the user "+USERNAME+" should be "+ORGANIZATIONNAME, userInfo[1].equals(ORGANIZATIONNAME));
157 158
         assertTrue("The email address for the user "+USERNAME+" should be "+EMAILADDRESS, userInfo[2].equals(EMAILADDRESS));
158 159
         userInfo = authFile.getUserInfo(USERNAME2, null);
159 160
         assertTrue("The common name for the user "+USERNAME2+" should be null.", userInfo[0] == null);
......
170 171
         String[][] users = authFile.getUsers(null, null);
171 172
         assertTrue("The file should have one user "+USERNAME, users[0][0].equals(USERNAME));
172 173
         assertTrue("The common name for the user "+USERNAME+" should be "+GIVENNAME+" "+SURNAME, users[0][1].equals(GIVENNAME+" "+SURNAME));
173
         assertTrue("The org name for the user "+USERNAME+" should be null ", users[0][2]== null);
174
         assertTrue("The org name for the user "+USERNAME+" should be "+ORGANIZATIONNAME, users[0][2].equals(ORGANIZATIONNAME));
174 175
         assertTrue("The org unit name for the user "+USERNAME+" should be null ", users[0][3]== null);
175 176
         assertTrue("The email address for the user "+USERNAME+" should be "+EMAILADDRESS, users[0][4].equals(EMAILADDRESS));
176 177
         assertTrue("The file should have one user "+USERNAME2, users[1][0].equals(USERNAME2));

Also available in: Unified diff