From ded6f8e8f0e7342990e0a673840127d5ac77abaf Mon Sep 17 00:00:00 2001 From: Jakub Urban Date: Mon, 29 Aug 2022 12:46:41 +0200 Subject: [PATCH] Add tests for multiple auth identities --- .../auth/test_multiple_auth_identities.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 testsuite/tests/kuadrant/authorino/identity/auth/test_multiple_auth_identities.py diff --git a/testsuite/tests/kuadrant/authorino/identity/auth/test_multiple_auth_identities.py b/testsuite/tests/kuadrant/authorino/identity/auth/test_multiple_auth_identities.py new file mode 100644 index 00000000..9c5e7d5d --- /dev/null +++ b/testsuite/tests/kuadrant/authorino/identity/auth/test_multiple_auth_identities.py @@ -0,0 +1,35 @@ +""" +Tests for multiple auth identities (RHSSO + Auth0) +""" + +import pytest + + +# pylint: disable=unused-argument +@pytest.fixture(scope="module") +def client(auth0_authorization, rhsso_authorization, envoy): + """Returns httpx client to be used for requests, it also commits AuthConfig""" + client = envoy.client() + yield client + client.close() + + +def test_correct_auth(client, auth, auth0_auth): + """Tests correct auth""" + response = client.get("/get", auth=auth) + assert response.status_code == 200 + + response = client.get("/get", auth=auth0_auth) + assert response.status_code == 200 + + +def test_no_auth(client, request): + """Tests request without any auth""" + response = client.get("/get") + assert response.status_code == 401 + + +def test_wrong_auth(client, request): + """Tests request with wrong token""" + response = client.get("/get", headers={"Authorization": "Bearer xyz"}) + assert response.status_code == 401