@@ -233,30 +233,44 @@ def test_authn_response_no_name_id(self, context, idp_conf, sp_conf):
233
233
assert backend .name not in context .state
234
234
235
235
def test_authn_response_with_encrypted_assertion (self , sp_conf , context ):
236
- with open (os .path .join (TEST_RESOURCE_BASE_PATH ,
237
- "idp_metadata_for_encrypted_signed_auth_response.xml" )) as idp_metadata_file :
236
+ with open (os .path .join (
237
+ TEST_RESOURCE_BASE_PATH ,
238
+ "idp_metadata_for_encrypted_signed_auth_response.xml"
239
+ )) as idp_metadata_file :
238
240
sp_conf ["metadata" ]["inline" ] = [idp_metadata_file .read ()]
239
- samlbackend = SAMLBackend (Mock (), INTERNAL_ATTRIBUTES , {"sp_config" : sp_conf ,
240
- "disco_srv" : DISCOSRV_URL },
241
- "base_url" , "samlbackend" )
241
+
242
+ samlbackend = SAMLBackend (
243
+ Mock (),
244
+ INTERNAL_ATTRIBUTES ,
245
+ {"sp_config" : sp_conf , "disco_srv" : DISCOSRV_URL },
246
+ "base_url" ,
247
+ "samlbackend" ,
248
+ )
242
249
response_binding = BINDING_HTTP_REDIRECT
243
250
relay_state = "test relay state"
244
251
245
- with open (os .path .join (TEST_RESOURCE_BASE_PATH ,
246
- "auth_response_with_encrypted_signed_assertion.xml" )) as auth_response_file :
252
+ with open (os .path .join (
253
+ TEST_RESOURCE_BASE_PATH ,
254
+ "auth_response_with_encrypted_signed_assertion.xml"
255
+ )) as auth_response_file :
247
256
auth_response = auth_response_file .read ()
257
+
248
258
context .request = {"SAMLResponse" : deflate_and_base64_encode (auth_response ), "RelayState" : relay_state }
249
259
250
260
context .state [self .samlbackend .name ] = {"relay_state" : relay_state }
251
- with open (os .path .join (TEST_RESOURCE_BASE_PATH , "encryption_key.pem" )) as encryption_key_file :
261
+ with open (
262
+ os .path .join (TEST_RESOURCE_BASE_PATH , "encryption_key.pem" )
263
+ ) as encryption_key_file :
252
264
samlbackend .encryption_keys = [encryption_key_file .read ()]
253
265
254
266
assertion_issued_at = 1479315212
255
267
with patch ('saml2.validate.time_util.shift_time' ) as mock_shift_time , \
256
268
patch ('saml2.validate.time_util.utc_now' ) as mock_utc_now :
257
269
mock_utc_now .return_value = assertion_issued_at + 1
258
- mock_shift_time .side_effect = [datetime .utcfromtimestamp (assertion_issued_at + 1 ),
259
- datetime .utcfromtimestamp (assertion_issued_at - 1 )]
270
+ mock_shift_time .side_effect = [
271
+ datetime .utcfromtimestamp (assertion_issued_at + 1 ),
272
+ datetime .utcfromtimestamp (assertion_issued_at - 1 ),
273
+ ]
260
274
samlbackend .authn_response (context , response_binding )
261
275
262
276
context , internal_resp = samlbackend .auth_callback_func .call_args [0 ]
0 commit comments