From 20b1fca3f162ea7b1d0c656a309f24255f2b77ca Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Wed, 18 Dec 2024 19:30:52 +0000 Subject: [PATCH 1/3] chore(logging): add logging to see what inputs are hashed to --- eligibility_server/verify.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eligibility_server/verify.py b/eligibility_server/verify.py index a3cd92fe..c3cf4a5f 100644 --- a/eligibility_server/verify.py +++ b/eligibility_server/verify.py @@ -108,6 +108,8 @@ def _check_user(self, sub, name, types): sub = self.hash.hash_input(sub) name = self.hash.hash_input(name) + logger.debug(f"Hashed sub, name: {sub},{name}") + existing_user = User.query.filter_by(sub=sub, name=name).first() if existing_user: existing_user_types = [type.name for type in existing_user.types] From 9f9607bd19afe32fe04d61d7ac5ffbecf040a371 Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Wed, 18 Dec 2024 19:32:08 +0000 Subject: [PATCH 2/3] chore(logging): add additional logging around types in play --- eligibility_server/verify.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eligibility_server/verify.py b/eligibility_server/verify.py index c3cf4a5f..36845e33 100644 --- a/eligibility_server/verify.py +++ b/eligibility_server/verify.py @@ -103,6 +103,8 @@ def _check_user(self, sub, name, types): if len(types) < 1: logger.debug("List of types to check was empty.") return [] + else: + logger.debug(f"Types to check: {types}") if self.hash: sub = self.hash.hash_input(sub) @@ -113,10 +115,12 @@ def _check_user(self, sub, name, types): existing_user = User.query.filter_by(sub=sub, name=name).first() if existing_user: existing_user_types = [type.name for type in existing_user.types] + logger.debug(f"Existing types on user: {existing_user_types}") else: existing_user_types = [] matching_types = set(existing_user_types) & set(types) + logger.debug(f"Matching types: {matching_types}") if existing_user is None: logger.debug("Database does not contain requested user.") From 7c950fa4076d9e6aa08129866af76987cc6e624a Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Wed, 18 Dec 2024 19:40:26 +0000 Subject: [PATCH 3/3] chore(logging): add more logging to cover more code paths --- eligibility_server/verify.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eligibility_server/verify.py b/eligibility_server/verify.py index 36845e33..8fabed3e 100644 --- a/eligibility_server/verify.py +++ b/eligibility_server/verify.py @@ -118,6 +118,7 @@ def _check_user(self, sub, name, types): logger.debug(f"Existing types on user: {existing_user_types}") else: existing_user_types = [] + logger.debug("User not found") matching_types = set(existing_user_types) & set(types) logger.debug(f"Matching types: {matching_types}") @@ -129,6 +130,7 @@ def _check_user(self, sub, name, types): logger.debug(f"User's types do not contain any of the requested types: {types}") return [] else: + logger.debug("Returning matching types for existing user") return list(matching_types) def get(self):