Project

General

Profile

« Previous | Next » 

Revision 8494

Added by Jing Tao almost 11 years ago

Change the test file according to the change on the constructor.

View differences:

test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java
88 88
      * @throws Exception
89 89
      */
90 90
     public void testAddGroup() throws Exception{
91
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
91
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
92 92
         authFile.addGroup(GROUPNAME, DESCRIPITION);
93 93
         try {
94 94
             authFile.addGroup(GROUPNAME, "Developers at NCEAS");
......
104 104
      * @throws Exception
105 105
      */
106 106
     public void testAddUser() throws Exception{
107
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
107
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
108 108
         String[]groups = {GROUPNAME};
109 109
         authFile.addUser(USERNAME, groups, PLAINPASSWORD, null, EMAILADDRESS, SURNAME, GIVENNAME, ORGANIZATIONNAME);
110 110
         //user a hash value of the PASSWORD
......
123 123
      * @throws Exception
124 124
      */
125 125
     public void testAuthenticate() throws Exception {
126
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
126
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
127 127
         boolean success = authFile.authenticate(USERNAME, PLAINPASSWORD);
128 128
         if(!success) {
129 129
             assertTrue("The authentication should succeed.", false);
......
151 151
      * @throws Exception
152 152
      */
153 153
     public void testGetUserInfo() throws Exception {
154
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
154
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
155 155
         String[] userInfo = authFile.getUserInfo(USERNAME, null);
156 156
         assertTrue("The common name for the user "+USERNAME+" should be "+GIVENNAME+" "+SURNAME, userInfo[0].equals(GIVENNAME+" "+SURNAME));
157 157
         assertTrue("The org name for the user "+USERNAME+" should be "+ORGANIZATIONNAME, userInfo[1].equals(ORGANIZATIONNAME));
......
167 167
      * @throws Exception
168 168
      */
169 169
     public void testGetUsers() throws Exception {
170
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
170
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
171 171
         String[][] users = authFile.getUsers(null, null);
172 172
         assertTrue("The file should have one user "+USERNAME, users[0][0].equals(USERNAME));
173 173
         assertTrue("The common name for the user "+USERNAME+" should be "+GIVENNAME+" "+SURNAME, users[0][1].equals(GIVENNAME+" "+SURNAME));
......
190 190
      * @throws Exception
191 191
      */
192 192
     public void testGetGroups() throws Exception {
193
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
193
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
194 194
         String[][] groups = authFile.getGroups(null, null);
195 195
         assertTrue("The file should have one group associated with "+USERNAME, groups[0][0].equals(GROUPNAME));
196 196
         assertTrue("The group "+groups[0][0]+" should have the description "+DESCRIPITION, groups[0][1].equals(DESCRIPITION));
......
208 208
      * @throws Exception
209 209
      */
210 210
     public void testChangePassword() throws Exception {
211
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
211
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
212 212
         authFile.authenticate(USERNAME, PLAINPASSWORD);
213 213
         String newPassword = "hello";
214 214
         authFile.modifyPassWithPlain(USERNAME,newPassword);
......
239 239
      * @throws Exception
240 240
      */
241 241
     public void testAddRemoveUserToFromGroup() throws Exception{
242
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
242
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
243 243
         try {
244 244
             authFile.addUserToGroup("user1", GROUPNAME);
245 245
             assertTrue("Can't reach here since we tried to add an unexisting user to a group", false);
......
318 318
      * @throws Exception
319 319
      */
320 320
     public void testGetPrincipals() throws Exception {
321
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
321
         AuthFile authFile = new AuthFile(PASSWORDFILEPATH);
322 322
         System.out.println(""+authFile.getPrincipals(null, null));
323 323
     }
324 324
}

Also available in: Unified diff