From 8fe4ca8233b182ff0bcae275ffa8101cc6e33fc6 Mon Sep 17 00:00:00 2001 From: Carl Beekhuizen Date: Thu, 23 Jul 2020 03:09:06 +0200 Subject: [PATCH] Adds tests for stripping of control chars for passwords --- tests/test_key_handling/test_keystore.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_key_handling/test_keystore.py b/tests/test_key_handling/test_keystore.py index d07bc22..10bb371 100644 --- a/tests/test_key_handling/test_keystore.py +++ b/tests/test_key_handling/test_keystore.py @@ -1,5 +1,6 @@ import os import json +import pytest from eth2deposit.key_handling.keystore import ( Keystore, @@ -56,3 +57,11 @@ def test_encrypt_decrypt_pbkdf2_random_iv() -> None: def test_encrypt_decrypt_scrypt_random_iv() -> None: generated_keystore = ScryptKeystore.encrypt(secret=test_vector_secret, password=test_vector_password) 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