Skip to content

Commit 333a745

Browse files
committed
Format code
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent e0102b8 commit 333a745

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

src/satosa/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ def _run_bound_endpoint(self, context, spec):
227227
return spec(context)
228228
except SATOSAAuthenticationError as error:
229229
error.error_id = uuid.uuid4().urn
230-
msg = "ERROR_ID [{err_id}]\nSTATE:\n{state}".format(err_id=error.error_id,
231-
state=json.dumps(
232-
error.state.state_dict,
233-
indent=4))
230+
state = json.dumps(error.state.state_dict, indent=4)
231+
msg = "ERROR_ID [{err_id}]\nSTATE:\n{state}".format(
232+
err_id=error.error_id, state=state
233+
)
234234
satosa_logging(logger, logging.ERROR, msg, error.state, exc_info=True)
235235
return self._handle_satosa_authentication_error(error)
236236

@@ -243,9 +243,10 @@ def _load_state(self, context):
243243
"""
244244
try:
245245
state = cookie_to_state(
246-
context.cookie,
247-
self.config["COOKIE_STATE_NAME"],
248-
self.config["STATE_ENCRYPTION_KEY"])
246+
context.cookie,
247+
self.config["COOKIE_STATE_NAME"],
248+
self.config["STATE_ENCRYPTION_KEY"],
249+
)
249250
except SATOSAStateError as e:
250251
msg_tmpl = 'Failed to decrypt state {state} with {error}'
251252
msg = msg_tmpl.format(state=context.cookie, error=str(e))

tests/satosa/backends/test_saml2.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,30 +233,44 @@ def test_authn_response_no_name_id(self, context, idp_conf, sp_conf):
233233
assert backend.name not in context.state
234234

235235
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:
238240
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+
)
242249
response_binding = BINDING_HTTP_REDIRECT
243250
relay_state = "test relay state"
244251

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:
247256
auth_response = auth_response_file.read()
257+
248258
context.request = {"SAMLResponse": deflate_and_base64_encode(auth_response), "RelayState": relay_state}
249259

250260
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:
252264
samlbackend.encryption_keys = [encryption_key_file.read()]
253265

254266
assertion_issued_at = 1479315212
255267
with patch('saml2.validate.time_util.shift_time') as mock_shift_time, \
256268
patch('saml2.validate.time_util.utc_now') as mock_utc_now:
257269
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+
]
260274
samlbackend.authn_response(context, response_binding)
261275

262276
context, internal_resp = samlbackend.auth_callback_func.call_args[0]

0 commit comments

Comments
 (0)