Skip to content

Commit fcd1cf4

Browse files
added validation to api identity
1 parent 97bf9b7 commit fcd1cf4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

uid2_client/identity_map_v3_response.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def __init__(self, current_uid: Optional[str], previous_uid: Optional[str],
8080

8181
@classmethod
8282
def from_json(cls, data: Dict[str, Any]) -> 'ApiIdentity':
83+
mapped_identity = data.keys().__contains__("u") and data.keys().__contains__("p") and data.keys().__contains__("r")
84+
unmapped_identity = data.keys().__contains__("e")
85+
if not mapped_identity and not unmapped_identity:
86+
raise ValueError("api identity does not contain the correct keys")
87+
8388
return cls(
8489
current_uid=data.get("u"),
8590
previous_uid=data.get("p"),

0 commit comments

Comments
 (0)