Changeset 5897 for main/waeup.sirp/trunk
- Timestamp:
- 30 Mar 2011, 14:33:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_authentication.py
r5817 r5897 21 21 ## 22 22 import grok 23 import shutil 24 import tempfile 23 25 import unittest 24 from zope.component import provideAdapter 26 from zope.app.testing.functional import FunctionalTestCase 27 from zope.authentication.interfaces import IAuthentication 28 from zope.component import provideAdapter, getUtility 25 29 from zope.component.hooks import setSite, clearSite 26 30 from zope.interface import verify … … 30 34 from zope.session.interfaces import ISession 31 35 from zope.site import LocalSiteManager 36 from zope.testbrowser.testing import Browser 32 37 from zope.testing import cleanup 38 from waeup.sirp.testing import FunctionalLayer 39 from waeup.sirp.app import University 33 40 from waeup.sirp.applicants.authentication import ( 34 41 ApplicantsAuthenticatorPlugin, WAeUPApplicantCredentialsPlugin, 35 42 ApplicantCredentials, AuthenticatedApplicantPrincipalFactory, 36 43 ApplicantPrincipalInfo, ApplicantPrincipal) 44 37 45 38 46 class FakeBatch(dict): … … 289 297 self.assertEqual(principal.id, 'APP-1-1234567890') 290 298 return 299 300 class PAUSetupTest(FunctionalTestCase): 301 # Check correct setup of authentication components in the 302 # applicants subpackage. 303 304 # When a university is created, we want by default have our local 305 # authentication components (an authenticator plugin and a 306 # credentials plugin) to be registered with the local PAU. Admins 307 # can remove these components on the fly later-on if they wish. 308 309 layer = FunctionalLayer 310 311 def setUp(self): 312 super(PAUSetupTest, self).setUp() 313 314 # Setup a sample site for each test 315 app = University() 316 self.dc_root = tempfile.mkdtemp() 317 app['datacenter'].setStoragePath(self.dc_root) 318 319 # Prepopulate the ZODB... 320 self.getRootFolder()['app'] = app 321 self.app = self.getRootFolder()['app'] 322 self.browser = Browser() 323 self.browser.handleErrors = False 324 325 def tearDown(self): 326 super(PAUSetupTest, self).tearDown() 327 shutil.rmtree(self.dc_root) 328 329 def test_extra_auth_plugins_installed(self): 330 # Check whether the auth plugins defined in here are setup 331 # automatically when a university is created 332 333 # Get the PAU responsible for the local site ('app') 334 pau = getUtility(IAuthentication, context=self.app) 335 cred_plugins = pau.getCredentialsPlugins() 336 auth_plugins = pau.getAuthenticatorPlugins() 337 cred_names = [name for name, plugin in cred_plugins] 338 auth_names = [name for name, plugin in auth_plugins] 291 339 340 # Make sure our local ApplicantsAuthenticatorPlugin is registered... 341 self.assertTrue('applicants' in auth_names) 342 # Make sure our local WAeUPApplicantCredentialsPlugin is registered... 343 self.assertTrue('applicant_credentials' in cred_names) 344 return 345 292 346 def test_suite(): 293 347 suite = unittest.TestSuite() … … 295 349 AuthenticatorPluginTest, CredentialsPluginTest, 296 350 ApplicantCredentialsTest, PrincipalFactoryTest, 351 PAUSetupTest, 297 352 ]: 298 353 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
Note: See TracChangeset for help on using the changeset viewer.