forked from p15670423/monkey
Island: Add a check for None credentials in get_user_credentials()
This commit is contained in:
parent
f5e1b46a31
commit
a2eab2fa5d
|
@ -51,7 +51,7 @@ class JsonFileUserDatastore(IUserDatastore):
|
|||
json.dump(self._credentials.to_dict(), f, indent=2)
|
||||
|
||||
def get_user_credentials(self, username: str) -> UserCreds:
|
||||
if self._credentials.username != username:
|
||||
if self._credentials is None or self._credentials.username != username:
|
||||
raise UnknownUserError(f"User {username} does not exist.")
|
||||
|
||||
return self._credentials
|
||||
|
|
|
@ -75,3 +75,8 @@ def test_get_user_credentials_from_file(tmp_path):
|
|||
def test_get_unknown_user(populated_datastore):
|
||||
with pytest.raises(UnknownUserError):
|
||||
populated_datastore.get_user_credentials("unregistered_user")
|
||||
|
||||
|
||||
def test_get_user_credentials__no_user_registered(empty_datastore):
|
||||
with pytest.raises(UnknownUserError):
|
||||
empty_datastore.get_user_credentials("unregistered_user")
|
||||
|
|
Loading…
Reference in New Issue