-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix/error handling] Different error handling for is_ec and is_es (#221)
* QRCode features (#217) * feat: changed qrcode handling * feat: copied static files from Satosa-saml2spid * feat: modified expiration time handling * fix: update test configuration * fix: remove of connection params * [Feat/retention rule] Added ttl rule for sessions (#218) * feat: added retention rule for session collection * test: added test for retention rule * Update pyeudiw/storage/mongo_storage.py Co-authored-by: Giuseppe De Marco <giuseppe.demarco@teamdigitale.governo.it> * Update pyeudiw/storage/mongo_storage.py Co-authored-by: Giuseppe De Marco <giuseppe.demarco@teamdigitale.governo.it> * Update pyeudiw/storage/base_storage.py Co-authored-by: Giuseppe De Marco <giuseppe.demarco@teamdigitale.governo.it> * chore: added config parameter --------- Co-authored-by: Giuseppe De Marco <giuseppe.demarco@teamdigitale.governo.it> * fix: error handling --------- Co-authored-by: Giuseppe De Marco <giuseppe.demarco@teamdigitale.governo.it> Co-authored-by: Ghenadie Artic <57416779+Gartic99@users.noreply.github.com>
- Loading branch information
1 parent
f75b6df
commit fbf62c4
Showing
10 changed files
with
103 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
from .exceptions import InvalidEntityStatement, InvalidEntityConfiguration | ||
from pyeudiw.federation.schemas.entity_configuration import EntityStatementPayload, EntityConfigurationPayload | ||
|
||
|
||
def is_es(payload: dict) -> bool: | ||
def is_es(payload: dict) -> None: | ||
""" | ||
Determines if payload dict is a Subordinate Entity Statement | ||
:param payload: the object to determine if is a Subordinate Entity Statement | ||
:type payload: dict | ||
:returns: True if is an Entity Statement and False otherwise | ||
:rtype: bool | ||
""" | ||
|
||
try: | ||
EntityStatementPayload(**payload) | ||
if payload["iss"] != payload["sub"]: | ||
return True | ||
except Exception: | ||
return False | ||
|
||
|
||
def is_ec(payload: dict) -> bool: | ||
if payload["iss"] == payload["sub"]: | ||
_msg = f"Invalid Entity Statement: iss and sub cannot be the same" | ||
raise InvalidEntityStatement(_msg) | ||
except ValueError as e: | ||
_msg = f"Invalid Entity Statement: {e}" | ||
raise InvalidEntityStatement(_msg) | ||
|
||
def is_ec(payload: dict) -> None: | ||
""" | ||
Determines if payload dict is an Entity Configuration | ||
:param payload: the object to determine if is an Entity Configuration | ||
:type payload: dict | ||
:returns: True if is an Entity Configuration and False otherwise | ||
:rtype: bool | ||
""" | ||
|
||
try: | ||
EntityConfigurationPayload(**payload) | ||
return True | ||
except Exception as e: | ||
return False | ||
except ValueError as e: | ||
_msg = f"Invalid Entity Configuration: {e}" | ||
raise InvalidEntityConfiguration(_msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters