From f08ac42ac9d7d1ff579f24b66daded1ae77ba054 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 18 Nov 2021 12:26:42 -0500 Subject: [PATCH] Tests: Clarify needs_registration() tests for AuthenticationService --- .../test_authentication_service.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py index 3c61594ad..62f73fa02 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py @@ -73,16 +73,8 @@ def patch_datastore_utils( def test_needs_registration__true(tmp_path): - mock_user_datastore = MockUserDatastore(lambda: True, None, None) - - a_s = AuthenticationService() - a_s.initialize(tmp_path, mock_user_datastore) - - assert not a_s.needs_registration() - - -def test_needs_registration__false(tmp_path): - mock_user_datastore = MockUserDatastore(lambda: False, None, None) + has_registered_users = False + mock_user_datastore = MockUserDatastore(lambda: has_registered_users, None, None) a_s = AuthenticationService() a_s.initialize(tmp_path, mock_user_datastore) @@ -90,6 +82,16 @@ def test_needs_registration__false(tmp_path): assert a_s.needs_registration() +def test_needs_registration__false(tmp_path): + has_registered_users = True + mock_user_datastore = MockUserDatastore(lambda: has_registered_users, None, None) + + a_s = AuthenticationService() + a_s.initialize(tmp_path, mock_user_datastore) + + assert not a_s.needs_registration() + + @pytest.mark.parametrize("error", [InvalidRegistrationCredentialsError, AlreadyRegisteredError]) def test_register_new_user__fails( tmp_path, mock_reset_datastore_encryptor, mock_reset_database, error