Beispiel #1
0
class TestVumiUserApiMiddleware(GoDjangoTestCase):
    def setUp(self):
        self.vumi_helper = self.add_helper(DjangoVumiApiHelper())
        self.user_helper = self.vumi_helper.make_django_user()

        self.factory = RequestFactory()
        self.mw = VumiUserApiMiddleware()

    def test_unauthenticated_access(self):
        request = self.factory.get('/accounts/login/')
        self.mw.process_request(request)
        self.assertFalse(hasattr(request, 'user_api'))
        self.assertFalse(hasattr(request, 'session'))

    def test_authenticated_access(self):
        request = self.factory.get('/accounts/login/')
        request.user = self.user_helper.get_django_user()
        request.session = {}
        self.mw.process_request(request)
        self.assertTrue(isinstance(request.user_api, VumiUserApi))
        self.assertEqual(SessionManager.get_user_account_key(request.session),
                         self.user_helper.account_key)
Beispiel #2
0
class TestVumiUserApiMiddleware(GoDjangoTestCase):

    def setUp(self):
        self.vumi_helper = self.add_helper(DjangoVumiApiHelper())
        self.user_helper = self.vumi_helper.make_django_user()

        self.factory = RequestFactory()
        self.mw = VumiUserApiMiddleware()

    def test_unauthenticated_access(self):
        request = self.factory.get('/accounts/login/')
        self.mw.process_request(request)
        self.assertFalse(hasattr(request, 'user_api'))
        self.assertFalse(hasattr(request, 'session'))

    def test_authenticated_access(self):
        request = self.factory.get('/accounts/login/')
        request.user = self.user_helper.get_django_user()
        request.session = {}
        self.mw.process_request(request)
        self.assertTrue(isinstance(request.user_api, VumiUserApi))
        self.assertEqual(
            SessionManager.get_user_account_key(request.session),
            self.user_helper.account_key)
Beispiel #3
0
    def setUp(self):
        self.vumi_helper = self.add_helper(DjangoVumiApiHelper())
        self.user_helper = self.vumi_helper.make_django_user()

        self.factory = RequestFactory()
        self.mw = VumiUserApiMiddleware()
Beispiel #4
0
    def setUp(self):
        self.vumi_helper = self.add_helper(DjangoVumiApiHelper())
        self.user_helper = self.vumi_helper.make_django_user()

        self.factory = RequestFactory()
        self.mw = VumiUserApiMiddleware()