nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1From: Vincent Breitmoser <look@my.amazin.horse>
2Date: Thu, 13 Jun 2019 21:27:41 +0200
3Subject: tests: add test cases for import without uid
4
5This commit adds a test case that does the following, in order:
6- Import of a primary key plus user id
7- Check that import of a subkey works, without a user id present in the
8imported key
9- Check that import of a subkey revocation works, without a user id or
10subkey binding signature present in the imported key
11- Check that import of a primary key revocation works, without a user id
12present in the imported key
13
14--
15
16Note that this test currently fails. The following changesets will
17fix gpg so that the tests pass.
18
19GnuPG-Bug-id: 4393
20Signed-Off-By: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
21---
22 tests/openpgp/Makefile.am | 1 +
23 tests/openpgp/import-incomplete.scm | 68 ++++++++++++++++++++++
24 .../import-incomplete/primary+revocation.asc | 9 +++
25 .../primary+subkey+sub-revocation.asc | 10 ++++
26 .../import-incomplete/primary+subkey+sub-sig.asc | 10 ++++
27 .../openpgp/import-incomplete/primary+uid-sig.asc | 10 ++++
28 tests/openpgp/import-incomplete/primary+uid.asc | 10 ++++
29 7 files changed, 118 insertions(+)
30 create mode 100755 tests/openpgp/import-incomplete.scm
31 create mode 100644 tests/openpgp/import-incomplete/primary+revocation.asc
32 create mode 100644 tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc
33 create mode 100644 tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc
34 create mode 100644 tests/openpgp/import-incomplete/primary+uid-sig.asc
35 create mode 100644 tests/openpgp/import-incomplete/primary+uid.asc
36
37diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
38index f6014c9..6423da1 100644
39--- a/tests/openpgp/Makefile.am
40+++ b/tests/openpgp/Makefile.am
41@@ -78,6 +78,7 @@ XTESTS = \
42 gpgv-forged-keyring.scm \
43 armor.scm \
44 import.scm \
45+ import-incomplete.scm \
46 import-revocation-certificate.scm \
47 ecc.scm \
48 4gb-packet.scm \
49diff --git a/tests/openpgp/import-incomplete.scm b/tests/openpgp/import-incomplete.scm
50new file mode 100755
51index 0000000..727a027
52--- /dev/null
53+++ b/tests/openpgp/import-incomplete.scm
54@@ -0,0 +1,68 @@
55+#!/usr/bin/env gpgscm
56+
57+;; Copyright (C) 2016 g10 Code GmbH
58+;;
59+;; This file is part of GnuPG.
60+;;
61+;; GnuPG is free software; you can redistribute it and/or modify
62+;; it under the terms of the GNU General Public License as published by
63+;; the Free Software Foundation; either version 3 of the License, or
64+;; (at your option) any later version.
65+;;
66+;; GnuPG is distributed in the hope that it will be useful,
67+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
68+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69+;; GNU General Public License for more details.
70+;;
71+;; You should have received a copy of the GNU General Public License
72+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
73+
74+(load (in-srcdir "tests" "openpgp" "defs.scm"))
75+(setup-environment)
76+
77+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+uid.asc")))
78+
79+(info "Test import of new subkey, from a certificate without uid")
80+(define keyid "573EA710367356BB")
81+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+subkey+sub-sig.asc")))
82+(tr:do
83+ (tr:pipe-do
84+ (pipe:gpg `(--list-keys --with-colons ,keyid)))
85+ (tr:call-with-content
86+ (lambda (c)
87+ ;; XXX we do not have a regexp library
88+ (unless (any (lambda (line)
89+ (and (string-prefix? line "sub:")
90+ (string-contains? line "573EA710367356BB")))
91+ (string-split-newlines c))
92+ (exit 1)))))
93+
94+(info "Test import of a subkey revocation, from a certificate without uid")
95+(define keyid "573EA710367356BB")
96+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+subkey+sub-revocation.asc")))
97+(tr:do
98+ (tr:pipe-do
99+ (pipe:gpg `(--list-keys --with-colons ,keyid)))
100+ (tr:call-with-content
101+ (lambda (c)
102+ ;; XXX we do not have a regexp library
103+ (unless (any (lambda (line)
104+ (and (string-prefix? line "sub:r:")
105+ (string-contains? line "573EA710367356BB")))
106+ (string-split-newlines c))
107+ (exit 1)))))
108+
109+(info "Test import of revocation, from a certificate without uid")
110+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+revocation.asc")))
111+(tr:do
112+ (tr:pipe-do
113+ (pipe:gpg `(--list-keys --with-colons ,keyid)))
114+ (tr:call-with-content
115+ (lambda (c)
116+ ;; XXX we do not have a regexp library
117+ (unless (any (lambda (line)
118+ (and (string-prefix? line "pub:r:")
119+ (string-contains? line "0843DA969AA8DAFB")))
120+ (string-split-newlines c))
121+ (exit 1)))))
122+
123diff --git a/tests/openpgp/import-incomplete/primary+revocation.asc b/tests/openpgp/import-incomplete/primary+revocation.asc
124new file mode 100644
125index 0000000..6b7b608
126--- /dev/null
127+++ b/tests/openpgp/import-incomplete/primary+revocation.asc
128@@ -0,0 +1,9 @@
129+-----BEGIN PGP PUBLIC KEY BLOCK-----
130+Comment: [E] primary key, revocation signature over primary (no user ID)
131+
132+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
133+631VAN2IeAQgFggAIBYhBLRpj5W82H/gSMzKKQhD2paaqNr7BQJc2ZQZAh0AAAoJ
134+EAhD2paaqNr7qAwA/2jBUpnN0BxwRO/4CrxvrLIsL+C9aSXJUOTv8XkP4lvtAQD3
135+XsDFfFNgEueiTfF7HtOGt5LPmRqVvUpQSMVgJJW6CQ==
136+=tM90
137+-----END PGP PUBLIC KEY BLOCK-----
138diff --git a/tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc b/tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc
139new file mode 100644
140index 0000000..83a51a5
141--- /dev/null
142+++ b/tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc
143@@ -0,0 +1,10 @@
144+-----BEGIN PGP PUBLIC KEY BLOCK-----
145+Comment: [D] primary key, subkey, subkey revocation (no user ID)
146+
147+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
148+631VAN24OARc2ZQhEgorBgEEAZdVAQUBAQdABsd5ha0AWXdXcSmfeiWIfrNcGqQK
149+j++lwwWDAOlkVicDAQgHiHgEKBYIACAWIQS0aY+VvNh/4EjMyikIQ9qWmqja+wUC
150+XNmnkAIdAgAKCRAIQ9qWmqja+ylaAQDmIKf86BJEq4OpDqU+V9D+wn2cyuxbyWVQ
151+3r9LiL9qNwD/QAjyrhSN8L3Mfq+wdTHo5i0yB9ZCCpHLXSbhCqfWZwQ=
152+=dwx2
153+-----END PGP PUBLIC KEY BLOCK-----
154diff --git a/tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc b/tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc
155new file mode 100644
156index 0000000..dc47a02
157--- /dev/null
158+++ b/tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc
159@@ -0,0 +1,10 @@
160+-----BEGIN PGP PUBLIC KEY BLOCK-----
161+Comment: [B] primary key, subkey, subkey binding sig (no user ID)
162+
163+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
164+631VAN24OARc2ZQhEgorBgEEAZdVAQUBAQdABsd5ha0AWXdXcSmfeiWIfrNcGqQK
165+j++lwwWDAOlkVicDAQgHiHgEGBYIACAWIQS0aY+VvNh/4EjMyikIQ9qWmqja+wUC
166+XNmUIQIbDAAKCRAIQ9qWmqja++vFAP98G1L+1/rWTGbsnxOAV2RocBYIroAvsbkR
167+Ly6FdP8YNwEA7jOgT05CoKIe37MstpOz23mM80AK369Ca3JMmKKCQgg=
168+=xuDu
169+-----END PGP PUBLIC KEY BLOCK-----
170diff --git a/tests/openpgp/import-incomplete/primary+uid-sig.asc b/tests/openpgp/import-incomplete/primary+uid-sig.asc
171new file mode 100644
172index 0000000..134607d
173--- /dev/null
174+++ b/tests/openpgp/import-incomplete/primary+uid-sig.asc
175@@ -0,0 +1,10 @@
176+-----BEGIN PGP PUBLIC KEY BLOCK-----
177+Comment: [C] primary key and self-sig expiring in 2024 (no user ID)
178+
179+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
180+631VAN2IlgQTFggAPgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBLRpj5W8
181+2H/gSMzKKQhD2paaqNr7BQJc2ZR1BQkJZgHcAAoJEAhD2paaqNr79soA/0lWkUsu
182+3NLwgbni6EzJxnTzgeNMpljqNpipHAwfix9hAP93AVtFdC8g7hdUZxawobl9lnSN
183+9ohXOEBWvdJgVv2YAg==
184+=KWIK
185+-----END PGP PUBLIC KEY BLOCK-----
186diff --git a/tests/openpgp/import-incomplete/primary+uid.asc b/tests/openpgp/import-incomplete/primary+uid.asc
187new file mode 100644
188index 0000000..055f300
189--- /dev/null
190+++ b/tests/openpgp/import-incomplete/primary+uid.asc
191@@ -0,0 +1,10 @@
192+-----BEGIN PGP PUBLIC KEY BLOCK-----
193+Comment: [A] primary key, user ID, and self-sig expiring in 2021
194+
195+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
196+631VAN20CHRlc3Qga2V5iJYEExYIAD4WIQS0aY+VvNh/4EjMyikIQ9qWmqja+wUC
197+XNmUGQIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRAIQ9qWmqja
198++0G1AQDdQiwhXxjXLMqoth+D4SigVHTJK8ORwifzsy3UE7mPGwD/aZ67XbAF/lgI
199+kv2O1Jo0u9BL9RNNF+L0DM7rAFbfMAs=
200+=1eII
201+-----END PGP PUBLIC KEY BLOCK-----