- Timestamp:
- 20 Aug 2013, 14:00:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
r10513 r10514 183 183 'description': 'Mr. Ray Charles', 184 184 'type': 'applicant'} 185 if username in ( 186 'fault1', 'fault2', 'fault3', 'fault4') and password == 'biz': 187 return {'type': 'student'} 185 188 return None 186 189 … … 197 200 lastname='Charles', 198 201 ) 199 return None 202 if username in ('fault1', 'fault2', 'fault3', 'fault4'): 203 return dict(email='ff@ff.ff', 204 firstname='John', 205 lastname='Fault', 206 ) 200 207 201 208 class FakeMoodleServer(SimpleXMLRPCServer): … … 216 223 def _core_user_create_users(self, arg): 217 224 # fake Moodle core_user_create_users method. 218 if arg[0]['username'] == 'fault ':225 if arg[0]['username'] == 'fault1': 219 226 raise xmlrpclib.Fault('faultCode', 'faultString') 227 if arg[0]['username'] == 'fault4': 228 raise xmlrpclib.Fault('faultCode', 'Username already exists') 220 229 return None 221 230 222 231 def _core_user_get_users(self, arg): 223 232 # fake Moodle core_user_get_users method. 224 if arg[0]['value'] == 'fault ':233 if arg[0]['value'] == 'fault2': 225 234 raise xmlrpclib.Fault('faultCode', 'faultString') 235 if arg[0]['value'] == 'fault3': 236 return {'users':[{'id':'fault3'}]} 226 237 return {'users':[{'id':'any id'}]} 227 238 228 239 def _core_user_update_users(self, arg): 229 240 # fake Moodle core_user_update_users method. 230 if arg[0]['id'] == 'fa il':241 if arg[0]['id'] == 'fault3': 231 242 raise xmlrpclib.Fault('faultCode', 'faultString') 232 243 return None … … 295 306 self.assertRaises( 296 307 xmlrpclib.Fault, proxy.core_user_create_users, 297 [{'username': 'fault '}])308 [{'username': 'fault1'}]) 298 309 # test core_user_get_users 299 310 result = proxy.core_user_get_users( … … 302 313 self.assertRaises( 303 314 xmlrpclib.Fault, proxy.core_user_get_users, 304 [{'key': 'username', 'value': 'fault '}])315 [{'key': 'username', 'value': 'fault2'}]) 305 316 # test core_user_update_users 306 317 result = proxy.core_user_update_users( … … 309 320 self.assertRaises( 310 321 xmlrpclib.Fault, proxy.core_user_update_users, 311 [{'id': 'fa il'}])322 [{'id': 'fault3'}]) 312 323 return 313 324 … … 331 342 result3 = auth.check_credentials('SCHOOL2-bar', 'baz') 332 343 assert result3 == (False, 'Invalid username or password.') 344 # exceptions are raised in the follwoing cases 345 result4 = auth.check_credentials('SCHOOL1-fault1', 'biz') 346 assert result4 == (False, 'faultString') 347 result5 = auth.check_credentials('SCHOOL1-fault2', 'biz') 348 assert result5 == (False, 'faultString') 349 result6 = auth.check_credentials('SCHOOL1-fault3', 'biz') 350 assert result6 == (False, 'faultString') 351 # no exception if user exists 352 result7 = auth.check_credentials('SCHOOL1-fault4', 'biz') 353 assert result7 == (True, '')
Note: See TracChangeset for help on using the changeset viewer.