Blame SOURCES/gnupg-2.2.18-tests-add-test-cases-for-import-without-uid.patch

4538af
From: Vincent Breitmoser <look@my.amazin.horse>
4538af
Date: Thu, 13 Jun 2019 21:27:41 +0200
4538af
Subject: tests: add test cases for import without uid
4538af
4538af
This commit adds a test case that does the following, in order:
4538af
- Import of a primary key plus user id
4538af
- Check that import of a subkey works, without a user id present in the
4538af
imported key
4538af
- Check that import of a subkey revocation works, without a user id or
4538af
subkey binding signature present in the imported key
4538af
- Check that import of a primary key revocation works, without a user id
4538af
present in the imported key
4538af
4538af
--
4538af
4538af
Note that this test currently fails.  The following changesets will
4538af
fix gpg so that the tests pass.
4538af
4538af
GnuPG-Bug-id: 4393
4538af
Signed-Off-By: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4538af
---
4538af
 tests/openpgp/Makefile.am                          |  1 +
4538af
 tests/openpgp/import-incomplete.scm                | 68 ++++++++++++++++++++++
4538af
 .../import-incomplete/primary+revocation.asc       |  9 +++
4538af
 .../primary+subkey+sub-revocation.asc              | 10 ++++
4538af
 .../import-incomplete/primary+subkey+sub-sig.asc   | 10 ++++
4538af
 .../openpgp/import-incomplete/primary+uid-sig.asc  | 10 ++++
4538af
 tests/openpgp/import-incomplete/primary+uid.asc    | 10 ++++
4538af
 7 files changed, 118 insertions(+)
4538af
 create mode 100755 tests/openpgp/import-incomplete.scm
4538af
 create mode 100644 tests/openpgp/import-incomplete/primary+revocation.asc
4538af
 create mode 100644 tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc
4538af
 create mode 100644 tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc
4538af
 create mode 100644 tests/openpgp/import-incomplete/primary+uid-sig.asc
4538af
 create mode 100644 tests/openpgp/import-incomplete/primary+uid.asc
4538af
4538af
diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
4538af
index f6014c9..6423da1 100644
4538af
--- a/tests/openpgp/Makefile.am
4538af
+++ b/tests/openpgp/Makefile.am
4538af
@@ -78,6 +78,7 @@ XTESTS = \
4538af
 	gpgv-forged-keyring.scm \
4538af
 	armor.scm \
4538af
 	import.scm \
4538af
+	import-incomplete.scm \
4538af
 	import-revocation-certificate.scm \
4538af
 	ecc.scm \
4538af
 	4gb-packet.scm \
4538af
diff --git a/tests/openpgp/import-incomplete.scm b/tests/openpgp/import-incomplete.scm
4538af
new file mode 100755
4538af
index 0000000..727a027
4538af
--- /dev/null
4538af
+++ b/tests/openpgp/import-incomplete.scm
4538af
@@ -0,0 +1,68 @@
4538af
+#!/usr/bin/env gpgscm
4538af
+
4538af
+;; Copyright (C) 2016 g10 Code GmbH
4538af
+;;
4538af
+;; This file is part of GnuPG.
4538af
+;;
4538af
+;; GnuPG is free software; you can redistribute it and/or modify
4538af
+;; it under the terms of the GNU General Public License as published by
4538af
+;; the Free Software Foundation; either version 3 of the License, or
4538af
+;; (at your option) any later version.
4538af
+;;
4538af
+;; GnuPG is distributed in the hope that it will be useful,
4538af
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4538af
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4538af
+;; GNU General Public License for more details.
4538af
+;;
4538af
+;; You should have received a copy of the GNU General Public License
4538af
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
4538af
+
4538af
+(load (in-srcdir "tests" "openpgp" "defs.scm"))
4538af
+(setup-environment)
4538af
+
4538af
+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+uid.asc")))
4538af
+
4538af
+(info "Test import of new subkey, from a certificate without uid")
4538af
+(define keyid "573EA710367356BB")
4538af
+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+subkey+sub-sig.asc")))
4538af
+(tr:do
4538af
+ (tr:pipe-do
4538af
+  (pipe:gpg `(--list-keys --with-colons ,keyid)))
4538af
+ (tr:call-with-content
4538af
+  (lambda (c)
4538af
+    ;; XXX we do not have a regexp library
4538af
+    (unless (any (lambda (line)
4538af
+		   (and (string-prefix? line "sub:")
4538af
+			(string-contains? line "573EA710367356BB")))
4538af
+		 (string-split-newlines c))
4538af
+	    (exit 1)))))
4538af
+
4538af
+(info "Test import of a subkey revocation, from a certificate without uid")
4538af
+(define keyid "573EA710367356BB")
4538af
+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+subkey+sub-revocation.asc")))
4538af
+(tr:do
4538af
+ (tr:pipe-do
4538af
+  (pipe:gpg `(--list-keys --with-colons ,keyid)))
4538af
+ (tr:call-with-content
4538af
+  (lambda (c)
4538af
+    ;; XXX we do not have a regexp library
4538af
+    (unless (any (lambda (line)
4538af
+		   (and (string-prefix? line "sub:r:")
4538af
+			(string-contains? line "573EA710367356BB")))
4538af
+		 (string-split-newlines c))
4538af
+	    (exit 1)))))
4538af
+
4538af
+(info "Test import of revocation, from a certificate without uid")
4538af
+(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "import-incomplete" "primary+revocation.asc")))
4538af
+(tr:do
4538af
+ (tr:pipe-do
4538af
+  (pipe:gpg `(--list-keys --with-colons ,keyid)))
4538af
+ (tr:call-with-content
4538af
+  (lambda (c)
4538af
+    ;; XXX we do not have a regexp library
4538af
+    (unless (any (lambda (line)
4538af
+		   (and (string-prefix? line "pub:r:")
4538af
+			(string-contains? line "0843DA969AA8DAFB")))
4538af
+		 (string-split-newlines c))
4538af
+	    (exit 1)))))
4538af
+
4538af
diff --git a/tests/openpgp/import-incomplete/primary+revocation.asc b/tests/openpgp/import-incomplete/primary+revocation.asc
4538af
new file mode 100644
4538af
index 0000000..6b7b608
4538af
--- /dev/null
4538af
+++ b/tests/openpgp/import-incomplete/primary+revocation.asc
4538af
@@ -0,0 +1,9 @@
4538af
+-----BEGIN PGP PUBLIC KEY BLOCK-----
4538af
+Comment: [E] primary key, revocation signature over primary (no user ID)
4538af
+
4538af
+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
4538af
+631VAN2IeAQgFggAIBYhBLRpj5W82H/gSMzKKQhD2paaqNr7BQJc2ZQZAh0AAAoJ
4538af
+EAhD2paaqNr7qAwA/2jBUpnN0BxwRO/4CrxvrLIsL+C9aSXJUOTv8XkP4lvtAQD3
4538af
+XsDFfFNgEueiTfF7HtOGt5LPmRqVvUpQSMVgJJW6CQ==
4538af
+=tM90
4538af
+-----END PGP PUBLIC KEY BLOCK-----
4538af
diff --git a/tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc b/tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc
4538af
new file mode 100644
4538af
index 0000000..83a51a5
4538af
--- /dev/null
4538af
+++ b/tests/openpgp/import-incomplete/primary+subkey+sub-revocation.asc
4538af
@@ -0,0 +1,10 @@
4538af
+-----BEGIN PGP PUBLIC KEY BLOCK-----
4538af
+Comment: [D] primary key, subkey, subkey revocation (no user ID)
4538af
+
4538af
+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
4538af
+631VAN24OARc2ZQhEgorBgEEAZdVAQUBAQdABsd5ha0AWXdXcSmfeiWIfrNcGqQK
4538af
+j++lwwWDAOlkVicDAQgHiHgEKBYIACAWIQS0aY+VvNh/4EjMyikIQ9qWmqja+wUC
4538af
+XNmnkAIdAgAKCRAIQ9qWmqja+ylaAQDmIKf86BJEq4OpDqU+V9D+wn2cyuxbyWVQ
4538af
+3r9LiL9qNwD/QAjyrhSN8L3Mfq+wdTHo5i0yB9ZCCpHLXSbhCqfWZwQ=
4538af
+=dwx2
4538af
+-----END PGP PUBLIC KEY BLOCK-----
4538af
diff --git a/tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc b/tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc
4538af
new file mode 100644
4538af
index 0000000..dc47a02
4538af
--- /dev/null
4538af
+++ b/tests/openpgp/import-incomplete/primary+subkey+sub-sig.asc
4538af
@@ -0,0 +1,10 @@
4538af
+-----BEGIN PGP PUBLIC KEY BLOCK-----
4538af
+Comment: [B] primary key, subkey, subkey binding sig (no user ID)
4538af
+
4538af
+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
4538af
+631VAN24OARc2ZQhEgorBgEEAZdVAQUBAQdABsd5ha0AWXdXcSmfeiWIfrNcGqQK
4538af
+j++lwwWDAOlkVicDAQgHiHgEGBYIACAWIQS0aY+VvNh/4EjMyikIQ9qWmqja+wUC
4538af
+XNmUIQIbDAAKCRAIQ9qWmqja++vFAP98G1L+1/rWTGbsnxOAV2RocBYIroAvsbkR
4538af
+Ly6FdP8YNwEA7jOgT05CoKIe37MstpOz23mM80AK369Ca3JMmKKCQgg=
4538af
+=xuDu
4538af
+-----END PGP PUBLIC KEY BLOCK-----
4538af
diff --git a/tests/openpgp/import-incomplete/primary+uid-sig.asc b/tests/openpgp/import-incomplete/primary+uid-sig.asc
4538af
new file mode 100644
4538af
index 0000000..134607d
4538af
--- /dev/null
4538af
+++ b/tests/openpgp/import-incomplete/primary+uid-sig.asc
4538af
@@ -0,0 +1,10 @@
4538af
+-----BEGIN PGP PUBLIC KEY BLOCK-----
4538af
+Comment: [C] primary key and self-sig expiring in 2024 (no user ID)
4538af
+
4538af
+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
4538af
+631VAN2IlgQTFggAPgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBLRpj5W8
4538af
+2H/gSMzKKQhD2paaqNr7BQJc2ZR1BQkJZgHcAAoJEAhD2paaqNr79soA/0lWkUsu
4538af
+3NLwgbni6EzJxnTzgeNMpljqNpipHAwfix9hAP93AVtFdC8g7hdUZxawobl9lnSN
4538af
+9ohXOEBWvdJgVv2YAg==
4538af
+=KWIK
4538af
+-----END PGP PUBLIC KEY BLOCK-----
4538af
diff --git a/tests/openpgp/import-incomplete/primary+uid.asc b/tests/openpgp/import-incomplete/primary+uid.asc
4538af
new file mode 100644
4538af
index 0000000..055f300
4538af
--- /dev/null
4538af
+++ b/tests/openpgp/import-incomplete/primary+uid.asc
4538af
@@ -0,0 +1,10 @@
4538af
+-----BEGIN PGP PUBLIC KEY BLOCK-----
4538af
+Comment: [A] primary key, user ID, and self-sig expiring in 2021
4538af
+
4538af
+mDMEXNmUGRYJKwYBBAHaRw8BAQdA75R8VlchvmEd2Iz/8l07RoKUaUPDB71Ao1zZ
4538af
+631VAN20CHRlc3Qga2V5iJYEExYIAD4WIQS0aY+VvNh/4EjMyikIQ9qWmqja+wUC
4538af
+XNmUGQIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRAIQ9qWmqja
4538af
++0G1AQDdQiwhXxjXLMqoth+D4SigVHTJK8ORwifzsy3UE7mPGwD/aZ67XbAF/lgI
4538af
+kv2O1Jo0u9BL9RNNF+L0DM7rAFbfMAs=
4538af
+=1eII
4538af
+-----END PGP PUBLIC KEY BLOCK-----