def test_app(): passwords = [ ("x", "", "1"), ("want", "a", "epuu7Aeja9"), ("emerge", "bamboo", "zexae2Moo2"), ("question", "predict", "dahTho9Thai5yiasie1c"), ("quick fiber estate ripple phrase", "topic", "huu4aeju2gooth1iS6ai") ] auto = Automaton() client = Client(auto) # Test password insertion assert client.get_size() == 0 for i, (name, login, password) in enumerate(passwords): auto.actions = "rb" client.add(name, login, password) assert client.get_size() == i+1 subtest_password_list(client, passwords) subtest_has_name(client, passwords) subtest_password_retrieval(client, auto, passwords) # Export in plain text and also in encrypted form # Do this before password removal testing auto.actions = "brb" export_plain = client.export(encrypt=False) auto.actions = "b" export_encrypted = client.export() # Test password removal removal_order = [name for name, _, _ in passwords] random.shuffle(removal_order) names = set(removal_order) for name in removal_order: auto.actions = "rb" client.delete_by_name(name) names.remove(name) assert set(client.get_names()) == names assert client.get_size() == 0 # Test import plain subtest_clear(client, auto, passwords) auto.actions = ";b" client.import_("1.1.0", export_plain, encrypted=False) subtest_password_list(client, passwords) subtest_password_retrieval(client, auto, passwords) # Test import encrypted subtest_clear(client, auto, passwords) auto.actions = ";b" client.import_("1.1.0", export_encrypted, encrypted=True) subtest_password_list(client, passwords) subtest_password_retrieval(client, auto, passwords)
from nanopass import Client import random passwords = [("x", "1"), ("want", "epuu7Aeja9"), ("emerge", "zexae2Moo2"), ("question", "dahTho9Thai5yiasie1c"), ("quick fiber estate ripple phrase", "huu4aeju2gooth1iS6ai")] password_names = [name for name, _ in passwords] auto = Automaton() client = Client(auto) # Test password insertion assert client.get_size() == 0 for i, (name, password) in enumerate(passwords): auto.actions = "rb" client.add(name, password) assert client.get_size() == i + 1 # List password names assert set(client.get_names()) == set(password_names) # Test password retrieval for name, password in passwords: auto.actions = "rb" assert password == client.get_by_name(name) # Test password removal removal_order = [name for name, _ in passwords] random.shuffle(removal_order) names = set(password_names)