Skip to content

Commit

Permalink
feat(utils.py): remove email verification
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlacho committed Dec 10, 2024
1 parent 728c7c1 commit c2ca852
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
10 changes: 8 additions & 2 deletions safety/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 15 additions & 11 deletions tests/auth/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from unittest.mock import Mock, PropertyMock, patch, ANY
import click
from click.testing import CliRunner
Expand All @@ -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": "[email protected]", "name": "Safety User"}
result = self.runner.invoke(cli, ['auth'])
process_browser_callback.return_value = {
"email": "[email protected]",
"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",
Expand All @@ -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)

0 comments on commit c2ca852

Please sign in to comment.