コード例 #1
0
ファイル: tests.py プロジェクト: josben77/weblate
 def test_protect_project(self):
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     request.user = User()
     request.META['SERVER_NAME'] = 'server'
     request.META['SERVER_PORT'] = '80'
     # No protection for not protected path
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )
     request.path = '/project/foo/'
     # No protection for protected path and logged in user
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )
     # Protection for protected path and not logged in user
     request.user = AnonymousUser()
     self.assertIsInstance(
         middleware.process_view(request, self.view_method, (), {}),
         HttpResponseRedirect
     )
     # No protection for login and not logged in user
     request.path = '/accounts/login/'
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )
コード例 #2
0
ファイル: test_middleware.py プロジェクト: nrasic/weblate
 def test_protect_project(self):
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     request.user = User()
     request.META["SERVER_NAME"] = "server"
     request.META["SERVER_PORT"] = "80"
     # No protection for not protected path
     self.assertIsNone(middleware.process_view(request, self.view_method, (), {}))
     request.path = "/project/foo/"
     # No protection for protected path and logged in user
     self.assertIsNone(middleware.process_view(request, self.view_method, (), {}))
     # Protection for protected path and not logged in user
     # pylint: disable=R0204
     request.user = AnonymousUser()
     self.assertIsInstance(middleware.process_view(request, self.view_method, (), {}), HttpResponseRedirect)
     # No protection for login and not logged in user
     request.path = "/accounts/login/"
     self.assertIsNone(middleware.process_view(request, self.view_method, (), {}))
コード例 #3
0
 def test_protect_project(self):
     settings.LOGIN_REQUIRED_URLS = (
         r'/project/(.*)$',
     )
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     request.user = User()
     request.META['SERVER_NAME'] = 'server'
     request.META['SERVER_PORT'] = '80'
     # No protection for not protected path
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )
     request.path = '/project/foo/'
     # No protection for protected path and logged in user
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )
     # Protection for protected path and not logged in user
     request.user = AnonymousUser()
     self.assertIsInstance(
         middleware.process_view(request, self.view_method, (), {}),
         HttpResponseRedirect
     )
     # No protection for login and not logged in user
     request.path = '/accounts/login/'
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )
コード例 #4
0
ファイル: test_middleware.py プロジェクト: renatofb/weblate
 def test_protect_project(self):
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     request.user = User()
     request.META["SERVER_NAME"] = "testserver"
     request.META["SERVER_PORT"] = "80"
     # No protection for not protected path
     self.assertIsNone(middleware.process_view(request, self.view_method, (), {}))
     request.path = "/project/foo/"
     # No protection for protected path and signed in user
     self.assertIsNone(middleware.process_view(request, self.view_method, (), {}))
     # Protection for protected path and not signed in user
     request.user = get_anonymous()
     self.assertIsInstance(
         middleware.process_view(request, self.view_method, (), {}),
         HttpResponseRedirect,
     )
     # No protection for login and not signed in user
     request.path = "/accounts/login/"
     self.assertIsNone(middleware.process_view(request, self.view_method, (), {}))
コード例 #5
0
 def test_protect_project(self):
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     request.user = User()
     request.META['SERVER_NAME'] = 'testserver'
     request.META['SERVER_PORT'] = '80'
     # No protection for not protected path
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {}))
     request.path = '/project/foo/'
     # No protection for protected path and logged in user
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {}))
     # Protection for protected path and not logged in user
     # pylint: disable=R0204
     request.user = AnonymousUser()
     self.assertIsInstance(
         middleware.process_view(request, self.view_method, (), {}),
         HttpResponseRedirect)
     # No protection for login and not logged in user
     request.path = '/accounts/login/'
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {}))
コード例 #6
0
ファイル: tests.py プロジェクト: phewcentral/weblate
 def test_disabled(self):
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {}))
コード例 #7
0
ファイル: tests.py プロジェクト: josben77/weblate
 def test_disabled(self):
     middleware = RequireLoginMiddleware()
     request = HttpRequest()
     self.assertIsNone(
         middleware.process_view(request, self.view_method, (), {})
     )