Exemplo n.º 1
0
class SentryAppInstallationPermissionTest(TestCase):
    def setUp(self):
        self.permission = SentryAppInstallationPermission()

        self.user = self.create_user()
        self.member = self.create_user()
        self.org = self.create_organization(owner=self.member)

        self.sentry_app = self.create_sentry_app(name="foo",
                                                 organization=self.org)

        self.installation = self.create_sentry_app_installation(
            slug=self.sentry_app.slug, organization=self.org, user=self.user)

        self.request = self.make_request(user=self.user, method="GET")

    def test_missing_request_user(self):
        self.request.user = None

        assert not self.permission.has_object_permission(
            self.request, None, self.installation)

    def test_request_user_in_organization(self):
        self.request = self.make_request(user=self.member, method="GET")

        assert self.permission.has_object_permission(self.request, None,
                                                     self.installation)

    def test_request_user_not_in_organization(self):
        with self.assertRaises(Http404):
            self.permission.has_object_permission(self.request, None,
                                                  self.installation)
Exemplo n.º 2
0
    def setUp(self):
        self.permission = SentryAppInstallationPermission()

        self.user = self.create_user()
        self.member = self.create_user()
        self.org = self.create_organization(owner=self.member)

        self.sentry_app = self.create_sentry_app(name="foo",
                                                 organization=self.org)

        self.installation = self.create_sentry_app_installation(
            slug=self.sentry_app.slug, organization=self.org, user=self.user)

        self.request = self.make_request(user=self.user, method="GET")
Exemplo n.º 3
0
class SentryAppInstallationPermissionTest(TestCase):
    def setUp(self):
        self.permission = SentryAppInstallationPermission()

        self.user = self.create_user()
        self.member = self.create_user()
        self.org = self.create_organization(owner=self.member)

        self.sentry_app = self.create_sentry_app(
            name='foo',
            organization=self.org,
        )

        self.installation = sentry_app_installations.Creator.run(
            slug=self.sentry_app.slug,
            organization=self.org,
            user=self.user,
        )

        self.request = self.make_request(user=self.user, method='GET')

    def test_missing_request_user(self):
        self.request.user = None

        assert not self.permission.has_object_permission(
            self.request,
            None,
            self.installation,
        )

    def test_request_user_in_organization(self):
        self.request = self.make_request(user=self.member, method='GET')

        assert self.permission.has_object_permission(
            self.request,
            None,
            self.installation,
        )

    def test_request_user_not_in_organization(self):
        with self.assertRaises(Http404):
            self.permission.has_object_permission(
                self.request,
                None,
                self.installation,
            )
Exemplo n.º 4
0
    def setUp(self):
        self.permission = SentryAppInstallationPermission()

        self.user = self.create_user()
        self.member = self.create_user()
        self.org = self.create_organization(owner=self.member)

        self.sentry_app = self.create_sentry_app(
            name='foo',
            organization=self.org,
        )

        self.installation, _ = SentryAppInstallationCreator.run(
            slug=self.sentry_app.slug,
            organization=self.org,
        )

        self.request = self.make_request(user=self.user, method='GET')
Exemplo n.º 5
0
    def setUp(self):
        self.permission = SentryAppInstallationPermission()

        self.user = self.create_user()
        self.member = self.create_user()
        self.org = self.create_organization(owner=self.member)

        self.sentry_app = self.create_sentry_app(
            name='foo',
            organization=self.org,
        )

        self.installation = sentry_app_installations.Creator.run(
            slug=self.sentry_app.slug,
            organization=self.org,
            user=self.user,
        )

        self.request = self.make_request(user=self.user, method='GET')