class SentryAppPermissionTest(TestCase): def setUp(self): self.permission = SentryAppPermission() self.user = self.create_user() self.org = self.create_organization(owner=self.user) self.sentry_app = self.create_sentry_app( name='foo', organization=self.org, ) self.request = self.make_request(user=self.user, method='GET') def test_request_user_is_app_owner_succeeds(self): assert self.permission.has_object_permission(self.request, None, self.sentry_app) def test_request_user_is_not_app_owner_fails(self): self.request.user = self.create_user() with self.assertRaises(Http404): self.permission.has_object_permission(self.request, None, self.sentry_app) def test_has_permission(self): from sentry.models import ApiToken token = ApiToken.objects.create(user=self.user, scope_list=['event:read', 'org:read']) self.request = self.make_request(user=None, auth=token, method='GET') assert self.permission.has_permission(self.request, None)
def setUp(self): self.permission = SentryAppPermission() self.user = self.create_user() self.org = self.create_organization(owner=self.user) self.sentry_app = self.create_sentry_app(name="foo", organization=self.org) self.request = self.make_request(user=self.user, method="GET")
def setUp(self): self.permission = SentryAppPermission() self.user = self.create_user() self.org = self.create_organization(owner=self.user) self.sentry_app = self.create_sentry_app( name='foo', organization=self.org, ) self.request = self.make_request(user=self.user, method='GET')
class SentryAppPermissionTest(TestCase): def setUp(self): self.permission = SentryAppPermission() self.user = self.create_user() self.org = self.create_organization(owner=self.user) self.sentry_app = self.create_sentry_app( name='foo', organization=self.org, ) self.request = self.make_request(user=self.user, method='GET') def test_request_user_is_app_owner_succeeds(self): assert self.permission.has_object_permission(self.request, None, self.sentry_app) def test_request_user_is_not_app_owner_fails(self): self.request.user = self.create_user() with self.assertRaises(Http404): self.permission.has_object_permission(self.request, None, self.sentry_app)