aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/tests/t-sig-notation.py
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-05-31 14:21:06 +0000
committerJustus Winter <[email protected]>2016-05-31 14:22:31 +0000
commitafa0dd56e1cce64fe08bff3c64b12aecce54fd2d (patch)
treec0bb97f2ab319e192a09b4b918a77926d7b477aa /lang/python/tests/t-sig-notation.py
parentbuild: Fix URL. (diff)
downloadgpgme-afa0dd56e1cce64fe08bff3c64b12aecce54fd2d.tar.gz
gpgme-afa0dd56e1cce64fe08bff3c64b12aecce54fd2d.zip
python: Port more tests.
* lang/python/gpgme.i: Hide length fields of notations. * lang/python/tests/Makefile.am (pytests): Add new tests. * lang/python/tests/t-decrypt-verify.py: New file. * lang/python/tests/t-sig-notation.py: Likewise. * lang/python/tests/t-verify.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/tests/t-sig-notation.py')
-rwxr-xr-xlang/python/tests/t-sig-notation.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/lang/python/tests/t-sig-notation.py b/lang/python/tests/t-sig-notation.py
new file mode 100755
index 00000000..2d832ef2
--- /dev/null
+++ b/lang/python/tests/t-sig-notation.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2016 g10 Code GmbH
+#
+# This file is part of GPGME.
+#
+# GPGME is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPGME is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+import os
+from pyme import core, constants, errors
+import support
+
+expected_notations = {
+ "laughing@me": ("Just Squeeze Me", constants.SIG_NOTATION_HUMAN_READABLE),
+ "[email protected]": ("pgpmime",
+ constants.SIG_NOTATION_HUMAN_READABLE
+ | constants.SIG_NOTATION_CRITICAL),
+ None: ("http://www.gnu.org/policy/", 0),
+}
+
+def check_result(result):
+ assert len(result.signatures) == 1, "Unexpected number of signatures"
+ sig = result.signatures[0]
+ assert len(sig.notations) == len(expected_notations)
+
+ for r in sig.notations:
+ assert not 'name_len' in dir(r)
+ assert not 'value_len' in dir(r)
+ assert r.name in expected_notations
+ value, flags = expected_notations.pop(r.name)
+
+ assert r.value == value, \
+ "Expected {!r}, got {!r}".format(value, r.value)
+ assert r.human_readable \
+ == bool(flags&constants.SIG_NOTATION_HUMAN_READABLE)
+ # xxx notyet
+ #assert r.human_readable \
+ # == bool(flags&constants.SIG_NOTATION_CRITICAL)
+
+ assert len(expected_notations) == 0
+
+support.init_gpgme(constants.PROTOCOL_OpenPGP)
+
+source = core.Data("Hallo Leute\n")
+signed = core.Data()
+
+c = core.Context()
+for name, (value, flags) in expected_notations.items():
+ c.sig_notation_add(name, value, flags)
+
+c.op_sign(source, signed, constants.SIG_MODE_NORMAL)
+
+signed.seek(0, os.SEEK_SET)
+sink = core.Data()
+c.op_verify(signed, None, sink)
+result = c.op_verify_result()
+check_result(result)