示例#1
0
文件: test_views.py 项目: dbaty/Lasco
 def setUp(self):
     from lasco.auth import setup_who_api_factory
     from lasco.app import set_config
     LascoTestCase.setUp(self)
     set_config(self.config)
     self.config.testing_add_renderer('templates/layout.pt')
     setup_who_api_factory(self.config, None, None, DummyWhoApiFactory)
示例#2
0
文件: app.py 项目: dbaty/Lasco
def make_app(global_settings, **settings):
    config = Configurator(settings=settings)
    set_config(config)
    initialize_sql(settings['lasco.db_string'])
    setup_who_api_factory(
        config, global_settings, settings['lasco.auth_config'])
    return config.make_wsgi_app()
示例#3
0
文件: test_views.py 项目: dbaty/Lasco
 def setUp(self):
     from lasco.auth import setup_who_api_factory
     from lasco.models import Picture
     LascoTestCase.setUp(self)
     setup_who_api_factory(self.config, None, None, DummyWhoApiFactory)
     self.add_gallery('g', u'Gallery')
     self.add_album('g', 'a', u'Album')
     self.picture = self.session.query(Picture).first()
示例#4
0
文件: test_auth.py 项目: dbaty/Lasco
 def setUp(self):
     from lasco.auth import setup_who_api_factory
     LascoTestCase.setUp(self)
     class DummyWhoApi(object):
         def __init__(self, environ):
             self.environ = environ
         def authenticate(self):
             identity = self.environ.get('repoze.who.identity')
             if identity is None:
                 return identity
             return identity.copy()
     setup_who_api_factory(self.config, None, None, DummyWhoApi)
示例#5
0
文件: test_auth.py 项目: dbaty/Lasco
 def test_login_valid_credentials(self):
     from lasco.auth import setup_who_api_factory
     from lasco.views.auth import login
     class AlwaysLogsIn(object):
         def __init__(self, environ):
             pass
         def login(self, credentials):
             return True, {}
     setup_who_api_factory(self.config, None, None, AlwaysLogsIn)
     request = self._make_request(post={'login': u'jsmith',
                                        'password': u'password',
                                        'next': 'http://next'})
     response = login(request)
     self.assertEqual(response.status, '303 See Other')
     self.assertEqual(response.location, 'http://next')
示例#6
0
文件: test_auth.py 项目: dbaty/Lasco
 def test_logout(self):
     from lasco.auth import setup_who_api_factory
     from lasco.views.auth import logout
     headers = {'logout-marker': 'marker'}
     class DummyWhoApi(object):
         def __init__(self, environ):
             pass
         def logout(self):
             return headers
     setup_who_api_factory(self.config, None, None, DummyWhoApi)
     request = self._make_request()
     request.application_url = 'http://application.url'
     response = logout(request)
     self.assertEqual(response.status, '303 See Other')
     self.assertEqual(response.location, request.application_url)
     self.assertEqual(response.headers['logout-marker'], 'marker')
示例#7
0
文件: test_auth.py 项目: dbaty/Lasco
 def test_login_try_invalid_credentials(self):
     from lasco.auth import setup_who_api_factory
     from lasco.views.auth import login
     class NeverLogsIn(object):
         def __init__(self, environ):
             pass
         def login(self, credentials):
             return False, {}
         def authenticate(self):  # required by 'login_form'
             return None
     setup_who_api_factory(self.config, None, None, NeverLogsIn)
     request = self._make_request(post={'login': u'jsmith',
                                        'password': u'password',
                                        'next': 'http://next'})
     res = login(request)
     self.assertEqual(res['error_msg'], u'Wrong user name or password.')
     self.assertEqual(res['login'], u'jsmith')