From bc96c3856dfd6ffbd27e0f59acacfef2b71e4edd Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Thu, 10 Sep 2020 02:28:38 +0300 Subject: Replace assert with proper checks Signed-off-by: Ivan Kanakarakis --- src/saml2/ecp_client.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/saml2/ecp_client.py') diff --git a/src/saml2/ecp_client.py b/src/saml2/ecp_client.py index f0183f45..5265f99d 100644 --- a/src/saml2/ecp_client.py +++ b/src/saml2/ecp_client.py @@ -136,7 +136,14 @@ class Client(Entity): logger.debug("[P2] IdP response dict: %s", respdict) idp_response = respdict["body"] - assert idp_response.c_tag == "Response" + + expected_tag = "Response" + if idp_response.c_tag != expected_tag: + raise ValueError( + "Invalid Response tag '{invalid}' should be '{valid}'".format( + invalid=idp_response.c_tag, valid=expected_tag + ) + ) logger.debug("[P2] IdP AUTHN response: %s", idp_response) @@ -165,7 +172,14 @@ class Client(Entity): # AuthnRequest in the body or not authn_request = respdict["body"] - assert authn_request.c_tag == "AuthnRequest" + + expected_tag = "AuthnRequest" + if authn_request.c_tag != expected_tag: + raise ValueError( + "Invalid AuthnRequest tag '{invalid}' should be '{valid}'".format( + invalid=authn_request.c_tag, valid=expected_tag + ) + ) # ecp.RelayState among headers _relay_state = None -- cgit v1.2.1