Skip to content

Commit 7db8bdb

Browse files
authored
Merge pull request #36 from its-dirg/consent-enable
Remove 'enable' config param for Consent
2 parents a2d5625 + 57e1200 commit 7db8bdb

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
module: satosa.micro_services.account_linking.Consent
1+
module: satosa.micro_services.consent.Consent
22
name: Consent
33
config:
4-
enable: Yes
54
api_url: "https://127.0.0.1:8166"
65
redirect_url: "https://localhost:8166/consent"
76
sign_key: "pki/mykey.pem"

src/satosa/micro_services/consent.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,15 @@ class Consent(ResponseMicroService):
3434
def __init__(self, config, internal_attributes, *args, **kwargs):
3535
super().__init__(*args, **kwargs)
3636
self.name = "consent"
37-
self.enabled = ("enable" not in config or config["enable"])
38-
if self.enabled:
39-
self.api_url = config["api_url"]
40-
self.redirect_url = config["redirect_url"]
41-
self.locked_attr = None
42-
if "user_id_to_attr" in internal_attributes:
43-
self.locked_attr = internal_attributes["user_id_to_attr"]
44-
45-
self.signing_key = RSAKey(key=rsa_load(config["sign_key"]), use="sig", alg="RS256")
46-
self.endpoint = "/handle_consent"
47-
logger.info("Consent flow is active")
48-
else:
49-
logger.info("Consent flow is not active")
37+
self.api_url = config["api_url"]
38+
self.redirect_url = config["redirect_url"]
39+
self.locked_attr = None
40+
if "user_id_to_attr" in internal_attributes:
41+
self.locked_attr = internal_attributes["user_id_to_attr"]
42+
43+
self.signing_key = RSAKey(key=rsa_load(config["sign_key"]), use="sig", alg="RS256")
44+
self.endpoint = "/handle_consent"
45+
logger.info("Consent flow is active")
5046

5147
def _handle_consent_response(self, context):
5248
"""
@@ -118,9 +114,6 @@ def process(self, context, internal_response):
118114
:param internal_response: the response
119115
:return: response
120116
"""
121-
if not self.enabled:
122-
return super().process(context, internal_response)
123-
124117
consent_state = context.state[STATE_KEY]
125118

126119
internal_response.attributes = self._filter_attributes(internal_response.attributes, consent_state["filter"])

tests/satosa/micro_services/test_consent.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ def assert_registration_req(self, request, internal_response, sign_key_path, bas
8787
assert consent_args["locked_attrs"] == [USER_ID_ATTR]
8888
assert "id" in consent_args
8989

90-
def test_disabled_consent(self, consent_config):
91-
consent_config["enable"] = False
92-
consent_module = Consent(consent_config, {"attributes": {}}, name="Consent",
93-
base_url="https://satosa.example.com")
94-
mock_next_callback = Mock()
95-
consent_module.next = mock_next_callback
96-
97-
assert consent_module.enabled is False
98-
consent_module.process(None, None)
99-
assert mock_next_callback.called
100-
10190
@responses.activate
10291
def test_verify_consent_false_on_http_400(self, consent_config):
10392
consent_id = "1234"

0 commit comments

Comments
 (0)