1 # Copyright (C) 2016 g10 Code GmbH
3 # This file is part of GPGME.
5 # GPGME is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # GPGME is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 from __future__ import absolute_import, print_function, unicode_literals
19 del absolute_import, print_function, unicode_literals
26 alpha = "A0FF4590BB6122EDEF6E3C542D727CC768697734"
27 bob = "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2"
28 encrypt_only = "F52770D5C4DB41408D918C9F920572769B9FE19C"
29 sign_only = "7CCA20CCDE5394CEE71C9F0BFED153F12F18F45D"
30 no_such_key = "A" * 40
32 def make_filename(name):
33 return os.path.join(os.environ['top_srcdir'], 'tests', 'gpg', name)
36 return os.path.join(os.environ['srcdir'], name)
38 def init_gpgme(proto):
39 gpg.core.engine_check_version(proto)
41 verbose = int(os.environ.get('verbose', 0)) > 1
45 # See if it is a file-like object.
46 data.seek(0, os.SEEK_SET)
51 sys.stdout.buffer.write(data)
53 def mark_key_trusted(ctx, key):
56 self.steps = ["trust", "save"]
57 def edit(self, status, args, out):
58 if args == "keyedit.prompt":
59 result = self.steps.pop(0)
60 elif args == "edit_ownertrust.value":
62 elif args == "edit_ownertrust.set_ultimate.okay":
64 elif args == "keyedit.save.okay":
69 with gpg.Data() as sink:
70 ctx.op_edit(key, Editor().edit, sink, sink)