Changeset 10524 for main/waeup.cas


Ignore:
Timestamp:
22 Aug 2013, 08:29:12 (11 years ago)
Author:
Henrik Bettermann
Message:

Test coverage 100%.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py

    r10523 r10524  
    186186                    'type': 'applicant'}
    187187        if username in (
    188             'fault1', 'fault2', 'fault3', 'fault4') and password == 'biz':
     188            'fault1', 'fault2', 'fault3', 'fault4', 'fault7') and password == 'biz':
    189189            return {'type': 'student'}
    190190        if username == 'fault5' and password == 'biz':
     
    206206                        lastname='Charles',
    207207                        )
    208         if username in ('fault1', 'fault2', 'fault3', 'fault4', 'fault5'):
     208        if username in ('fault1', 'fault2', 'fault3',
     209                        'fault4', 'fault5', 'fault7'):
    209210            return dict(email='ff@ff.ff',
    210211                        firstname='John',
     
    233234        if arg[0]['username'] in ('school1-fault4', 'school1-fault5'):
    234235            raise xmlrpclib.Fault('faultCode', 'Username already exists')
     236        if arg[0]['username'] == 'school1-fault7':
     237            raise xmlrpclib.Fault('faultCode', 'Email address already exists')
    235238        return None
    236239
     
    250253
    251254class KofaAuthenticatorsIntegrationTests(unittest.TestCase):
    252     # A test case where a fake Kofa server is started before tests (and
    253     # 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).
    254257
    255258    kofa_server = None
     
    319322            xmlrpclib.Fault, proxy.core_user_create_users,
    320323            [{'username': 'school1-fault1'}])
     324        self.assertRaises(
     325            xmlrpclib.Fault, proxy.core_user_create_users,
     326            [{'username': 'school1-fault7'}])
    321327        # test core_user_get_users
    322328        result = proxy.core_user_get_users(
     
    358364        result8 = auth.check_credentials('SCHOOL1-fault6', 'biz')
    359365        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.')
    360370
    361371        # exceptions are raised in the following cases
     
    372382        result7a = auth.check_credentials('SCHOOL1-fault5', 'biz')
    373383        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.