Fix examples, tests which used the deprecated plugins.
| | |
| | | def make_test_middleware(app, global_conf): |
| | | """ Functionally equivalent to |
| | | |
| | | [plugin:form] |
| | | use = repoze.who.plugins.form.FormPlugin |
| | | rememberer_name = cookie |
| | | login_form_qs=__do_login |
| | | [plugin:redirector] |
| | | use = repoze.who.plugins.redirector.RedirectorPlugin |
| | | login_url = /login.html |
| | | |
| | | [plugin:cookie] |
| | | use = repoze.who.plugins.cookie:InsecureCookiePlugin |
| | | [plugin:auth_tkt] |
| | | use = repoze.who.plugins.auth_tkt:AuthTktCookiePlugin |
| | | secret = SEEKRIT |
| | | cookie_name = oatmeal |
| | | |
| | | [plugin:basicauth] |
| | |
| | | challenge_decider = repoze.who.classifiers:default_challenge_decider |
| | | |
| | | [identifiers] |
| | | plugins = form:browser cookie basicauth |
| | | plugins = authtkt basicauth |
| | | |
| | | [authenticators] |
| | | plugins = htpasswd |
| | | plugins = authtkt htpasswd |
| | | |
| | | [challengers] |
| | | plugins = form:browser basicauth |
| | | plugins = redirector:browser basicauth |
| | | """ |
| | | # be able to test without a config file |
| | | from repoze.who.plugins.basicauth import BasicAuthPlugin |
| | | from repoze.who.plugins.auth_tkt import AuthTktCookiePlugin |
| | | from repoze.who.plugins.form import FormPlugin |
| | | from repoze.who.plugins.redirector import RedirectorPlugin |
| | | from repoze.who.plugins.htpasswd import HTPasswdPlugin |
| | | io = StringIO() |
| | | for name, password in [ ('admin', 'admin'), ('chris', 'chris') ]: |
| | |
| | | htpasswd = HTPasswdPlugin(io, cleartext_check) |
| | | basicauth = BasicAuthPlugin('repoze.who') |
| | | auth_tkt = AuthTktCookiePlugin('secret', 'auth_tkt') |
| | | form = FormPlugin('__do_login', rememberer_name='auth_tkt') |
| | | form.classifications = { IIdentifier:['browser'], |
| | | IChallenger:['browser'] } # only for browser |
| | | identifiers = [('form', form),('auth_tkt',auth_tkt),('basicauth',basicauth)] |
| | | redirector = RedirectorPlugin('/login.html') |
| | | redirector.classifications = {IChallenger: ['browser']} # only for browser |
| | | identifiers = [('auth_tkt', auth_tkt), |
| | | ('basicauth', basicauth), |
| | | ] |
| | | authenticators = [('htpasswd', htpasswd)] |
| | | challengers = [('form',form), ('basicauth',basicauth)] |
| | | challengers = [('redirector', redirector), |
| | | ('basicauth', basicauth)] |
| | | mdproviders = [] |
| | | from repoze.who.classifiers import default_request_classifier |
| | | from repoze.who.classifiers import default_challenge_decider |
| | |
| | | log_level = logging.DEBUG |
| | | ) |
| | | return middleware |
| | | |
| | | |
| | |
| | | middleware = factory(app, global_conf, config_file=path, |
| | | log_file='STDOUT', log_level='debug') |
| | | api_factory = middleware.api_factory |
| | | self.assertEqual(len(api_factory.identifiers), 3) |
| | | self.assertEqual(len(api_factory.identifiers), 2) |
| | | self.assertEqual(len(api_factory.authenticators), 1) |
| | | self.assertEqual(len(api_factory.challengers), 2) |
| | | self.assertEqual(len(api_factory.mdproviders), 0) |
| | |
| | | path = self._getTempfile(SAMPLE_CONFIG) |
| | | global_conf = {'here': '/'} |
| | | api_factory = factory(global_conf, config_file=path) |
| | | self.assertEqual(len(api_factory.identifiers), 3) |
| | | self.assertEqual(len(api_factory.identifiers), 2) |
| | | self.assertEqual(len(api_factory.authenticators), 1) |
| | | self.assertEqual(len(api_factory.challengers), 2) |
| | | self.assertEqual(len(api_factory.mdproviders), 0) |
| | |
| | | global_conf = {'here': '/'} |
| | | api_factory = factory(global_conf, config_file=path, |
| | | remote_user_key = 'X-OTHER-USER') |
| | | self.assertEqual(len(api_factory.identifiers), 3) |
| | | self.assertEqual(len(api_factory.identifiers), 2) |
| | | self.assertEqual(len(api_factory.authenticators), 1) |
| | | self.assertEqual(len(api_factory.challengers), 2) |
| | | self.assertEqual(len(api_factory.mdproviders), 0) |
| | |
| | | global_conf = {'here': '/'} |
| | | logger = object() |
| | | api_factory = factory(global_conf, config_file=path, logger=logger) |
| | | self.assertEqual(len(api_factory.identifiers), 3) |
| | | self.assertEqual(len(api_factory.identifiers), 2) |
| | | self.assertEqual(len(api_factory.authenticators), 1) |
| | | self.assertEqual(len(api_factory.challengers), 2) |
| | | self.assertEqual(len(api_factory.mdproviders), 0) |
| | | self.failUnless(api_factory.logger is logger) |
| | | |
| | | SAMPLE_CONFIG = """\ |
| | | [plugin:form] |
| | | use = repoze.who.plugins.form:make_plugin |
| | | login_form_qs = __do_login |
| | | rememberer_name = auth_tkt |
| | | [plugin:redirector] |
| | | use = repoze.who.plugins.redirector:make_plugin |
| | | login_url = /login.html |
| | | |
| | | [plugin:auth_tkt] |
| | | use = repoze.who.plugins.auth_tkt:make_plugin |
| | |
| | | |
| | | [identifiers] |
| | | plugins = |
| | | form;browser |
| | | auth_tkt |
| | | basicauth |
| | | |
| | |
| | | |
| | | [challengers] |
| | | plugins = |
| | | form;browser |
| | | redirector;browser |
| | | basicauth |
| | | |
| | | [mdproviders] |
| | |
| | | return make_test_middleware |
| | | |
| | | def test_it_no_WHO_LOG_in_environ(self): |
| | | from repoze.who.interfaces import IIdentifier |
| | | from repoze.who.interfaces import IAuthenticator |
| | | from repoze.who.interfaces import IChallenger |
| | | app = DummyApp() |
| | | factory = self._getFactory() |
| | | global_conf = {'here': '/'} |
| | | middleware = factory(app, global_conf) |
| | | api_factory = middleware.api_factory |
| | | self.assertEqual(len(api_factory.identifiers), 3) |
| | | self.assertEqual(len(api_factory.identifiers), 2) |
| | | self.assertEqual(len(api_factory.authenticators), 1) |
| | | self.assertEqual(len(api_factory.challengers), 2) |
| | | self.assertEqual(len(api_factory.mdproviders), 0) |