forked from p15670423/monkey
island: Add FULL_USER_CREDENTIALS to test_environment.py
This commit is contained in:
parent
9024a512b0
commit
7772ea6e4e
|
@ -20,7 +20,8 @@ PARTIAL_CREDENTIALS = None
|
|||
STANDARD_WITH_CREDENTIALS = None
|
||||
STANDARD_ENV = None
|
||||
|
||||
EMPTY_CREDS = UserCreds("", "")
|
||||
EMPTY_USER_CREDENTIALS = UserCreds("", "")
|
||||
FULL_USER_CREDENTIALS = UserCreds(username="test", password_hash="1231234")
|
||||
|
||||
|
||||
# This fixture is a dirty hack that can be removed once these tests are converted from
|
||||
|
@ -69,7 +70,7 @@ def get_server_config_file_path_test_version():
|
|||
class TestEnvironment(TestCase):
|
||||
class EnvironmentCredentialsNotRequired(Environment):
|
||||
def __init__(self):
|
||||
config = StubEnvironmentConfig("test", "test", EMPTY_CREDS)
|
||||
config = StubEnvironmentConfig("test", "test", EMPTY_USER_CREDENTIALS)
|
||||
super().__init__(config)
|
||||
|
||||
_credentials_required = False
|
||||
|
@ -79,7 +80,7 @@ class TestEnvironment(TestCase):
|
|||
|
||||
class EnvironmentCredentialsRequired(Environment):
|
||||
def __init__(self):
|
||||
config = StubEnvironmentConfig("test", "test", EMPTY_CREDS)
|
||||
config = StubEnvironmentConfig("test", "test", EMPTY_USER_CREDENTIALS)
|
||||
super().__init__(config)
|
||||
|
||||
_credentials_required = True
|
||||
|
@ -100,7 +101,7 @@ class TestEnvironment(TestCase):
|
|||
@patch.object(target=EnvironmentConfig, attribute="save_to_file", new=MagicMock())
|
||||
def test_try_add_user(self):
|
||||
env = TestEnvironment.EnvironmentCredentialsRequired()
|
||||
credentials = UserCreds(username="test", password_hash="1231234")
|
||||
credentials = FULL_USER_CREDENTIALS
|
||||
env.try_add_user(credentials)
|
||||
|
||||
credentials = UserCreds(username="test", password_hash="")
|
||||
|
@ -108,7 +109,7 @@ class TestEnvironment(TestCase):
|
|||
env.try_add_user(credentials)
|
||||
|
||||
env = TestEnvironment.EnvironmentCredentialsNotRequired()
|
||||
credentials = UserCreds(username="test", password_hash="1231234")
|
||||
credentials = FULL_USER_CREDENTIALS
|
||||
with self.assertRaises(RegistrationNotNeededError):
|
||||
env.try_add_user(credentials)
|
||||
|
||||
|
|
Loading…
Reference in New Issue