Example #1
0
def test_clone():
    a = Fingerprint.from_hex(hexy)
    b = a.copy()
    del a
    c = b.copy()
    del b
    assert c.hex() == hexy
Example #2
0
def test_bad_hex():
    try:
        f = Fingerprint.from_hex("bad hex")
    except:
        pass
    else:
        raise "Expected exception"
Example #3
0
from os.path import join
from tempfile import TemporaryDirectory

from sequoia.core import Context, NetworkPolicy, Reader, Writer
from sequoia.openpgp import ArmorReader, Fingerprint, TPK, PacketPile

pgp = "../../../openpgp/tests/data/keys/testy.pgp"
asc = "../../../openpgp/tests/data/keys/testy.asc"
fp = Fingerprint.from_hex("3E8877C877274692975189F5D03F6F865226FE8B")


def test_from_reader():
    ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True)
    r = Reader.open(ctx, pgp)
    t = TPK.from_reader(ctx, r)
    assert t.fingerprint() == fp


def test_from_armor_reader():
    ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True)
    k = open(asc, "rb").read()
    r = Reader.from_bytes(ctx, k)
    r = ArmorReader.new(ctx, r)
    t = TPK.from_reader(ctx, r)
    assert t.fingerprint() == fp


def test_from_file():
    ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True)
    t = TPK.open(ctx, pgp)
    assert t.fingerprint() == fp
Example #4
0
def test_from_bytes():
    f = Fingerprint.from_bytes(binary)
    assert str(f) == pretty
    assert f.hex() == hexy
Example #5
0
def test_hash():
    a = Fingerprint.from_hex(hexy)
    b = Fingerprint.from_hex(hexy)
    assert hash(a) == hash(b)
Example #6
0
def test_equals():
    a = Fingerprint.from_hex(hexy)
    b = Fingerprint.from_hex(hexy)
    assert a == b
Example #7
0
def test_to_keyid():
    f = Fingerprint.from_hex(hexy)
    assert f.keyid().hex() == "247F6DABC84914FE"
Example #8
0
def test_from_hex():
    f = Fingerprint.from_hex(hexy)
    assert str(f) == pretty
    assert f.hex() == hexy