Skip to content

Commit 4c6a230

Browse files
committed
chore: unite test for opt-out trust param header
1 parent c7c4a4e commit 4c6a230

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

pyeudiw/tests/satosa/test_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ def test_response_endpoint(self, context):
467467

468468
# case (4): good aud, nonce and state
469469
good_response = self._generate_payload(self.issuer_jwk, self.holder_jwk, nonce, state, self.backend.client_id)
470-
471470
encrypted_response = JWEHelper(
472471
CONFIG["metadata_jwks"][1]).encrypt(good_response)
473472
context.request = {
@@ -919,6 +918,7 @@ def test_trust_parameters_in_response(self, context):
919918
jwks=[JWK(key=ta_jwk).as_dict()],
920919
expiration_date=datetime.datetime.now(),
921920
trust_chain=trust_chain_wallet,
921+
trust_handler_name="FederationHandler",
922922
)
923923
)
924924

pyeudiw/tests/trust/mock_trust_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MockTrustHandler(TrustHandlerInterface):
3232
def __init__(self, *args, **kwargs):
3333
self.client_id = kwargs.get("default_client_id", None)
3434
self.exp = kwargs.get("exp", 10)
35+
self.include_issued_jwt_header_param = kwargs.get("include_issued_jwt_header_param", False)
3536

3637
def get_metadata(self, issuer: str, trust_source: TrustSourceData) -> dict:
3738
if issuer == self.client_id:

pyeudiw/tests/trust/test_dynamic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ def test_public_key_and_metadata_retrive():
5252
"mock": {
5353
"module": "pyeudiw.tests.trust.mock_trust_handler",
5454
"class": "MockTrustHandler",
55-
"config": {},
55+
"config": {"include_issued_jwt_header_param": True},
5656
},
5757

5858
}, db_engine, default_client_id="default-client-id", mode="update_first"
5959
)
6060

6161
uuid_url = f"http://{uuid4()}.issuer.it"
62-
6362
assert trust_ev.get_jwt_header_trust_parameters(uuid_url) == {'trust_param_name': {'trust_param_key': 'trust_param_value'}}
6463
metadata = trust_ev.get_metadata()
6564

@@ -82,7 +81,7 @@ def test_update_first_strategy():
8281
"mock": {
8382
"module": "pyeudiw.tests.trust.mock_trust_handler",
8483
"class": "UpdateTrustHandler",
85-
"config": {},
84+
"config": {"include_issued_jwt_header_param": True},
8685
},
8786

8887
}, db_engine, default_client_id="default-client-id"
@@ -102,7 +101,7 @@ def test_cache_first_strategy():
102101
"mock": {
103102
"module": "pyeudiw.tests.trust.mock_trust_handler",
104103
"class": "UpdateTrustHandler",
105-
"config": {},
104+
"config": {"include_issued_jwt_header_param": True},
106105
},
107106

108107
}, db_engine, default_client_id="default-client-id", mode="cache_first"
@@ -122,7 +121,8 @@ def test_cache_first_strategy_expired():
122121
"module": "pyeudiw.tests.trust.mock_trust_handler",
123122
"class": "UpdateTrustHandler",
124123
"config": {
125-
"exp": 0
124+
"exp": 0,
125+
"include_issued_jwt_header_param": True
126126
},
127127
},
128128

@@ -143,7 +143,7 @@ def test_cache_first_strategy_expired_revoked():
143143
"mock": {
144144
"module": "pyeudiw.tests.trust.mock_trust_handler",
145145
"class": "UpdateTrustHandler",
146-
"config": {},
146+
"config": {"include_issued_jwt_header_param": True},
147147
},
148148

149149
}, db_engine, default_client_id="default-client-id", mode="cache_first"
@@ -166,7 +166,7 @@ def test_cache_first_strategy_expired_force_update():
166166
"mock": {
167167
"module": "pyeudiw.tests.trust.mock_trust_handler",
168168
"class": "UpdateTrustHandler",
169-
"config": {},
169+
"config": {"include_issued_jwt_header_param": True},
170170
},
171171

172172
}, db_engine, default_client_id="default-client-id", mode="cache_first"

pyeudiw/trust/dynamic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ def get_jwt_header_trust_parameters(self, issuer: Optional[str] = None, force_up
308308
trust_source = self._get_trust_source(issuer, force_update)
309309

310310
headers_params = {}
311-
312311
for handler in self.handlers:
313312
if getattr(handler, INCLUDE_JWT_HEADER_CONFIG_NAME, None):
314313
if header := handler.extract_jwt_header_trust_parameters(trust_source):

pyeudiw/trust/handler/federation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(
4949
httpc_params: dict = DEFAULT_HTTPC_PARAMS,
5050
cache_ttl: int = 0,
5151
metadata_type: str = _ISSUER_METADATA_TYPE,
52+
include_issued_jwt_header_param: bool = False,
5253
**kwargs,
5354
):
5455

@@ -68,6 +69,7 @@ def __init__(
6869
self.federation_entity_metadata: dict[str, str] = federation_entity_metadata
6970
self.client_id: str = federation_entity_metadata
7071
self.entity_configuration_exp = entity_configuration_exp
72+
self.include_issued_jwt_header_param = include_issued_jwt_header_param
7173

7274
self.federation_public_jwks = [
7375
JWK(i).as_public_dict() for i in self.federation_jwks

0 commit comments

Comments
 (0)