def test_hierarchy(self): """ Because there is no installed scrooge, always show core user with scrooge perms -> show core user with core perms -> show core For asset perms: user with asset perms -> show core """ test_data = [ Perm.has_scrooge_access, Perm.has_assets_access, Perm.has_core_access, ] for perm in test_data: user = self._get_user_by_perm(perm) self.client = login_as_user(user) response = self.client.get( self.success_login_url, follow=True, **self.request_headers ) if perm == Perm.has_assets_access: self.assertEqual( response.request['PATH_INFO'], reverse('asset_search', args=('dc',)), ) else: self.assertEqual( response.request['PATH_INFO'], reverse('search', args=('info', '')), )
def test_user_has_no_access(self): no_access_user = UserFactory( is_staff=False, is_superuser=False, ) no_access_user.get_profile().boundperm_set.all().delete() client = login_as_user(no_access_user) response = client.get(self.assets_module_url, follow=True) self.assertEqual(response.status_code, 403)
def check_redirection(self, hierarchy_data): for perm, home_url in hierarchy_data: user = self._get_user_by_perm(perm) self.client = login_as_user(user) response = self.client.get( self.success_login_url, follow=True, **self.request_headers ) self.assertEqual(response.request['PATH_INFO'], home_url)
def test_user_with_bound_perms_has_access(self): user_with_access = UserFactory( is_staff=False, is_superuser=False, ) BoundPerm( profile=user_with_access.get_profile(), perm=Perm.has_assets_access, ).save() client = login_as_user(user_with_access) response = client.get(self.assets_module_url, follow=True) self.assertEqual(response.status_code, 200)
def test_user_no_perms(self): """user without perms -> show 403""" no_access_user = UserFactory( is_staff=False, is_superuser=False, ) self.client = login_as_user(no_access_user) response = self.client.get( self.success_login_url, follow=True, **self.request_headers ) self.assertEqual(response.status_code, 403)
def test_hierarchy(self): """ Because there is no installed scrooge, always show core user with scrooge perms -> show core user with core perms -> show core For asset perms: user with asset perms -> show core """ test_data = [Perm.has_scrooge_access, Perm.has_assets_access, Perm.has_core_access] for perm in test_data: user = self._get_user_by_perm(perm) self.client = login_as_user(user) response = self.client.get(self.success_login_url, follow=True, **self.request_headers) if perm == Perm.has_assets_access: self.assertEqual(response.request["PATH_INFO"], reverse("asset_search", args=("dc",))) else: self.assertEqual(response.request["PATH_INFO"], reverse("search", args=("info", "")))
def test_hierarchy(self): """ Because there is no installed scrooge or assets, always show core user with scrooge perms -> show core user with asset perms -> show core user with core perms -> show core """ test_data = [ Perm.has_scrooge_access, Perm.has_assets_access, Perm.has_core_access, ] for perm in test_data: user = self._get_user_by_perm(perm) self.client = login_as_user(user) response = self.client.get( self.success_login_url, follow=True, **self.request_headers ) self.assertEqual( response.request['PATH_INFO'], reverse('search', args=('info', '')), )
def setUp(self): user = UserFactory(is_superuser=True) self.client = login_as_user(user)