- Timestamp:
- 22 Aug 2013, 08:29:12 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
r10523 r10524 186 186 'type': 'applicant'} 187 187 if username in ( 188 'fault1', 'fault2', 'fault3', 'fault4' ) and password == 'biz':188 'fault1', 'fault2', 'fault3', 'fault4', 'fault7') and password == 'biz': 189 189 return {'type': 'student'} 190 190 if username == 'fault5' and password == 'biz': … … 206 206 lastname='Charles', 207 207 ) 208 if username in ('fault1', 'fault2', 'fault3', 'fault4', 'fault5'): 208 if username in ('fault1', 'fault2', 'fault3', 209 'fault4', 'fault5', 'fault7'): 209 210 return dict(email='ff@ff.ff', 210 211 firstname='John', … … 233 234 if arg[0]['username'] in ('school1-fault4', 'school1-fault5'): 234 235 raise xmlrpclib.Fault('faultCode', 'Username already exists') 236 if arg[0]['username'] == 'school1-fault7': 237 raise xmlrpclib.Fault('faultCode', 'Email address already exists') 235 238 return None 236 239 … … 250 253 251 254 class KofaAuthenticatorsIntegrationTests(unittest.TestCase): 252 # A test case where a fake Kofa server is started before tests (and253 # shut down afterwards).255 # A test case where a fake Kofa server and a fake Moodle server 256 # are started before tests (and shut down afterwards). 254 257 255 258 kofa_server = None … … 319 322 xmlrpclib.Fault, proxy.core_user_create_users, 320 323 [{'username': 'school1-fault1'}]) 324 self.assertRaises( 325 xmlrpclib.Fault, proxy.core_user_create_users, 326 [{'username': 'school1-fault7'}]) 321 327 # test core_user_get_users 322 328 result = proxy.core_user_get_users( … … 358 364 result8 = auth.check_credentials('SCHOOL1-fault6', 'biz') 359 365 assert result8 == (False, 'User not eligible') 366 result9 = auth.check_credentials('SCHOOL1-fault7', 'biz') 367 assert result9 == (False, 368 'Another Moodle user is using the same email address.' 369 ' Email addresses can\'t be used twice in Moodle.') 360 370 361 371 # exceptions are raised in the following cases … … 372 382 result7a = auth.check_credentials('SCHOOL1-fault5', 'biz') 373 383 assert result7a == (True, '') 384 385 # If marker is an empty sring school markers are neither 386 # checked nor removed. 387 BACKENDS3['inst1']['marker'] = '' 388 auth = KofaMoodleAuthenticator(auth_backends=str(BACKENDS3)) 389 result10s = auth.check_credentials('bird', 'bebop') 390 assert result10s == (True, '') 391 result10a = auth.check_credentials('pig', 'pog') 392 assert result10a == (True, '') 393 result11s = auth.check_credentials('SCHOOL1-bird', 'bebop') 394 assert result11s == (False, 'Invalid username or password') 395 result11a = auth.check_credentials('SCHOOL1-pig', 'pog') 396 assert result11a == (False, 'Invalid username or password')
Note: See TracChangeset for help on using the changeset viewer.