コード例 #1
0
 def test_malformed_base64(self):
     # 'asdf' base64-encoded becomes 'YXNkZg=='
     # remove one of the pad characters and we should get a PGPError
     data = '-----BEGIN PGP SOMETHING-----\n' \
            '\n' \
            'YXNkZg=\n' \
            '=ZEO6\n' \
            '-----END PGP SOMETHING-----\n'
     with pytest.raises(PGPError):
         Armorable.ascii_unarmor(data)
コード例 #2
0
 def test_malformed_base64(self):
     # 'asdf' base64-encoded becomes 'YXNkZg=='
     # remove one of the pad characters and we should get a PGPError
     data = '-----BEGIN PGP SOMETHING-----\n' \
            '\n' \
            'YXNkZg=\n' \
            '=ZEO6\n' \
            '-----END PGP SOMETHING-----\n'
     with pytest.raises(PGPError):
         Armorable.ascii_unarmor(data)
コード例 #3
0
ファイル: crypto.py プロジェクト: oliverFU/pyac
def list_packets_pgpy(keydata):
    if isinstance(keydata, bytes):
        data = bytearray(keydata)
    elif isinstance(keydata, str):
        data = Armorable.ascii_unarmor(keydata)['body']
    packets = []
    while data:
        packets.append(Packet(data))
    return packets
コード例 #4
0
ファイル: test_99_regressions.py プロジェクト: strayge/PGPy
def test_oneline_cleartext(sf, cleartext):
    with open(sf) as of:
        oc = of.read()

    dearmor = Armorable.ascii_unarmor(oc)
    # It is a signature
    assert dearmor['magic'] == 'SIGNATURE'
    # No newline at the end
    assert dearmor['cleartext'] == cleartext
コード例 #5
0
def test_oneline_cleartext(sf, cleartext):
    with open(sf) as of:
        oc = of.read()

    dearmor = Armorable.ascii_unarmor(oc)
    # It is a signature
    assert dearmor['magic'] == 'SIGNATURE'
    # No newline at the end
    assert dearmor['cleartext'] == cleartext
コード例 #6
0
    def test_not_armor(self, text):
        mode = 'r' if text in txt else 'rb'
        with open(text, mode) as tf:
            tc = tf.read()

        assert not Armorable.is_armor(tc)
コード例 #7
0
    def test_is_armor(self, armored):
        with open(armored) as af:
            ac = af.read()

        assert Armorable.is_armor(ac)
コード例 #8
0
    def test_not_armor(self, text):
        mode = 'r' if text in txt else 'rb'
        with open(text, mode) as tf:
            tc = tf.read()

        assert not Armorable.is_armor(tc)
コード例 #9
0
    def test_is_armor(self, armored):
        with open(armored) as af:
            ac = af.read()

        assert Armorable.is_armor(ac)
コード例 #10
0
ファイル: test_99_regressions.py プロジェクト: strayge/PGPy
def test_armorable_empty_str():
    with pytest.raises(ValueError, message='Expected: ASCII-armored PGP data'):
        Armorable.ascii_unarmor('')
コード例 #11
0
def test_armorable_empty_str():
    with pytest.raises(ValueError, message='Expected: ASCII-armored PGP data'):
        Armorable.ascii_unarmor('')