forked from Kuadrant/testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
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 Kuadrant#37 from pehala/rhsso_default
Use RHSSO identity by default
- Loading branch information
Showing
10 changed files
with
108 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Conftest for all Identity tests""" | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def authorization(authorization): | ||
"""For Identity tests remove all identities previously setup""" | ||
authorization.remove_all_identities() | ||
return authorization |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
64 changes: 64 additions & 0 deletions
64
testsuite/tests/kuadrant/authorino/operator/test_sharding.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,64 @@ | ||
"""Test for authorino sharding""" | ||
import pytest | ||
|
||
from testsuite.openshift.httpbin import Envoy | ||
from testsuite.openshift.objects.auth_config import AuthConfig | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def authorino_parameters(authorino_parameters): | ||
"""Setup TLS for authorino""" | ||
authorino_parameters["label_selectors"] = ["sharding=true"] | ||
yield authorino_parameters | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def envoy(request, authorino, openshift, blame, backend, label): | ||
"""Envoy""" | ||
|
||
def _envoy(): | ||
envoy = Envoy(openshift, authorino, blame("envoy"), label, backend.url) | ||
request.addfinalizer(envoy.delete) | ||
envoy.commit() | ||
return envoy | ||
|
||
return _envoy | ||
|
||
|
||
# pylint: disable=unused-argument | ||
@pytest.fixture(scope="module") | ||
def authorization(request, authorino, blame, openshift, label): | ||
"""In case of Authorino, AuthConfig used for authorization""" | ||
|
||
def _authorization(envoy, sharding): | ||
auth = AuthConfig.create_instance(openshift, blame("ac"), envoy.hostname, | ||
labels={"testRun": label, "sharding": sharding}) | ||
request.addfinalizer(auth.delete) | ||
auth.commit() | ||
return auth | ||
|
||
return _authorization | ||
|
||
|
||
def test_sharding(authorization, envoy): | ||
""" | ||
Setup: | ||
- Create Authorino that watch only AuthConfigs with label `sharding=true` | ||
Test: | ||
- Create AuthConfig with `sharding=true` label | ||
- Create AuthConfig with `sharding=false` label | ||
- Send a request to the first AuthConfig | ||
- Assert that the response status code is 200 | ||
- Send a request to the second AuthConfig | ||
- Assert that the response status code is 404 | ||
""" | ||
envoy1 = envoy() | ||
envoy2 = envoy() | ||
authorization(envoy1, "true") | ||
authorization(envoy2, "false") | ||
|
||
response = envoy1.client().get("/get") | ||
assert response.status_code == 200 | ||
|
||
response = envoy2.client().get("/get") | ||
assert response.status_code == 404 |