Changeset 10511 for main/waeup.cas
- Timestamp:
- 20 Aug 2013, 10:39:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
r10507 r10511 14 14 from waeup.cas.authenticators import ( 15 15 get_all_authenticators, get_authenticator, filter_auth_opts, 16 Authenticator, DummyAuthenticator, KofaAuthenticator 16 Authenticator, DummyAuthenticator, KofaAuthenticator, 17 KofaMoodleAuthenticator 17 18 ) 18 19 from waeup.cas.server import CASServer … … 83 84 ) 84 85 86 BACKENDS3 = dict( 87 inst1=dict( 88 url='http://localhost:6666/', 89 marker='^SCHOOL1-', 90 moodle_url = 'http://localhost/moodle', 91 ) 92 ) 85 93 86 94 class KofaAuthenticatorTests(unittest.TestCase): … … 125 133 assert isinstance(app.auth, KofaAuthenticator) 126 134 135 class 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 127 155 128 156 class FakeKofaServer(SimpleXMLRPCServer): … … 147 175 if username == 'bird' and password == 'bebop': 148 176 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'} 150 183 return None 151 184 … … 179 212 'description': 'Mr. Charles Parker', 180 213 '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') 183 217 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'} 187 222 return 188 223 … … 196 231 result3 = auth.check_credentials('SCHOOL2-bar', 'baz') 197 232 assert result3 == (False, 'Invalid username or password.') 233
Note: See TracChangeset for help on using the changeset viewer.