Adds tests for stripping of control chars for passwords

This commit is contained in:
Carl Beekhuizen 2020-07-23 03:09:06 +02:00
parent a13294741f
commit 8fe4ca8233
No known key found for this signature in database
GPG Key ID: 8F29E54F49E7AAB5

View File

@ -1,5 +1,6 @@
import os import os
import json import json
import pytest
from eth2deposit.key_handling.keystore import ( from eth2deposit.key_handling.keystore import (
Keystore, Keystore,
@ -56,3 +57,11 @@ def test_encrypt_decrypt_pbkdf2_random_iv() -> None:
def test_encrypt_decrypt_scrypt_random_iv() -> None: def test_encrypt_decrypt_scrypt_random_iv() -> None:
generated_keystore = ScryptKeystore.encrypt(secret=test_vector_secret, password=test_vector_password) generated_keystore = ScryptKeystore.encrypt(secret=test_vector_secret, password=test_vector_password)
assert generated_keystore.decrypt(test_vector_password) == test_vector_secret assert generated_keystore.decrypt(test_vector_password) == test_vector_secret
@pytest.mark.parametrize(
'password,processed_password',
[['\a', b''], ['\b', b''], ['\t', b'']]
)
def test_process_password(password: str, processed_password: bytes) -> None:
assert Keystore._process_password(password) == processed_password