Пример #1
0
def test_encrypt(dirname, filename):
    # load unencrypted password file
    unencrypted = open(os.path.join(dirname, "db.pw"), "rb").read()

    # encrypt into temporary file, decrypt again, and compare result
    fp = tempfile.NamedTemporaryFile(delete=False, suffix=filename)
    try:
        fp.close()

        encrypt(recipient="test.user@localhost", dest_path=fp.name, content=unencrypted)
        decrypted = decrypt(fp.name)
        assert decrypted == unencrypted
    finally:
        os.unlink(fp.name)
Пример #2
0
def test_decrypt(dirname, filename):
    # manually decrypt password file & compare with unencrypted file in repository
    decrypted = decrypt(os.path.join(dirname, filename))
    unencrypted = open(os.path.join(dirname, "db.pw"), "rb").read()
    assert decrypted == unencrypted