diff options
| author | Justus Winter <[email protected]> | 2017-02-17 16:07:05 +0000 | 
|---|---|---|
| committer | Justus Winter <[email protected]> | 2017-02-17 16:08:03 +0000 | 
| commit | 15fbac9e72a4d1bff9a3b9e9822f9175b09fbcd5 (patch) | |
| tree | cee4dfffa19f9ad95b51afb3e33b73d2b69fa9da /lang/python/tests | |
| parent | python: Support quick key signing. (diff) | |
| download | gpgme-15fbac9e72a4d1bff9a3b9e9822f9175b09fbcd5.tar.gz gpgme-15fbac9e72a4d1bff9a3b9e9822f9175b09fbcd5.zip | |
python: Support manipulating the TOFU policy.
* NEWS: Update.
* doc/gpgme.texi: Fix typos.
* lang/python/gpg/constants/__init__.py: Import new files.
* lang/python/gpg/constants/tofu/__init__.py: New file.
* lang/python/gpg/constants/tofu/policy.py: New file.
* lang/python/gpg/core.py (Context.key_tofu_policy): New function.
* lang/python/gpgme.i: Nice reprs for gpgme_tofu_info_t.
* lang/python/setup.py.in: Install new package.
* lang/python/tests/t-quick-key-manipulation.py: Extend test.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/tests')
| -rwxr-xr-x | lang/python/tests/t-quick-key-manipulation.py | 31 | 
1 files changed, 31 insertions, 0 deletions
| diff --git a/lang/python/tests/t-quick-key-manipulation.py b/lang/python/tests/t-quick-key-manipulation.py index 12c18ce5..d7d2bd4f 100755 --- a/lang/python/tests/t-quick-key-manipulation.py +++ b/lang/python/tests/t-quick-key-manipulation.py @@ -90,3 +90,34 @@ with support.EphemeralContext() as ctx:          assert False, "Expected an error but got none"      except gpg.errors.GpgError:          pass + +    # Check setting the TOFU policy. +    with open("gpg.conf", "a") as handle: +        handle.write("trust-model tofu+pgp\n") + +    for name, policy in [(name, getattr(gpg.constants.tofu.policy, name)) +                         for name in filter(lambda x: not x.startswith('__'), +                                            dir(gpg.constants.tofu.policy))]: +        if policy == gpg.constants.tofu.policy.NONE: +            # We must not set the policy to NONE. +            continue + +        ctx.key_tofu_policy(key, policy) + +        keys = list(ctx.keylist(key.uids[0].uid, +                                mode=(gpg.constants.keylist.mode.LOCAL +                                      |gpg.constants.keylist.mode.WITH_TOFU))) +        assert len(keys) == 1 + +        if policy == gpg.constants.tofu.policy.AUTO: +            # We cannot check that it is set to AUTO. +            continue + +        for uid in keys[0].uids: +            if uid.uid == alpha: +                # TOFU information of revoked UIDs is not updated. +                # XXX: Is that expected? +                continue +            assert uid.tofu[0].policy == policy, \ +                "Expected policy {0} ({1}), got {2}".format(policy, name, +                                                            uid.tofu[0].policy) | 
