mirror of https://github.com/nucypher/nucypher.git
Include min password length when asking for it.
parent
50f1e41904
commit
e814cc464e
|
@ -88,7 +88,8 @@ def get_client_password(checksum_address: str, envvar: str = '') -> str:
|
|||
|
||||
|
||||
def get_nucypher_password(confirm: bool = False, envvar="NUCYPHER_KEYRING_PASSWORD") -> str:
|
||||
prompt = "Enter NuCypher keyring password"
|
||||
from nucypher.config.keyring import NucypherKeyring
|
||||
prompt = f"Enter NuCypher keyring password (min. {NucypherKeyring.MINIMUM_PASSWORD_LENGTH} chars.)"
|
||||
keyring_password = get_password_from_prompt(prompt=prompt, confirm=confirm, envvar=envvar)
|
||||
return keyring_password
|
||||
|
||||
|
|
|
@ -320,6 +320,8 @@ class NucypherKeyring:
|
|||
|
||||
"""
|
||||
|
||||
MINIMUM_PASSWORD_LENGTH = 16
|
||||
|
||||
__default_keyring_root = os.path.join(DEFAULT_CONFIG_ROOT, 'keyring')
|
||||
_private_key_serializer = _PrivateKeySerializer()
|
||||
__DEFAULT_TLS_CURVE = ec.SECP384R1
|
||||
|
@ -663,8 +665,8 @@ class NucypherKeyring:
|
|||
keyring_instance = cls(account=checksum_address, **keyring_args)
|
||||
return keyring_instance
|
||||
|
||||
@staticmethod
|
||||
def validate_password(password: str) -> List:
|
||||
@classmethod
|
||||
def validate_password(cls, password: str) -> List:
|
||||
"""
|
||||
Validate a password and return True or raise an error with a failure reason.
|
||||
|
||||
|
@ -672,7 +674,8 @@ class NucypherKeyring:
|
|||
"""
|
||||
rules = (
|
||||
(bool(password), 'Password must not be blank.'),
|
||||
(len(password) >= 16, 'Password must be at least 16 characters long.'),
|
||||
(len(password) >= cls.MINIMUM_PASSWORD_LENGTH,
|
||||
f'Password must be at least {cls.MINIMUM_PASSWORD_LENGTH} characters long.'),
|
||||
)
|
||||
|
||||
failures = list()
|
||||
|
|
|
@ -24,7 +24,7 @@ def test_initialize_alice_defaults(click_runner, mocker):
|
|||
assert "nucypher alice run" in result.output
|
||||
|
||||
# Auth
|
||||
assert 'Enter NuCypher keyring password:' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Enter NuCypher keyring password' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Repeat for confirmation:' in result.output, 'User was not prompted to confirm password'
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ def test_initialize_alice_with_custom_configuration_root(custom_filepath, click_
|
|||
assert os.path.isfile(custom_config_filepath), 'Configuration file does not exist'
|
||||
|
||||
# Auth
|
||||
assert 'Enter NuCypher keyring password:' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Enter NuCypher keyring password' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Repeat for confirmation:' in result.output, 'User was not prompted to confirm password'
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ def test_initialize_bob_with_custom_configuration_root(custom_filepath, click_ru
|
|||
assert os.path.isfile(custom_config_filepath), 'Configuration file does not exist'
|
||||
|
||||
# Auth
|
||||
assert 'Enter NuCypher keyring password:' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Enter NuCypher keyring password' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Repeat for confirmation:' in result.output, 'User was not prompted to confirm password'
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ def test_initialize_ursula_defaults(click_runner, mocker):
|
|||
assert 'Is this the public-facing IPv4 address' in result.output
|
||||
|
||||
# Auth
|
||||
assert 'Enter NuCypher keyring password:' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Enter NuCypher keyring password' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Repeat for confirmation:' in result.output, 'User was not prompted to confirm password'
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ def test_initialize_custom_configuration_root(custom_filepath, click_runner):
|
|||
assert os.path.isfile(custom_config_filepath), 'Configuration file does not exist'
|
||||
|
||||
# Auth
|
||||
assert 'Enter NuCypher keyring password:' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Enter NuCypher keyring password' in result.output, 'WARNING: User was not prompted for password'
|
||||
assert 'Repeat for confirmation:' in result.output, 'User was not prompted to confirm password'
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue