Ejemplo n.º 1
0
 def test_public(self):
     users.get_user_from_request = self._real_get_user_from_request
     settings = horizon.get_dashboard("settings")
     # Known to have no restrictions on it other than being logged in.
     user_panel = settings.get_panel("user")
     url = user_panel.get_absolute_url()
     # Get a clean, logged out client instance.
     client = Client()
     client.logout()
     resp = client.get(url)
     self.assertRedirectsNoFollow(resp, '/accounts/login/?next=/settings/')
Ejemplo n.º 2
0
 def test_public(self):
     users.get_user_from_request = self._real_get_user_from_request
     settings = horizon.get_dashboard("settings")
     # Known to have no restrictions on it other than being logged in.
     user_panel = settings.get_panel("user")
     url = user_panel.get_absolute_url()
     # Get a clean, logged out client instance.
     client = Client()
     client.logout()
     resp = client.get(url)
     redirect_url = "?".join([urlresolvers.reverse("horizon:auth_login"), "next=%s" % url])
     self.assertRedirectsNoFollow(resp, redirect_url)
     # Simulate ajax call
     resp = client.get(url, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
     # Response should be HTTP 401 with redirect header
     self.assertEquals(resp.status_code, 401)
     self.assertEquals(
         resp["X-Horizon-Location"], "?".join([urlresolvers.reverse("horizon:auth_login"), "next=%s" % url])
     )
Ejemplo n.º 3
0
 def test_public(self):
     users.get_user_from_request = self._real_get_user_from_request
     settings = horizon.get_dashboard("settings")
     # Known to have no restrictions on it other than being logged in.
     user_panel = settings.get_panel("user")
     url = user_panel.get_absolute_url()
     # Get a clean, logged out client instance.
     client = Client()
     client.logout()
     resp = client.get(url)
     redirect_url = "?".join(
         [urlresolvers.reverse("horizon:auth_login"),
          "next=%s" % url])
     self.assertRedirectsNoFollow(resp, redirect_url)
     # Simulate ajax call
     resp = client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     # Response should be HTTP 401 with redirect header
     self.assertEquals(resp.status_code, 401)
     self.assertEquals(
         resp["X-Horizon-Location"], "?".join(
             [urlresolvers.reverse("horizon:auth_login"),
              "next=%s" % url]))