예제 #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')