-
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 #50 from JaurbanRH/wildcard
Add tests for wildcard hosts
- Loading branch information
Showing
6 changed files
with
93 additions
and
11 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
48 changes: 48 additions & 0 deletions
48
testsuite/tests/kuadrant/authorino/operator/clusterwide/test_wildcard_collision.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,48 @@ | ||
""" | ||
Test for wildcard collisions with clusterwide authorino | ||
""" | ||
|
||
import pytest | ||
|
||
from testsuite.openshift.objects.auth_config import AuthConfig | ||
|
||
|
||
# pylint: disable = unused-argument | ||
@pytest.fixture(scope="module") | ||
def authorization(authorino, blame, openshift, module_label, envoy, wildcard_domain): | ||
"""In case of Authorino, AuthConfig used for authorization""" | ||
auth = AuthConfig.create_instance(openshift, blame("ac"), wildcard_domain, labels={"testRun": module_label}) | ||
auth.add_response({"name": "header", "json": {"properties": [{"name": "anything", "value": "one"}]}}) | ||
return auth | ||
|
||
|
||
# pylint: disable = unused-argument | ||
@pytest.fixture(scope="module") | ||
def authorization2(authorino, blame, openshift2, module_label, envoy, wildcard_domain): | ||
"""In case of Authorino, AuthConfig used for authorization""" | ||
auth = AuthConfig.create_instance(openshift2, blame("ac"), wildcard_domain, labels={"testRun": module_label}) | ||
auth.add_response({"name": "header", "json": {"properties": [{"name": "anything", "value": "two"}]}}) | ||
return auth | ||
|
||
|
||
@pytest.mark.parametrize(("client_fixture", "auth_fixture", "hosts"), [ | ||
pytest.param("client", "authorization", "wildcard_domain", id="First namespace"), | ||
pytest.param("client2", "authorization2", [], id="Second namespace"), | ||
]) | ||
def test_wildcard_collision(client_fixture, auth_fixture, hosts, request): | ||
""" | ||
Preparation: | ||
- Create AuthConfig with host set to wildcard_domain | ||
- Create AuthConfig with host set to wildcard_domain in another project | ||
Test: | ||
- Send request to authorino | ||
- Assert that the correct AuthConfig was used | ||
""" | ||
if hosts: | ||
hosts = [request.getfixturevalue(hosts)] | ||
client = request.getfixturevalue(client_fixture) | ||
response = client.get("/get") | ||
assert response.status_code == 200 | ||
assert response.json()["headers"]["Header"] == '{"anything":"one"}' | ||
authorization = request.getfixturevalue(auth_fixture) | ||
assert authorization.model.status.summary.hostsReady == hosts |
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
25 changes: 25 additions & 0 deletions
25
testsuite/tests/kuadrant/authorino/operator/test_wildcard.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,25 @@ | ||
""" | ||
Test for wildcard host | ||
""" | ||
import pytest | ||
|
||
from testsuite.openshift.objects.auth_config import AuthConfig | ||
|
||
|
||
# pylint: disable = unused-argument | ||
@pytest.fixture(scope="module") | ||
def authorization(authorino, blame, openshift, module_label): | ||
"""In case of Authorino, AuthConfig used for authorization""" | ||
return AuthConfig.create_instance(openshift, blame("ac"), "*.redhat.com", labels={"testRun": module_label}) | ||
|
||
|
||
def test_wildcard(client): | ||
""" | ||
Preparation: | ||
- Create AuthConfig with host set to `*.redhat.com` | ||
Test: | ||
- Send request to authorino | ||
- Assert that request was successful | ||
""" | ||
response = client.get("/get") | ||
assert response.status_code == 200 |
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