Ignore:
Timestamp:
20 Aug 2013, 10:39:07 (11 years ago)
Author:
Henrik Bettermann
Message:

Start implementing KofaMoodleAuthenticator? tests.

File:
1 edited

Legend:

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

    r10507 r10511  
    1414from waeup.cas.authenticators import (
    1515    get_all_authenticators, get_authenticator, filter_auth_opts,
    16     Authenticator, DummyAuthenticator, KofaAuthenticator
     16    Authenticator, DummyAuthenticator, KofaAuthenticator,
     17    KofaMoodleAuthenticator
    1718    )
    1819from waeup.cas.server import CASServer
     
    8384    )
    8485
     86BACKENDS3 = dict(
     87    inst1=dict(
     88        url='http://localhost:6666/',
     89        marker='^SCHOOL1-',
     90        moodle_url = 'http://localhost/moodle',
     91        )
     92    )
    8593
    8694class KofaAuthenticatorTests(unittest.TestCase):
     
    125133        assert isinstance(app.auth, KofaAuthenticator)
    126134
     135class KofaMoodleAuthenticatorTests(unittest.TestCase):
     136
     137    def test_paste_deploy_options(self):
     138        # we can set CAS server-related options via paste.deploy config
     139        paste_conf = os.path.join(
     140            os.path.dirname(__file__), 'sample4.ini')
     141        app = loadapp('config:%s' % paste_conf)
     142        assert isinstance(app, CASServer)
     143        assert app.db_connection_string == 'sqlite:///:memory:'
     144        assert isinstance(app.auth, KofaAuthenticator)
     145        assert app.auth.name == 'kofa_moodle1'
     146        auth_backends = {
     147          'kofa_moodle1':
     148            {'url': 'http://xmlrpcuser1:xmlrpcuser1@localhost:8080/app1/',
     149             'marker': '^K',
     150             'moodle_url': 'http://localhost/moodle/webservice/xmlrpc/server.php?wstoken=de1e1cbacf91ec6290bb6f6339122e7d',
     151            },
     152          }
     153        assert app.auth.backends == auth_backends
     154
    127155
    128156class FakeKofaServer(SimpleXMLRPCServer):
     
    147175        if username == 'bird' and password == 'bebop':
    148176            return {'id': 'bird', 'email': 'bird@gods.net',
    149                     'description': 'Mr. Charles Parker'}
     177                    'description': 'Mr. Charles Parker',
     178                    'type': 'student'}
     179        if username == 'pig' and password == 'pog':
     180            return {'id': 'pig', 'email': 'pig@gods.net',
     181                    'description': 'Mr. Ray Charles',
     182                    'type': 'applicant'}
    150183        return None
    151184
     
    179212            'description': 'Mr. Charles Parker',
    180213            'email': 'bird@gods.net',
    181             'id': 'bird'}
    182         result = proxy.check_applicant_credentials('bird', 'bebop')
     214            'id': 'bird',
     215            'type': 'student'}
     216        result = proxy.check_applicant_credentials('pig', 'pog')
    183217        assert result == {
    184             'description': 'Mr. Charles Parker',
    185             'email': 'bird@gods.net',
    186             'id': 'bird'}
     218            'description': 'Mr. Ray Charles',
     219            'email': 'pig@gods.net',
     220            'id': 'pig',
     221            'type': 'applicant'}
    187222        return
    188223
     
    196231        result3 = auth.check_credentials('SCHOOL2-bar', 'baz')
    197232        assert result3 == (False, 'Invalid username or password.')
     233
Note: See TracChangeset for help on using the changeset viewer.