diff --git a/testsuite/tests/kuadrant/authorino/conditions/section_conditions/test_response_condition.py b/testsuite/tests/kuadrant/authorino/conditions/section_conditions/test_response_condition.py index 61f384b1..05574df2 100644 --- a/testsuite/tests/kuadrant/authorino/conditions/section_conditions/test_response_condition.py +++ b/testsuite/tests/kuadrant/authorino/conditions/section_conditions/test_response_condition.py @@ -1,23 +1,15 @@ """Test condition to skip the response section of AuthConfig""" import pytest -from testsuite.objects import Rule +from testsuite.objects import Property, Rule from testsuite.utils import extract_response @pytest.fixture(scope="module") def authorization(authorization): """Add to the AuthConfig response, which will only trigger on POST requests""" - authorization.responses.add( - { - "name": "simple", - "json": { - "properties": [ - {"name": "data", "value": "response"}, - ] - }, - }, - when=[Rule("context.request.http.method", "eq", "POST")], + authorization.responses.json( + "simple", [Property("data", value="response")], when=[Rule("context.request.http.method", "eq", "POST")] ) return authorization diff --git a/testsuite/tests/kuadrant/authorino/identity/rhsso/test_rhsso_context.py b/testsuite/tests/kuadrant/authorino/identity/rhsso/test_rhsso_context.py index f1b2065f..bf9ee631 100644 --- a/testsuite/tests/kuadrant/authorino/identity/rhsso/test_rhsso_context.py +++ b/testsuite/tests/kuadrant/authorino/identity/rhsso/test_rhsso_context.py @@ -4,20 +4,18 @@ import pytest +from testsuite.objects import Property + @pytest.fixture(scope="module") def authorization(authorization): """Setup AuthConfig for test""" - authorization.responses.add( - { - "name": "auth-json", - "json": { - "properties": [ - {"name": "auth", "valueFrom": {"authJSON": "auth.identity"}}, - {"name": "context", "valueFrom": {"authJSON": "context.request.http.headers.authorization"}}, - ] - }, - } + authorization.responses.json( + "auth-json", + [ + Property("auth", jsonPath="auth.identity"), + Property("context", jsonPath="context.request.http.headers.authorization"), + ], ) return authorization diff --git a/testsuite/tests/kuadrant/authorino/operator/clusterwide/test_wildcard_collision.py b/testsuite/tests/kuadrant/authorino/operator/clusterwide/test_wildcard_collision.py index db274faa..a1d004e9 100644 --- a/testsuite/tests/kuadrant/authorino/operator/clusterwide/test_wildcard_collision.py +++ b/testsuite/tests/kuadrant/authorino/operator/clusterwide/test_wildcard_collision.py @@ -4,6 +4,7 @@ import pytest +from testsuite.objects import Property from testsuite.openshift.objects.auth_config import AuthConfig @@ -14,7 +15,7 @@ def authorization(authorino, blame, openshift, module_label, envoy, wildcard_dom auth = AuthConfig.create_instance( openshift, blame("ac"), None, hostnames=[wildcard_domain], labels={"testRun": module_label} ) - auth.responses.add({"name": "header", "json": {"properties": [{"name": "anything", "value": "one"}]}}) + auth.responses.json("header", [Property("anything", value="one")]) return auth @@ -25,7 +26,7 @@ def authorization2(authorino, blame, openshift2, module_label, envoy, wildcard_d auth = AuthConfig.create_instance( openshift2, blame("ac"), None, hostnames=[wildcard_domain], labels={"testRun": module_label} ) - auth.responses.add({"name": "header", "json": {"properties": [{"name": "anything", "value": "two"}]}}) + auth.responses.json("header", [Property("anything", value="two")]) return auth diff --git a/testsuite/tests/kuadrant/authorino/operator/http/conftest.py b/testsuite/tests/kuadrant/authorino/operator/http/conftest.py index 045f53c7..54c4b608 100644 --- a/testsuite/tests/kuadrant/authorino/operator/http/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/http/conftest.py @@ -1,7 +1,7 @@ """Conftest for all tests requiring custom deployment of Authorino""" import pytest -from testsuite.objects import Authorization +from testsuite.objects import Authorization, Property from testsuite.httpx import HttpxBackoffClient @@ -11,12 +11,9 @@ def authorization(authorization, wildcard_domain, openshift, module_label) -> Au """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.responses.add(response=resp) + authorization.responses.json( + "another-json-returned-in-a-header", [Property("propX", value="valueX")], wrapper_key="x-ext-auth-other-json" + ) return authorization diff --git a/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py b/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py index f4d9d129..c09ecf5c 100644 --- a/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py +++ b/testsuite/tests/kuadrant/authorino/operator/sharding/conftest.py @@ -1,6 +1,7 @@ """Conftest for authorino sharding tests""" import pytest +from testsuite.objects import Property from testsuite.openshift.envoy import Envoy from testsuite.openshift.objects.auth_config import AuthConfig @@ -31,7 +32,7 @@ def _authorization(hostname=None, sharding_label=None): hostnames=[hostname], labels={"testRun": module_label, "sharding": sharding_label}, ) - auth.responses.add({"name": "header", "json": {"properties": [{"name": "anything", "value": sharding_label}]}}) + auth.responses.json("header", [Property("anything", value=sharding_label)]) request.addfinalizer(auth.delete) auth.commit() return auth diff --git a/testsuite/tests/kuadrant/authorino/wristband/conftest.py b/testsuite/tests/kuadrant/authorino/wristband/conftest.py index 99699870..b963af13 100644 --- a/testsuite/tests/kuadrant/authorino/wristband/conftest.py +++ b/testsuite/tests/kuadrant/authorino/wristband/conftest.py @@ -63,22 +63,7 @@ def wristband_endpoint(openshift, authorino, authorization_name): @pytest.fixture(scope="module") def authorization(authorization, wristband_secret, wristband_endpoint) -> Authorization: """Add wristband response with the signing key to the AuthConfig""" - authorization.responses.add( - { - "name": "wristband", - "wrapper": "envoyDynamicMetadata", - "wristband": { - "issuer": wristband_endpoint, - "tokenDuration": 300, # default value - "signingKeyRefs": [ - { - "name": wristband_secret, - "algorithm": "RS256", - } - ], - }, - } - ) + authorization.responses.wristband("wristband", wristband_endpoint, wristband_secret, wrapper="envoyDynamicMetadata") return authorization