chiark / gitweb /
gnupg2 (2.1.17-3) unstable; urgency=medium
[gnupg2.git] / tests / fake-pinentries / fake-pinentry.py
1 #!/usr/bin/env python
2 # Use this for your test suites when a python interpreter is available.
3 #
4 # The encrypted keys in your test suite that you expect to work must
5 # be locked with a passphrase of "passphrase"
6 #
7 # Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
8 #
9 # License: Creative Commons Zero ("Public Domain Dedication") --
10 # Anyone may reuse it, modify it, redistribute it for any purpose.
11
12 import sys, os
13
14 # turn off buffering:
15 sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)
16 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
17
18 print("OK This is only for test suites, and should never be used in production")
19 while True:
20     ln = sys.stdin.readline()
21     if (ln == ''):
22         break
23     ln = ln.lower()
24     if (ln.strip() == '') or (ln.startswith('#')):
25         continue
26     if (ln.startswith('getpin')):
27         sys.stdout.write('D passphrase\n')
28     sys.stdout.write('OK\n')
29     if (ln.startswith('bye')):
30         break