def test_invalid_cases(self):
        """get_protected_namespace returns none for other links"""
        TEST_CASES = ('/', '/somewhere/', '/ejksajdlksajldjskajdlksajlkdas', )

        for case in TEST_CASES:
            request = FakeRequest(case)
            self.assertEqual(get_protected_namespace(request), None)
Exemple #2
0
    def test_invalid_cases(self):
        """get_protected_namespace returns none for other links"""
        TEST_CASES = ('/', '/somewhere/', '/ejksajdlksajldjskajdlksajlkdas', )

        for case in TEST_CASES:
            request = FakeRequest(case)
            self.assertEqual(get_protected_namespace(request), None)
    def test_valid_cases(self):
        """get_protected_namespace returns true for protected links"""
        links_prefix = reverse('misago:admin:index')
        TEST_CASES = ('', 'somewhere/', 'ejksajdlksajldjskajdlksajlkdas', )

        for case in TEST_CASES:
            request = FakeRequest(links_prefix + case)
            self.assertEqual(get_protected_namespace(request), 'misago:admin')
Exemple #4
0
    def test_valid_cases(self):
        """get_protected_namespace returns true for protected links"""
        links_prefix = reverse('misago:admin:index')
        TEST_CASES = ('', 'somewhere/', 'ejksajdlksajldjskajdlksajlkdas', )

        for case in TEST_CASES:
            request = FakeRequest(links_prefix + case)
            self.assertEqual(get_protected_namespace(request), 'misago:admin')
Exemple #5
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.admin_namespace = get_protected_namespace(request)

        if request.admin_namespace:
            if not auth.is_admin_session(request):
                auth.close_admin_session(request)
                if request.resolver_match.url_name == 'index':
                    return login(request)
                else:
                    return redirect('%s:index' % request.admin_namespace)
            else:
                auth.update_admin_session(request)
Exemple #6
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.admin_namespace = get_protected_namespace(request)

        if request.admin_namespace:
            if not auth.is_admin_session(request):
                auth.close_admin_session(request)
                if request.resolver_match.url_name == "index":
                    return login(request)
                else:
                    return redirect("%s:index" % request.admin_namespace)
            else:
                auth.update_admin_session(request)
Exemple #7
0
 def decorator(request, *args, **kwargs):
     if get_protected_namespace(request):
         return _csrf_failure(request, *args, **kwargs)
     else:
         return f(request, *args, **kwargs)
Exemple #8
0
 def decorator(request, *args, **kwargs):
     if get_protected_namespace(request):
         update_admin_session(request)
         return _error_page(request, *args, **kwargs)
     else:
         return f(request, *args, **kwargs)