Beispiel #1
0
class TestClientIdSecretAuthentication(TestCase):
    def setUp(self):
        super(TestClientIdSecretAuthentication, self).setUp()

        self.auth = ClientIdSecretAuthentication()
        self.org = self.create_organization(owner=self.user)

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

        self.api_app = self.sentry_app.application

    def test_authenticate(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': self.api_app.client_id,
            'client_secret': self.api_app.client_secret,
        }

        user, _ = self.auth.authenticate(request)

        assert user == self.sentry_app.proxy_user

    def test_without_json_body(self):
        request = HttpRequest()
        request.json_body = None

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_missing_client_id(self):
        request = HttpRequest()
        request.json_body = {
            'client_secret': self.api_app.client_secret,
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_missing_client_secret(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': self.api_app.client_id,
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_incorrect_client_id(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': 'notit',
            'client_secret': self.api_app.client_secret,
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_incorrect_client_secret(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': self.api_app.client_id,
            'client_secret': 'notit',
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)
Beispiel #2
0
class TestClientIdSecretAuthentication(TestCase):
    def setUp(self):
        super(TestClientIdSecretAuthentication, self).setUp()

        self.auth = ClientIdSecretAuthentication()
        self.org = self.create_organization(owner=self.user)

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

        self.api_app = self.sentry_app.application

    def test_authenticate(self):
        request = HttpRequest()
        request.json_body = {
            "client_id": self.api_app.client_id,
            "client_secret": self.api_app.client_secret,
        }

        user, _ = self.auth.authenticate(request)

        assert user == self.sentry_app.proxy_user

    def test_without_json_body(self):
        request = HttpRequest()
        request.json_body = None

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_missing_client_id(self):
        request = HttpRequest()
        request.json_body = {"client_secret": self.api_app.client_secret}

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_missing_client_secret(self):
        request = HttpRequest()
        request.json_body = {"client_id": self.api_app.client_id}

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_incorrect_client_id(self):
        request = HttpRequest()
        request.json_body = {
            "client_id": "notit",
            "client_secret": self.api_app.client_secret
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_incorrect_client_secret(self):
        request = HttpRequest()
        request.json_body = {
            "client_id": self.api_app.client_id,
            "client_secret": "notit"
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)
Beispiel #3
0
class TestClientIdSecretAuthentication(TestCase):
    def setUp(self):
        super(TestClientIdSecretAuthentication, self).setUp()

        self.auth = ClientIdSecretAuthentication()

        self.sentry_app = Creator.run(
            name="foo",
            user=self.user,
            scopes=(),
            webhook_url='https://example.com',
        )

        self.api_app = self.sentry_app.application

    def test_authenticate(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': self.api_app.client_id,
            'client_secret': self.api_app.client_secret,
        }

        user, _ = self.auth.authenticate(request)

        assert user == self.sentry_app.proxy_user

    def test_without_json_body(self):
        request = HttpRequest()
        request.json_body = None

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_missing_client_id(self):
        request = HttpRequest()
        request.json_body = {
            'client_secret': self.api_app.client_secret,
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_missing_client_secret(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': self.api_app.client_id,
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_incorrect_client_id(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': 'notit',
            'client_secret': self.api_app.client_secret,
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)

    def test_incorrect_client_secret(self):
        request = HttpRequest()
        request.json_body = {
            'client_id': self.api_app.client_id,
            'client_secret': 'notit',
        }

        with self.assertRaises(AuthenticationFailed):
            self.auth.authenticate(request)