예제 #1
0
파일: test_gpg.py 프로젝트: catch22/pw
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
파일: test_gpg.py 프로젝트: catch22/pw
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