From c2ca852a402a04f642dea80a29fa2ae9fa4d8eab Mon Sep 17 00:00:00 2001 From: David Lacho Date: Tue, 10 Dec 2024 15:28:56 -0500 Subject: [PATCH] feat(utils.py): remove email verification --- safety/auth/utils.py | 10 ++++++++-- tests/auth/test_cli.py | 26 +++++++++++++++----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/safety/auth/utils.py b/safety/auth/utils.py index 4d42ddba..604b496e 100644 --- a/safety/auth/utils.py +++ b/safety/auth/utils.py @@ -48,9 +48,15 @@ def is_email_verified(info: Dict[str, Any]) -> Optional[bool]: info (Dict[str, Any]): The user information. Returns: - bool: True if the email is verified, False otherwise. + bool: True """ - return info.get(CLAIM_EMAIL_VERIFIED_API) or info.get(CLAIM_EMAIL_VERIFIED_AUTH_SERVER) + # return info.get(CLAIM_EMAIL_VERIFIED_API) or info.get( + # CLAIM_EMAIL_VERIFIED_AUTH_SERVER + # ) + + # Always return True to avoid email verification + return True + def parse_response(func: Callable) -> Callable: diff --git a/tests/auth/test_cli.py b/tests/auth/test_cli.py index 9b035b3d..f77aeae6 100644 --- a/tests/auth/test_cli.py +++ b/tests/auth/test_cli.py @@ -1,4 +1,3 @@ - from unittest.mock import Mock, PropertyMock, patch, ANY import click from click.testing import CliRunner @@ -14,22 +13,27 @@ def setUp(self): self.maxDiff = None self.runner = CliRunner(mix_stderr=False) + @unittest.skip("We are bypassing email verification for now") @patch("safety.auth.cli.fail_if_authenticated") @patch("safety.auth.cli.get_authorization_data") @patch("safety.auth.cli.process_browser_callback") - def test_auth_calls_login(self, process_browser_callback, - get_authorization_data, fail_if_authenticated): + def test_auth_calls_login( + self, process_browser_callback, get_authorization_data, fail_if_authenticated + ): auth_data = "https://safetycli.com", "initialState" get_authorization_data.return_value = auth_data - process_browser_callback.return_value = {"email": "user@safetycli.com", "name": "Safety User"} - result = self.runner.invoke(cli, ['auth']) + process_browser_callback.return_value = { + "email": "user@safetycli.com", + "name": "Safety User", + } + result = self.runner.invoke(cli, ["auth"]) fail_if_authenticated.assert_called_once() get_authorization_data.assert_called_once() - process_browser_callback.assert_called_once_with(auth_data[0], - initial_state=auth_data[1], - ctx=ANY, headless=False) - + process_browser_callback.assert_called_once_with( + auth_data[0], initial_state=auth_data[1], ctx=ANY, headless=False + ) + expected = [ "", "Redirecting your browser to log in; once authenticated, return here to start using Safety", @@ -42,8 +46,8 @@ def test_auth_calls_login(self, process_browser_callback, "", "Can’t find the verification email? Login at", "`https://platform.safetycli.com/login/` to resend the verification email", - "" + "", ] for res_line, exp_line in zip(result.stdout.splitlines(), expected): - self.assertIn(exp_line, res_line) + self.assertIn(exp_line, res_line)