Skip to content

Commit 67a6fd2

Browse files
committed
Merge remote-tracking branch 'origin/rh_wkis3' into rh_wkis3
2 parents 231ea51 + 58e537c commit 67a6fd2

11 files changed

+79
-72
lines changed

tests/satosa/backends/test_bitbucket.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def create_backend(self):
7878
BB_CONFIG, "base_url", "bitbucket")
7979

8080
@pytest.fixture
81-
def incoming_authn_response(self, context):
81+
def incoming_authn_response(self, context, **kwargs):
8282
context.path = 'bitbucket/sso/redirect'
8383
state_data = dict(state=mock_get_state.return_value)
8484
context.state[self.bb_backend.name] = state_data
@@ -127,15 +127,16 @@ def test_register_endpoints(self):
127127
expected_url_map = [('^bitbucket$', self.bb_backend._authn_response)]
128128
assert url_map == expected_url_map
129129

130-
def test_start_auth(self, context):
130+
def test_start_auth(self, context, **kwargs):
131131
context.path = 'bitbucket/sso/redirect'
132132
internal_request = InternalData(
133133
subject_type=NAMEID_FORMAT_TRANSIENT, requester='test_requester'
134134
)
135135

136136
resp = self.bb_backend.start_auth(context,
137137
internal_request,
138-
mock_get_state)
138+
mock_get_state,
139+
**kwargs)
139140
login_url = resp.message
140141
assert login_url.startswith(
141142
BB_CONFIG["server_info"]["authorization_endpoint"])
@@ -165,7 +166,7 @@ def test_authn_response(self, incoming_authn_response):
165166
self.assert_token_request(**mock_do_access_token_request.call_args[1])
166167

167168
@responses.activate
168-
def test_entire_flow(self, context):
169+
def test_entire_flow(self, context, **kwargs):
169170
"""
170171
Tests start of authentication (incoming auth req) and receiving auth
171172
response.

tests/satosa/backends/test_oauth.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def create_backend(self):
6868
self.fb_backend = FacebookBackend(Mock(), INTERNAL_ATTRIBUTES, FB_CONFIG, "base_url", "facebook")
6969

7070
@pytest.fixture
71-
def incoming_authn_response(self, context):
71+
def incoming_authn_response(self, context, **kwargs):
7272
context.path = 'facebook/sso/redirect'
7373
state_data = dict(state=mock_get_state.return_value)
7474
context.state[self.fb_backend.name] = state_data
@@ -110,7 +110,7 @@ def test_register_endpoints(self):
110110
expected_url_map = [('^facebook$', self.fb_backend._authn_response)]
111111
assert url_map == expected_url_map
112112

113-
def test_start_auth(self, context):
113+
def test_start_auth(self, context, **kwargs):
114114
context.path = 'facebook/sso/redirect'
115115
internal_request = InternalData(
116116
subject_type=NAMEID_FORMAT_TRANSIENT, requester='test_requester'
@@ -142,7 +142,7 @@ def test_authn_response(self, incoming_authn_response):
142142
self.assert_token_request(**mock_do_access_token_request.call_args[1])
143143

144144
@responses.activate
145-
def test_entire_flow(self, context):
145+
def test_entire_flow(self, context, **kwargs):
146146
"""Tests start of authentication (incoming auth req) and receiving auth response."""
147147
responses.add(responses.POST,
148148
"https://graph.facebook.com/v2.5/oauth/access_token",

tests/satosa/backends/test_openid_connect.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_redirect_uri_path(self, backend_config):
129129
return urlparse(backend_config["client"]["client_metadata"]["redirect_uris"][0]).path.lstrip("/")
130130

131131
@pytest.fixture
132-
def incoming_authn_response(self, context, backend_config):
132+
def incoming_authn_response(self, context, backend_config, **kwargs):
133133
oidc_state = "my state"
134134
context.path = self.get_redirect_uri_path(backend_config)
135135
context.request = {
@@ -170,7 +170,7 @@ def test_response_endpoint(self, backend_config, internal_attributes, userinfo,
170170
assert isinstance(args[1], InternalData)
171171
self.assert_expected_attributes(internal_attributes, userinfo, args[1].attributes)
172172

173-
def test_start_auth_redirects_to_provider_authorization_endpoint(self, context, backend_config):
173+
def test_start_auth_redirects_to_provider_authorization_endpoint(self, context, backend_config, **kwargs):
174174
auth_response = self.oidc_backend.start_auth(context, None)
175175
assert isinstance(auth_response, Response)
176176

@@ -186,7 +186,7 @@ def test_start_auth_redirects_to_provider_authorization_endpoint(self, context,
186186
assert "nonce" in auth_params
187187

188188
@responses.activate
189-
def test_entire_flow(self, context, backend_config, internal_attributes, userinfo):
189+
def test_entire_flow(self, context, backend_config, internal_attributes, userinfo, **kwargs):
190190
self.setup_userinfo_endpoint(backend_config["provider_metadata"]["userinfo_endpoint"], userinfo)
191191
auth_response = self.oidc_backend.start_auth(context, None)
192192
auth_params = dict(parse_qsl(urlparse(auth_response.message).query))

tests/satosa/backends/test_orcid.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def setup_userinfo_endpoint(self, userinfo_endpoint_url, userinfo):
145145
)
146146

147147
@pytest.fixture
148-
def incoming_authn_response(self, context, backend_config):
148+
def incoming_authn_response(self, context, backend_config, **kwargs):
149149
context.path = backend_config["authz_page"]
150150
state_data = dict(state=mock_get_state.return_value)
151151
context.state[self.orcid_backend.name] = state_data
@@ -156,7 +156,7 @@ def incoming_authn_response(self, context, backend_config):
156156

157157
return context
158158

159-
def test_start_auth(self, context, backend_config):
159+
def test_start_auth(self, context, backend_config, **kwargs):
160160
auth_response = self.orcid_backend.start_auth(
161161
context, None, mock_get_state)
162162
assert isinstance(auth_response, Response)
@@ -191,7 +191,7 @@ def test_authn_response(self, backend_config, userinfo, incoming_authn_response)
191191
self.assert_expected_attributes(userinfo, args[1].attributes)
192192

193193
@responses.activate
194-
def test_user_information(self, context, backend_config, userinfo):
194+
def test_user_information(self, context, backend_config, userinfo, **kwargs):
195195
self.setup_userinfo_endpoint(
196196
backend_config["server_info"]["user_info"],
197197
userinfo
@@ -212,7 +212,7 @@ def test_user_information(self, context, backend_config, userinfo):
212212
assert user_attributes["surname"] == ORCID_PERSON_FAMILY_NAME
213213

214214
@responses.activate
215-
def test_user_information_private(self, context, backend_config, userinfo_private):
215+
def test_user_information_private(self, context, backend_config, userinfo_private, **kwargs):
216216
self.setup_userinfo_endpoint(
217217
backend_config["server_info"]["user_info"],
218218
userinfo_private

tests/satosa/backends/test_saml2.py

+17-21
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,19 @@ def get_path_from_url(url):
103103
for endp in all_sp_endpoints:
104104
assert any(p.match(endp) for p in compiled_regex)
105105

106-
def test_start_auth_defaults_to_redirecting_to_discovery_server(self, context, sp_conf):
106+
def test_start_auth_defaults_to_redirecting_to_discovery_server(self, context, sp_conf, **kwargs):
107107
resp = self.samlbackend.start_auth(context, InternalData())
108108
assert_redirect_to_discovery_server(resp, sp_conf, DISCOSRV_URL)
109109

110-
def test_discovery_server_set_in_context(self, context, sp_conf):
110+
def test_discovery_server_set_in_context(self, context, sp_conf, **kwargs):
111111
discosrv_url = 'https://my.org/saml_discovery_service'
112112
context.decorate(
113113
SAMLBackend.KEY_SAML_DISCOVERY_SERVICE_URL, discosrv_url
114114
)
115115
resp = self.samlbackend.start_auth(context, InternalData())
116116
assert_redirect_to_discovery_server(resp, sp_conf, discosrv_url)
117117

118-
def test_full_flow(self, context, idp_conf, sp_conf):
118+
def test_full_flow(self, context, idp_conf, sp_conf, **kwargs):
119119
test_state_key = "test_state_key_456afgrh"
120120
response_binding = BINDING_HTTP_REDIRECT
121121
fakeidp = FakeIdP(USERS, config=IdPConfig().load(idp_conf, metadata_construction=False))
@@ -165,21 +165,21 @@ def test_start_auth_redirects_directly_to_mirrored_idp(
165165
resp = self.samlbackend.start_auth(context, InternalData())
166166
assert_redirect_to_idp(resp, idp_conf)
167167

168-
def test_redirect_to_idp_if_only_one_idp_in_metadata(self, context, sp_conf, idp_conf):
168+
def test_redirect_to_idp_if_only_one_idp_in_metadata(self, context, sp_conf, idp_conf, **kwargs):
169169
sp_conf["metadata"]["inline"] = [create_metadata_from_config_dict(idp_conf)]
170170
# instantiate new backend, without any discovery service configured
171171
samlbackend = SAMLBackend(None, INTERNAL_ATTRIBUTES, {"sp_config": sp_conf}, "base_url", "saml_backend")
172172

173173
resp = samlbackend.start_auth(context, InternalData())
174174
assert_redirect_to_idp(resp, idp_conf)
175175

176-
def test_authn_request(self, context, idp_conf):
176+
def test_authn_request(self, context, idp_conf, **kwargs):
177177
resp = self.samlbackend.authn_request(context, idp_conf["entityid"])
178178
assert_redirect_to_idp(resp, idp_conf)
179179
req_params = dict(parse_qsl(urlparse(resp.message).query))
180180
assert context.state[self.samlbackend.name]["relay_state"] == req_params["RelayState"]
181181

182-
def test_authn_response(self, context, idp_conf, sp_conf):
182+
def test_authn_response(self, context, idp_conf, sp_conf, **kwargs):
183183
response_binding = BINDING_HTTP_REDIRECT
184184
fakesp = FakeSP(SPConfig().load(sp_conf, metadata_construction=False))
185185
fakeidp = FakeIdP(USERS, config=IdPConfig().load(idp_conf, metadata_construction=False))
@@ -199,7 +199,7 @@ def test_authn_response(self, context, idp_conf, sp_conf):
199199
@pytest.mark.skipif(
200200
saml2.__version__ < '4.6.1',
201201
reason="Optional NameID needs pysaml2 v4.6.1 or higher")
202-
def test_authn_response_no_name_id(self, context, idp_conf, sp_conf):
202+
def test_authn_response_no_name_id(self, context, idp_conf, sp_conf, **kwargs):
203203
response_binding = BINDING_HTTP_REDIRECT
204204

205205
fakesp_conf = SPConfig().load(sp_conf, metadata_construction=False)
@@ -232,7 +232,7 @@ def test_authn_response_no_name_id(self, context, idp_conf, sp_conf):
232232
assert_authn_response(internal_resp)
233233
assert backend.name not in context.state
234234

235-
def test_authn_response_with_encrypted_assertion(self, sp_conf, context):
235+
def test_authn_response_with_encrypted_assertion(self, sp_conf, context, **kwargs):
236236
with open(os.path.join(
237237
TEST_RESOURCE_BASE_PATH,
238238
"idp_metadata_for_encrypted_signed_auth_response.xml"
@@ -277,28 +277,28 @@ def test_authn_response_with_encrypted_assertion(self, sp_conf, context):
277277
context, internal_resp = samlbackend.auth_callback_func.call_args[0]
278278
assert Counter(internal_resp.attributes.keys()) == Counter({"mail", "givenname", "displayname", "surname"})
279279

280-
def test_backend_reads_encryption_key_from_key_file(self, sp_conf):
280+
def test_backend_reads_encryption_key_from_key_file(self, sp_conf, **kwargs):
281281
sp_conf["key_file"] = os.path.join(TEST_RESOURCE_BASE_PATH, "encryption_key.pem")
282282
samlbackend = SAMLBackend(Mock(), INTERNAL_ATTRIBUTES, {"sp_config": sp_conf,
283283
"disco_srv": DISCOSRV_URL},
284284
"base_url", "samlbackend")
285285
assert samlbackend.encryption_keys
286286

287-
def test_backend_reads_encryption_key_from_encryption_keypair(self, sp_conf):
287+
def test_backend_reads_encryption_key_from_encryption_keypair(self, sp_conf, **kwargs):
288288
del sp_conf["key_file"]
289289
sp_conf["encryption_keypairs"] = [{"key_file": os.path.join(TEST_RESOURCE_BASE_PATH, "encryption_key.pem")}]
290290
samlbackend = SAMLBackend(Mock(), INTERNAL_ATTRIBUTES, {"sp_config": sp_conf,
291291
"disco_srv": DISCOSRV_URL},
292292
"base_url", "samlbackend")
293293
assert samlbackend.encryption_keys
294294

295-
def test_metadata_endpoint(self, context, sp_conf):
295+
def test_metadata_endpoint(self, context, sp_conf, **kwargs):
296296
resp = self.samlbackend._metadata_endpoint(context)
297297
headers = dict(resp.headers)
298298
assert headers["Content-Type"] == "text/xml"
299299
assert sp_conf["entityid"] in resp.message
300300

301-
def test_get_metadata_desc(self, sp_conf, idp_conf):
301+
def test_get_metadata_desc(self, sp_conf, idp_conf, **kwargs):
302302
sp_conf["metadata"]["inline"] = [create_metadata_from_config_dict(idp_conf)]
303303
# instantiate new backend, with a single backing IdP
304304
samlbackend = SAMLBackend(None, INTERNAL_ATTRIBUTES, {"sp_config": sp_conf}, "base_url", "saml_backend")
@@ -321,7 +321,7 @@ def test_get_metadata_desc(self, sp_conf, idp_conf):
321321
assert ui_info["description"] == expected_ui_info["description"]
322322
assert ui_info["logo"] == expected_ui_info["logo"]
323323

324-
def test_get_metadata_desc_with_logo_without_lang(self, sp_conf, idp_conf):
324+
def test_get_metadata_desc_with_logo_without_lang(self, sp_conf, idp_conf, **kwargs):
325325
# add logo without 'lang'
326326
idp_conf["service"]["idp"]["ui_info"]["logo"] = [{"text": "https://idp.example.com/static/logo.png",
327327
"width": "120", "height": "60"}]
@@ -351,8 +351,7 @@ def test_get_metadata_desc_with_logo_without_lang(self, sp_conf, idp_conf):
351351

352352
class TestSAMLBackendRedirects:
353353
def test_default_redirect_to_discovery_service_if_using_mdq(
354-
self, context, sp_conf, idp_conf
355-
):
354+
self, context, sp_conf, idp_conf, **kwargs):
356355
# one IdP in the metadata, but MDQ also configured so should always redirect to the discovery service
357356
sp_conf["metadata"]["inline"] = [create_metadata_from_config_dict(idp_conf)]
358357
sp_conf["metadata"]["mdq"] = ["https://mdq.example.com"]
@@ -362,8 +361,7 @@ def test_default_redirect_to_discovery_service_if_using_mdq(
362361
assert_redirect_to_discovery_server(resp, sp_conf, DISCOSRV_URL)
363362

364363
def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_not_set(
365-
self, context, sp_conf, idp_conf
366-
):
364+
self, context, sp_conf, idp_conf, **kwargs):
367365
sp_conf["metadata"]["inline"] = [create_metadata_from_config_dict(idp_conf)]
368366
sp_conf["metadata"]["mdq"] = ["https://mdq.example.com"]
369367

@@ -402,8 +400,7 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_not_se
402400
assert_redirect_to_discovery_server(resp, sp_conf, DISCOSRV_URL)
403401

404402
def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_true(
405-
self, context, sp_conf, idp_conf
406-
):
403+
self, context, sp_conf, idp_conf, **kwargs):
407404
sp_conf["metadata"]["inline"] = [create_metadata_from_config_dict(idp_conf)]
408405
sp_conf["metadata"]["mdq"] = ["https://mdq.example.com"]
409406

@@ -430,8 +427,7 @@ def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_tr
430427
assert_redirect_to_idp(resp, idp_conf)
431428

432429
def test_use_of_disco_or_redirect_to_idp_when_using_mdq_and_forceauthn_is_set_1(
433-
self, context, sp_conf, idp_conf
434-
):
430+
self, context, sp_conf, idp_conf, **kwargs):
435431
sp_conf["metadata"]["inline"] = [create_metadata_from_config_dict(idp_conf)]
436432
sp_conf["metadata"]["mdq"] = ["https://mdq.example.com"]
437433

0 commit comments

Comments
 (0)