From a6c48304b589bbd9abfbdfb4a2f8c8b2f026fbd2 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Mon, 5 Dec 2022 21:09:21 -0600 Subject: [PATCH] Revise mock tool testsuite to prepare for additional tests A mock GPG for handling keyrings will soon be added to support testing the keymaster tool currently under early development. --- testsuite/lib/mock.exp | 5 ++-- testsuite/mock.gpgv/sign.exp | 48 ++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/testsuite/lib/mock.exp b/testsuite/lib/mock.exp index 9248d45..223faea 100644 --- a/testsuite/lib/mock.exp +++ b/testsuite/lib/mock.exp @@ -1,4 +1,4 @@ -# DejaGnu tool init file for testing gpgv mock tests +# DejaGnu tool init file for testing mock GPG # Copyright (C) 2021, 2022 Jacob Bachmeyer # @@ -20,10 +20,11 @@ set MINLOGD [testsuite file -source -top lib exec minlogd.pl] set MINSMTPD [testsuite file -source -top lib exec minsmtpd.tcl] +set MOCKGPG [testsuite file -source -top lib exec mockgpg] set MOCKGPGV [testsuite file -source -top lib exec mockgpgv] set GNUPGHOME [file join \ [file dirname [testsuite file -object -top]] \ - test.tmp gpgv] + test.tmp gpg] set ::env(GNUPGHOME) $GNUPGHOME load_lib mockgpg.exp diff --git a/testsuite/mock.gpgv/sign.exp b/testsuite/mock.gpgv/sign.exp index 4e5f1cb..d1340ff 100644 --- a/testsuite/mock.gpgv/sign.exp +++ b/testsuite/mock.gpgv/sign.exp @@ -19,7 +19,7 @@ file mkdir $GNUPGHOME -write_test_keyring [file join $GNUPGHOME dg1.gpg] { +write_test_keyring [file join $GNUPGHOME dgS1.gpg] { { id 1001 name {test 1-1} } { id 1002 name {test 1-2} } { id 1003 name {test 1-3} expires {+5 minutes} } @@ -29,7 +29,7 @@ write_test_keyring [file join $GNUPGHOME dg1.gpg] { is revoked expired {5 minutes ago} } } -write_test_keyring [file join $GNUPGHOME dg2.gpg] { +write_test_keyring [file join $GNUPGHOME dgS2.gpg] { { id 1011 name {test 2-1 (primary)} } { id 1012 name {test 2-2 (subkey)} subkey-of 1011 } { id 1013 name {test 2-3 (subkey)} subkey-of 1011 expires {+5 minutes} } @@ -142,7 +142,7 @@ proc do_gpgv_test { Name stem keyrings exitCode signature assess expect } { # -do_gpgv_test "unknown key used for signature" t0a {dg1.gpg dg2.gpg} 2 \ +do_gpgv_test "unknown key used for signature" t0a {dgS1.gpg dgS2.gpg} 2 \ [make_test_signature good 00 8765 "5 minutes ago"] { sighdr "signature header" ERRSIG "ERRSIG status" NO_PUBKEY "NO_PUBKEY status" keynotfound "key not found message" @@ -164,7 +164,7 @@ do_gpgv_test "unknown key used for signature" t0a {dg1.gpg dg2.gpg} 2 \ exp_continue } } -run_gpgv_test "detached signature without signed file" t0b {dg1.gpg dg2.gpg} 2 \ +run_gpgv_test "detached signature without signed file" t0b {dgS1.gpg dgS2.gpg} 2 \ { put_file [file join $test_dir t0b.sig] \ [sign_test_file t0b \ [make_test_signature good 00 1001 "5 minutes ago"]] @@ -180,7 +180,7 @@ run_gpgv_test "detached signature without signed file" t0b {dg1.gpg dg2.gpg} 2 \ exp_continue } } -run_gpgv_test "detached signature with missing signed file" t0c {dg1.gpg} 2 \ +run_gpgv_test "detached signature with missing signed file" t0c {dgS1.gpg} 2 \ { put_file [file join $test_dir t0c.sig] \ [sign_test_file t0c \ [make_test_signature good 00 1001 "5 minutes ago"]] @@ -196,7 +196,7 @@ run_gpgv_test "detached signature with missing signed file" t0c {dg1.gpg} 2 \ exp_continue } } -run_gpgv_test "all signed files missing" t0d {dg1.gpg} 2 \ +run_gpgv_test "all signed files missing" t0d {dgS1.gpg} 2 \ { put_file [file join $test_dir t0d] $Name } {inline detached} { cantopen "missing file message" failuremsg "verify failure message" } { @@ -210,7 +210,7 @@ run_gpgv_test "all signed files missing" t0d {dg1.gpg} 2 \ } } -do_gpgv_test "valid signature" t1a {dg1.gpg} 0 \ +do_gpgv_test "valid signature" t1a {dgS1.gpg} 0 \ [make_test_signature good 00 1001 "5 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" SIG_ID "SIG_ID status" @@ -237,7 +237,7 @@ do_gpgv_test "valid signature" t1a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "valid signature from subkey" t1b {dg2.gpg} 0 \ +do_gpgv_test "valid signature from subkey" t1b {dgS2.gpg} 0 \ [make_test_signature good 80 1012 "5 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" SIG_ID "SIG_ID status" @@ -265,7 +265,7 @@ do_gpgv_test "valid signature from subkey" t1b {dg2.gpg} 0 \ } } -do_gpgv_test "bad signature" t2a {dg1.gpg} 1 \ +do_gpgv_test "bad signature" t2a {dgS1.gpg} 1 \ [make_test_signature bad 01 1002 "5 minutes ago"] { sighdr "signature header" badsigmsg "bad signature message" BADSIG "BADSIG status" @@ -283,7 +283,7 @@ do_gpgv_test "bad signature" t2a {dg1.gpg} 1 \ exp_continue } } -do_gpgv_test "bad signature from subkey" t2b {dg2.gpg} 1 \ +do_gpgv_test "bad signature from subkey" t2b {dgS2.gpg} 1 \ [make_test_signature bad 01 1012 "5 minutes ago"] { sighdr "signature header" badsigmsg "bad signature message" BADSIG "BADSIG status" @@ -302,7 +302,7 @@ do_gpgv_test "bad signature from subkey" t2b {dg2.gpg} 1 \ } } -do_gpgv_test "expired signature" t3a {dg1.gpg} 0 \ +do_gpgv_test "expired signature" t3a {dgS1.gpg} 0 \ [make_test_signature good 02 1001 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -334,7 +334,7 @@ do_gpgv_test "expired signature" t3a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "expired signature from subkey" t3b {dg2.gpg} 0 \ +do_gpgv_test "expired signature from subkey" t3b {dgS2.gpg} 0 \ [make_test_signature good 82 1012 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -367,7 +367,7 @@ do_gpgv_test "expired signature from subkey" t3b {dg2.gpg} 0 \ } } -do_gpgv_test "good signature from expired key" t4a {dg1.gpg} 0 \ +do_gpgv_test "good signature from expired key" t4a {dgS1.gpg} 0 \ [make_test_signature good 03 1004 "6 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" KEYEXPIRED "KEYEXPIRED status" SIG_ID "SIG_ID status" @@ -398,7 +398,7 @@ do_gpgv_test "good signature from expired key" t4a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "good signature from expired subkey" t4b {dg2.gpg} 0 \ +do_gpgv_test "good signature from expired subkey" t4b {dgS2.gpg} 0 \ [make_test_signature good 83 1014 "6 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" KEYEXPIRED "KEYEXPIRED status" SIG_ID "SIG_ID status" @@ -430,7 +430,7 @@ do_gpgv_test "good signature from expired subkey" t4b {dg2.gpg} 0 \ } } -do_gpgv_test "expired signature from expired key" t5a {dg1.gpg} 0 \ +do_gpgv_test "expired signature from expired key" t5a {dgS1.gpg} 0 \ [make_test_signature good 04 1004 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -466,7 +466,7 @@ do_gpgv_test "expired signature from expired key" t5a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "expired signature from expired subkey" t5b {dg2.gpg} 0 \ +do_gpgv_test "expired signature from expired subkey" t5b {dgS2.gpg} 0 \ [make_test_signature good 84 1014 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -503,7 +503,7 @@ do_gpgv_test "expired signature from expired subkey" t5b {dg2.gpg} 0 \ } } -do_gpgv_test "signature from revoked key" t6a {dg1.gpg} 0 \ +do_gpgv_test "signature from revoked key" t6a {dgS1.gpg} 0 \ [make_test_signature good 05 1005 "5 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" SIG_ID "SIG_ID status" @@ -530,7 +530,7 @@ do_gpgv_test "signature from revoked key" t6a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "signature from revoked subkey" t6b {dg2.gpg} 0 \ +do_gpgv_test "signature from revoked subkey" t6b {dgS2.gpg} 0 \ [make_test_signature good 85 1015 "5 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" SIG_ID "SIG_ID status" @@ -558,7 +558,7 @@ do_gpgv_test "signature from revoked subkey" t6b {dg2.gpg} 0 \ } } -do_gpgv_test "expired signature from revoked key" t7a {dg1.gpg} 0 \ +do_gpgv_test "expired signature from revoked key" t7a {dgS1.gpg} 0 \ [make_test_signature good 06 1005 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -590,7 +590,7 @@ do_gpgv_test "expired signature from revoked key" t7a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "expired signature from revoked subkey" t7b {dg2.gpg} 0 \ +do_gpgv_test "expired signature from revoked subkey" t7b {dgS2.gpg} 0 \ [make_test_signature good 86 1015 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -623,7 +623,7 @@ do_gpgv_test "expired signature from revoked subkey" t7b {dg2.gpg} 0 \ } } -do_gpgv_test "signature from revoked expired key" t8a {dg1.gpg} 0 \ +do_gpgv_test "signature from revoked expired key" t8a {dgS1.gpg} 0 \ [make_test_signature good 07 1006 "6 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" KEYEXPIRED "KEYEXPIRED status" SIG_ID "SIG_ID status" @@ -654,7 +654,7 @@ do_gpgv_test "signature from revoked expired key" t8a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "signature from revoked expired subkey" t8b {dg2.gpg} 0 \ +do_gpgv_test "signature from revoked expired subkey" t8b {dgS2.gpg} 0 \ [make_test_signature good 87 1016 "6 minutes ago"] { sighdr "signature header" goodsigmsg "good signature message" KEYEXPIRED "KEYEXPIRED status" SIG_ID "SIG_ID status" @@ -686,7 +686,7 @@ do_gpgv_test "signature from revoked expired subkey" t8b {dg2.gpg} 0 \ } } -do_gpgv_test "expired signature from revoked key" t9a {dg1.gpg} 0 \ +do_gpgv_test "expired signature from revoked key" t9a {dgS1.gpg} 0 \ [make_test_signature good 08 1006 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" @@ -722,7 +722,7 @@ do_gpgv_test "expired signature from revoked key" t9a {dg1.gpg} 0 \ exp_continue } } -do_gpgv_test "expired signature from expired subkey" t9b {dg2.gpg} 0 \ +do_gpgv_test "expired signature from expired subkey" t9b {dgS2.gpg} 0 \ [make_test_signature good 88 1016 "10 minutes ago" expired "5 minutes ago"] { sighdr "signature header" expsigmsg "expired signature message" sigexpmsg "signature expiration message" -- 2.25.1