-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from mkudlej/raw_http
Add raw http test with response with adding extra header
- Loading branch information
Showing
5 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
37 changes: 37 additions & 0 deletions
37
testsuite/tests/kuadrant/authorino/operator/http/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Conftest for all tests requiring custom deployment of Authorino""" | ||
import pytest | ||
|
||
from testsuite.objects import Authorization | ||
from testsuite.httpx import HttpxBackoffClient | ||
|
||
|
||
# pylint: disable=unused-argument | ||
@pytest.fixture(scope="module") | ||
def authorization(authorization, wildcard_domain, openshift, rhsso_service_info, module_label) -> Authorization: | ||
"""In case of Authorino, AuthConfig used for authorization""" | ||
authorization.remove_all_hosts() | ||
authorization.add_host(wildcard_domain) | ||
resp = {'name': 'another-json-returned-in-a-header', | ||
'wrapperKey': 'x-ext-auth-other-json', | ||
'json': {'properties': [ | ||
{'name': 'propX', 'value': 'valueX'} | ||
]}} | ||
authorization.add_response(response=resp) | ||
return authorization | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def client(authorization, authorino_route): | ||
"""Returns httpx client to be used for requests, it also commits AuthConfig""" | ||
client = HttpxBackoffClient(base_url=f"http://{authorino_route.model.spec.host}", verify=False) | ||
yield client | ||
client.close() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def authorino_route(authorino, blame, openshift): | ||
"""Add route for authorino http port to be able to access it.""" | ||
route = openshift.routes.expose(blame('route'), f"{authorino.name()}-authorino-authorization", | ||
port='http') | ||
yield route | ||
route.delete() |
20 changes: 20 additions & 0 deletions
20
testsuite/tests/kuadrant/authorino/operator/http/test_raw_http.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Test raw http authorization interface. | ||
""" | ||
|
||
|
||
# pylint: disable=unused-argument | ||
def test_authorized_via_http(authorization, client, auth): | ||
"""Test raw http authentization with Keycloak.""" | ||
response = client.get("/check", auth=auth) | ||
assert response.status_code == 200 | ||
assert response.text == '' | ||
assert response.headers.get('x-ext-auth-other-json', '') == '{"propX":"valueX"}' | ||
|
||
|
||
# pylint: disable=unused-argument | ||
def test_unauthorized_via_http(authorization, client): | ||
"""Test raw http authentization with unauthorized request.""" | ||
response = client.get("/check") | ||
assert response.status_code == 401 | ||
assert response.text == '' |