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fz2/ZXifm8IYYyNQ3a0eA0EjRNaGF3Xgr9jI+Pwku
cTQZV1cw0YTajXgXHxA/N6ddi035psLjaqTrfq2Sk2UH+gNpfJdvI8YTwCWsf01b
ACoWxNf7GyNrLUjjo6P2kSG27H1IvyBdkL48ghFw2vR3/k6B059I27CLbKDn20as
e6BgJnMea8aqIhbLbPQtfW2OnlfWCyOx2HTUa2F+zGpqWADX9r6J8hnQVjsBD1FG
0TGmCHIqe+BCsBXERdFU3fJh1JjZg5rvdo+gpZ4CAuOupBfrH0f5h7pcQb8oKhLP
wxgYpMGYsElS2ioyam/EqO45fMh1p+tJ/kGPb5sL20ORJc63knW1olI04VEzjY87
esl3/iBHiZ+YKKasJum3KD4gfkglW955Igj+9pUNI73hvoN83yXuhIbOPicZg3Hh
zHTSPwHRiwIVoo8ULFoRdUxgdL9zUdVz/+7R+pyaIQ4RVvQz0QFXH3rjDBow0N1n
QXbPbHR4+golsi6vouzOp7VIrQ==
=0e7b
-----END PGP MESSAGE-----
"""
    tmp = maketemp()
    path = os.path.join(tmp, 'message')
    with file(path, 'w') as f:
        f.write(data)

    g = extract_recipients.extract_recipients(path=path)
    eq(g.next(), 'F262194F862966CD')
    eq(g.next(), 'F05139DE5A850E85')
    assert_raises(StopIteration, g.next)
Пример #2
0
def test_not_found():
    cfg = ConfigParser.RawConfigParser()
    cfg.readfp(StringIO("""\
[fingerprints]
jdoe = B18D D37D 391B D037 B668  A32A C447 4F3C 620F 3B4B
"""))
    e = assert_raises(
        user_to_fpr.UnknownUserError,
        user_to_fpr.user_to_fpr,
        cfg, 'smith',
        )
    eq(str(e), 'Unknown user: smith')
Пример #3
0
def test_simple():
    data = """
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.6 (GNU/Linux)

hQIOA/JiGU+GKWbNEAf+Mj23UceAZbB0F1aiM7/3JJdoEqKqof1L/zdPU3YF1STX
dcGVrERNgLgxk8hheLQUSrTOZ9THhQuFmkWkBkB6NKOn5pElxAOWmB04496Q+F*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2OnlfWCyOx2HTUa2F+zGpqWADX9r6J8hnQVjsBD1FG
0TGmCHIqe+BCsBXERdFU3fJh1JjZg5rvdo+gpZ4CAuOupBfrH0f5h7pcQb8oKhLP
wxgYpMGYsElS2ioyam/EqO45fMh1p+tJ/kGPb5sL20ORJc63knW1olI04VEzjY87
esl3/iBHiZ+YKKasJum3KD4gfkglW955Igj+9pUNI73hvoN83yXuhIbOPicZg3Hh
zHTSPwHRiwIVoo8ULFoRdUxgdL9zUdVz/+7R+pyaIQ4RVvQz0QFXH3rjDBow0N1n
QXbPbHR4+golsi6vouzOp7VIrQ==
=0e7b
-----END PGP MESSAGE-----
"""
    tmp = maketemp()
    path = os.path.join(tmp, 'message')
    with file(path, 'w') as f:
        f.write(data)

    cfg = ordered_config_parser.OrderedRawConfigParser()
    cfg.readfp(StringIO("""\
[access message]
users = tv esa

[fingerprints]
tv = DB74559E2AB7C126FACAA3C4947509D4251AA7AB
esa = 8208 9CF0 7AAB AAC2 C25D  9C70 407A 5DA8 04F6 4D37
"""))

    log = logging.getLogger('sekrit.verify')
    log.setLevel(logging.DEBUG)
    buf = StringIO()
    handler = logging.StreamHandler(buf)
    handler.setLevel(logging.INFO)
    log.addHandler(handler)
    try:
        g = verify.verify(cfg=cfg, path=tmp)
        # no problems
        assert_raises(StopIteration, next, g)
    finally:
        log.removeHandler(handler)
    handler.flush()
    eq(
        buf.getvalue().splitlines(),
        [
            'message: ok: esa tv',
            ],
        )