From 2aa745e332f61523625dc66ee67c36483b8f494d Mon Sep 17 00:00:00 2001 From: hasan7n Date: Mon, 31 Jul 2023 16:13:25 +0200 Subject: [PATCH] add error checking regarding local test emails --- cli/medperf/comms/auth/local.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/medperf/comms/auth/local.py b/cli/medperf/comms/auth/local.py index dac749109..1c12ba1cc 100644 --- a/cli/medperf/comms/auth/local.py +++ b/cli/medperf/comms/auth/local.py @@ -1,5 +1,6 @@ from medperf.comms.auth.interface import Auth import medperf.config as config +from medperf.exceptions import InvalidArgumentError from medperf.account_management import ( set_credentials, read_credentials, @@ -20,7 +21,13 @@ def login(self, email): email (str): user email. """ - access_token = self.tokens[email] + try: + access_token = self.tokens[email] + except KeyError: + raise InvalidArgumentError( + "The provided email does not exist for testing. " + "Make sure you activated the right profile." + ) refresh_token = "refresh token" id_token_payload = {"email": email} token_issued_at = 0