def test_has_guest_access__unauthorized_guest_user__different_resource_id(self): g.user = security_manager.get_guest_user_from_token( { "user": {}, "resources": [{"type": "dashboard", "id": "not-a-real-id"}], } ) has_guest_access = security_manager.has_guest_access(self.dash) self.assertFalse(has_guest_access)
def test_has_guest_access__authorized_guest_user__non_zero_resource_index(self): # set up a user who has authorized access, plus another resource guest = self.authorized_guest guest.resources = [ {"type": "dashboard", "id": "not-a-real-id"} ] + guest.resources g.user = guest has_guest_access = security_manager.has_guest_access(self.dash) self.assertTrue(has_guest_access)
def test_has_guest_access__unauthorized_guest_user__different_resource_type( self): g.user = security_manager.get_guest_user_from_token({ "user": {}, "resources": [{ "type": "dirt", "id": self.resource_id }] }) has_guest_access = security_manager.has_guest_access( GuestTokenResourceType.DASHBOARD, self.resource_id) self.assertFalse(has_guest_access)
def test_has_guest_access__authorized_guest_user__non_zero_resource_index( self): guest = self.authorized_guest() guest.resources = [{ "type": "dashboard", "id": self.resource_id - 1 }] + guest.resources g.user = guest has_guest_access = security_manager.has_guest_access( GuestTokenResourceType.DASHBOARD, self.resource_id) self.assertTrue(has_guest_access)
def test_has_guest_access__anonymous_user(self): g.user = security_manager.get_anonymous_user() has_guest_access = security_manager.has_guest_access( GuestTokenResourceType.DASHBOARD, self.resource_id) self.assertFalse(has_guest_access)
def test_has_guest_access__regular_user(self): g.user = security_manager.find_user("admin") has_guest_access = security_manager.has_guest_access( GuestTokenResourceType.DASHBOARD, self.resource_id) self.assertFalse(has_guest_access)
def test_has_guest_access__authorized_guest_user(self): g.user = self.authorized_guest() has_guest_access = security_manager.has_guest_access( GuestTokenResourceType.DASHBOARD, self.resource_id) self.assertTrue(has_guest_access)
def test_has_guest_access__unauthorized_guest_user__different_resource_type(self): g.user = security_manager.get_guest_user_from_token( {"user": {}, "resources": [{"type": "dirt", "id": self.embedded.uuid}]} ) has_guest_access = security_manager.has_guest_access(self.dash) self.assertFalse(has_guest_access)
def test_has_guest_access__authorized_guest_user(self): g.user = self.authorized_guest has_guest_access = security_manager.has_guest_access(self.dash) self.assertTrue(has_guest_access)
def test_has_guest_access__anonymous_user(self): g.user = security_manager.get_anonymous_user() has_guest_access = security_manager.has_guest_access(self.dash) self.assertFalse(has_guest_access)
def test_has_guest_access__regular_user(self): g.user = security_manager.find_user("admin") has_guest_access = security_manager.has_guest_access(self.dash) self.assertFalse(has_guest_access)