Changeset 10462
- Timestamp:
- 7 Aug 2013, 09:11:59 (11 years ago)
- Location:
- main/waeup.cas/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/setup.py
r10394 r10462 68 68 [waeup.cas.authenticators] 69 69 dummy = waeup.cas.authenticators:DummyAuthenticator 70 kofa1 = waeup.cas.authenticators:KofaAuthenticator 70 71 """, 71 72 ) -
main/waeup.cas/trunk/waeup/cas/authenticators.py
r10396 r10462 109 109 reason = 'Invalid username or password.' 110 110 return result, reason 111 112 113 class KofaAuthenticator(Authenticator): 114 """Authenticate against a running Kofa instance. 115 """ 116 117 name = 'kofa1' 118 119 def __init__(self, auth_services=None): 120 self.services = auth_services 121 122 def check_credentials(self, username='', password=''): 123 """Do the real check. 124 """ 125 return False, 'Not implemented.' -
main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
r10396 r10462 1 import os 1 2 import unittest 3 from paste.deploy import loadapp 2 4 from waeup.cas.authenticators import ( 3 5 get_all_authenticators, get_authenticator, filter_auth_opts, 4 Authenticator, DummyAuthenticator, 6 Authenticator, DummyAuthenticator, KofaAuthenticator 5 7 ) 8 from waeup.cas.server import CASServer 6 9 7 10 … … 54 57 result2 = auth.check_credentials('foo', 'bar') 55 58 assert result2 == (False, 'Invalid username or password.') 59 60 61 SERVICES = dict( 62 inst1 = dict(auth_url = 'http://localhost:6666/app', 63 service_url = 'http://example.com/foo/bar') 64 ) 65 66 67 class KofaAuthenticatorTests(unittest.TestCase): 68 69 def test_create(self): 70 # we can create KofaAuthenticator instances 71 auth = KofaAuthenticator() 72 assert isinstance(auth, KofaAuthenticator) 73 74 def test_options_defaults(self): 75 # all options have sensible defaults 76 auth = KofaAuthenticator() 77 assert auth.services is None 78 79 def test_options(self): 80 # we can pass options 81 auth = KofaAuthenticator(auth_services=SERVICES) 82 assert auth.services == SERVICES 83 84 def test_paste_deploy_options(self): 85 # we can set CAS server-related options via paste.deploy config 86 paste_conf = os.path.join( 87 os.path.dirname(__file__), 'sample3.ini') 88 app = loadapp('config:%s' % paste_conf) 89 assert isinstance(app, CASServer) 90 assert app.db_connection_string == 'sqlite:///:memory:' 91 assert isinstance(app.auth, KofaAuthenticator) 92 93 def DIStest_check_credentials(self): 94 # we get real responses when querying Kofa instances 95 auth = KofaAuthenticator() 96 result1 = auth.check_credentials('bird', 'bebop') 97 assert result1 == (True, '') 98 result2 = auth.check_credentials('foo', 'bar') 99 assert result2 == (False, 'Invalid username or password.')
Note: See TracChangeset for help on using the changeset viewer.