From bf3b556263b9781db852de583f71e09c8e329e2b Mon Sep 17 00:00:00 2001 From: Alex Zgabur Date: Thu, 2 Nov 2023 18:28:43 +0100 Subject: [PATCH] Authpolicy upgrade to v2 dynamic envoy --- .../openshift/objects/auth_config/sections.py | 28 ++++++++++++++----- .../kuadrant/authorino/wristband/conftest.py | 4 +-- .../authorino/wristband/test_wristband.py | 3 -- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/testsuite/openshift/objects/auth_config/sections.py b/testsuite/openshift/objects/auth_config/sections.py index ff2344a9..1daa042f 100644 --- a/testsuite/openshift/objects/auth_config/sections.py +++ b/testsuite/openshift/objects/auth_config/sections.py @@ -197,27 +197,41 @@ def add_uma(self, name, endpoint, credentials_secret, **common_features): class ResponseSection(Section): - """Section which contains response configuration. todo envoyDynamicMetadata""" + """Section which contains response configuration.""" @property - def success_headers(self): - """Nested dict for most of the section.""" - return self.section.setdefault("success", {}).setdefault("headers", {}) + def success(self): + """Nested dict for success dictionary.""" + return self.section.setdefault("success", {}) @modify - def clear_success_headers(self): - """Clears content of a success headers""" + def clear_success(self): + """Clears content of a success dictionary.""" self.success_headers.clear() + @property + def success_headers(self): + """Nested dict for items wrapped as HTTP headers.""" + return self.success.setdefault("headers", {}) + + @property + def success_dynamic_metadata(self): + """Nested dict for items wrapped as Envoy Dynamic Metadata.""" + return self.success.setdefault("dynamicMetadata", {}) + def _add( self, name: str, value: dict, + wrapper: Literal["headers", "dynamicMetadata"] = "headers", **common_features, ): """Add response to AuthConfig""" add_common_features(value, **common_features) - self.success_headers.update({name: value}) + if wrapper == "headers": + self.success_headers.update({name: value}) + if wrapper == "dynamicMetadata": + self.success_dynamic_metadata.update({name: value}) def add_simple(self, auth_json: str, name="simple", key="data", **common_features): """ diff --git a/testsuite/tests/kuadrant/authorino/wristband/conftest.py b/testsuite/tests/kuadrant/authorino/wristband/conftest.py index 0a7d0173..c258590c 100644 --- a/testsuite/tests/kuadrant/authorino/wristband/conftest.py +++ b/testsuite/tests/kuadrant/authorino/wristband/conftest.py @@ -70,9 +70,7 @@ def wristband_endpoint(openshift, authorino, authorization_name): @pytest.fixture(scope="module") def authorization(authorization, wristband_secret, wristband_endpoint) -> AuthConfig: """Add wristband response with the signing key to the AuthConfig""" - authorization.responses.add_wristband( - "wristband", wristband_endpoint, wristband_secret, wrapper="envoyDynamicMetadata" - ) + authorization.responses.add_wristband("wristband", wristband_endpoint, wristband_secret, wrapper="dynamicMetadata") return authorization diff --git a/testsuite/tests/kuadrant/authorino/wristband/test_wristband.py b/testsuite/tests/kuadrant/authorino/wristband/test_wristband.py index 581682b6..4877592f 100644 --- a/testsuite/tests/kuadrant/authorino/wristband/test_wristband.py +++ b/testsuite/tests/kuadrant/authorino/wristband/test_wristband.py @@ -1,9 +1,6 @@ """Test api authentication with wristband-token that was acquired after authentication on the edge layer""" -import pytest from jose import jwt -pytest.skip("Envoy dynamic metadata not yet implemented due to v1beta2 AuthConfig change", allow_module_level=True) - def test_wristband_token_claims(oidc_provider, auth, wristband_token, wristband_endpoint, certificates): """Verify acquired jwt token claims"""