The secret key material in this test comes from https://datatracker.ietf.org/doc/draft-bre-openpgp-samples/
Signed-off-by: Daniel Kahn Gillmor <d...@fifthhorseman.net> --- debian/control | 1 + tests/email-print-mime-structure.sh | 17 +++- tests/email-print-mime-structure/bob.key | 82 +++++++++++++++++++ .../email-print-mime-structure/encrypted.eml | 37 +++++++++ .../email-print-mime-structure/encrypted.out | 9 ++ .../encrypted.pgpkey | 1 + 6 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 tests/email-print-mime-structure/bob.key create mode 100644 tests/email-print-mime-structure/encrypted.eml create mode 100644 tests/email-print-mime-structure/encrypted.out create mode 120000 tests/email-print-mime-structure/encrypted.pgpkey diff --git a/debian/control b/debian/control index bf49458..2576d6c 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,7 @@ Build-Depends: perl, python3 <!nocheck>, python3-argcomplete, + python3-pgpy <!nocheck>, Vcs-Git: https://git.spwhitton.name/mailscripts Vcs-Browser: https://git.spwhitton.name/mailscripts diff --git a/tests/email-print-mime-structure.sh b/tests/email-print-mime-structure.sh index 5efa2ca..0c0bb50 100755 --- a/tests/email-print-mime-structure.sh +++ b/tests/email-print-mime-structure.sh @@ -2,7 +2,20 @@ set -e +test_eml() { + message="$1" + shift + diff -u "$message.out" <(./email-print-mime-structure "$@" < "$message.eml") +} + for eml in tests/email-print-mime-structure/*.eml; do - printf "Testing %s\n" "${eml##*/}" - diff -u "${eml%%.eml}.out" <(./email-print-mime-structure < "$eml") + base="${eml%%.eml}" + pgpkey="$base.pgpkey" + if [ -e "$pgpkey" ]; then + printf "Testing %s (PGPy)\n" "${eml##*/}" + test_eml "$base" --pgpkey "$pgpkey" + else + printf "Testing %s\n" "${eml##*/}" + test_eml "$base" + fi done diff --git a/tests/email-print-mime-structure/bob.key b/tests/email-print-mime-structure/bob.key new file mode 100644 index 0000000..59e981b --- /dev/null +++ b/tests/email-print-mime-structure/bob.key @@ -0,0 +1,82 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- +Comment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r6AV9hAd8RWXMchJLaExK9J5SRawSg671ObAU24SdY +vMQ9Z4kAQ2+1ReUZzf3ogSMRZtMT+d18gT6L90/y+APZIaoArLPhebIAGq39HLmJ +26x3z0WAgrpA1kNsjXEXkoiZGPLKIGoe3hqJAbYEGAEKACAWIQTRpm4aI7GCyZgP +eIz7/MgqAV5zMAUCXaWc8gIbDAAKCRD7/MgqAV5zMOn/C/9ugt+HZIwX308zI+QX +c5vDLReuzmJ3ieE0DMO/uNSC+K1XEioSIZP91HeZJ2kbT9nn9fuReuoff0T0Dief +rbwcIQQHFFkrqSp1K3VWmUGp2JrUsXFVdjy/fkBIjTd7c5boWljv/6wAsSfiv2V0 +JSM8EFU6TYXxswGjFVfc6X97tJNeIrXL+mpSmPPqy2bztcCCHkWS5lNLWQw+R7Vg +71Fe6yBSNVrqC2/imYG2J9zlowjx1XU63Wdgqp2Wxt0l8OmsB/W80S1fRF5G4SDH +s9HXglXXqPsBRZJYfP+VStm9L5P/sKjCcX6WtZR7yS6G8zj/X767MLK/djANvpPd +NVniEke6hM3CNBXYPAMhQBMWhCulcoz+0lxi8L34rMN+Dsbma96psdUrn7uLaB91 +6we0CTfF8qqm7BsVAgalon/UUiuMY80U3ueoj3okiSTiHIjD/YtpXSPioC8nMng7 +xqAY9Bwizt4FWgXuLm1a4+So4V9j1TRCXd12Uc2l2RNmgDE= +=miES +-----END PGP PRIVATE KEY BLOCK----- diff --git a/tests/email-print-mime-structure/encrypted.eml b/tests/email-print-mime-structure/encrypted.eml new file mode 100644 index 0000000..5a28719 --- /dev/null +++ b/tests/email-print-mime-structure/encrypted.eml @@ -0,0 +1,37 @@ +Date: Sun, 24 Nov 2019 21:13:45 -0500 +Subject: test message +Message-ID: <pgpmime-encrypted@mailscripts.example> +From: Alice <alice@mailscripts.example> +To: Bob <bob@mailscripts.example> +Content-Type: multipart/encrypted; boundary="eeee"; + protocol="application/pgp-encrypted" + +--eeee +content-type: application/pgp-encrypted + +Version: 1 + +--eeee +content-type: application/octet-stream + +-----BEGIN PGP MESSAGE----- + +hQGMA3wvqk35PDeyAQv/YL3qVwxaAzTrk7/YysmH+HZs8A5DS7WarPpQ6Y33LZ/1 +KFmVujDxbAg4xBDyDJYGmvlKXnbA/rWCAWI+tc67EoSO35hAFK0h6hUhHCCdAy+g +p9coNsZS+XF9xw8Bfd4Bfr+iaHojqVsBJJXGVg/ie3PWMwC4vvllLsk42Uibw5Oa +AiEvvm/UTOL/4hEiH2G3Au68e6ulC8q/PNPp4vOD7xMUTg319f+ZkR9pLs2KZles +o+gioquDvdZhroGmPem9pUsLyjQ83TwYtvaPGoA5uLCuIL1jkroIFPjp96/JqzDR +RmsEQ3GzWVwxcWyjpw/6gU5SfPrfgaTLLvm6MgYIbAFYEG1cTMbkl3W2vR0VUecr +uL9YDqmBHgS5XhkxE5tvs0vo8pyIXg96Td1tJIu1IOA87XXVD8Uo6ypTffggOIpO +YWM0yRXXEOXTd+RwAbY4+Tpu4pE1dQbKF660iuFcoY3b9Bh8O4UG5eARI2gEiFb/ +UmmWp0GpUi4mbhq381rS0sBOAU6KB6t5lk8+IBjGQG8PDf8kovKZrL/zaSrfppqm +d7ecohTZ41uYP+R6sYu6/LE3UfmTYWqavb0SLwzB55oXhEQBj/NeI/7kwPKrAvfC +64hxR1Zkd5JfJO6Qwmp7+Z7PB6f1yvBuNhupZqAxP9Dp7F/+b5RaCdSaVIrNUarP +xRbgaCvL/RDp3HQ1SQlEMNrkIdALXw6xSYvCYxCFnrJOAqeAUtdf3JLVS7jIyuWC +SeWJwd17o7wkzp7uz6IdK+f+wcNTxPogvpM/rjBmAFE8PHZkgjZlZLJFMDFx4ZiI +Ljn7AwKRH225pKV3ixwTTFlNCtjO6BgtaSEIRLXw6a95iAsdO140qGRCIRAYMxww +=9ORE +-----END PGP MESSAGE----- + +--eeee-- + diff --git a/tests/email-print-mime-structure/encrypted.out b/tests/email-print-mime-structure/encrypted.out new file mode 100644 index 0000000..a2db072 --- /dev/null +++ b/tests/email-print-mime-structure/encrypted.out @@ -0,0 +1,9 @@ +└┬╴multipart/encrypted 1366 bytes + ├─╴application/pgp-encrypted 11 bytes + └─╴application/octet-stream 971 bytes + ↧ (decrypts to) + └┬╴multipart/mixed 415 bytes + ├┬╴multipart/alternative 234 bytes + │├─╴text/plain 26 bytes + │└─╴text/html 72 bytes + └─╴text/plain attachment [test.txt] 33 bytes diff --git a/tests/email-print-mime-structure/encrypted.pgpkey b/tests/email-print-mime-structure/encrypted.pgpkey new file mode 120000 index 0000000..9ba5070 --- /dev/null +++ b/tests/email-print-mime-structure/encrypted.pgpkey @@ -0,0 +1 @@ +bob.key \ No newline at end of file -- 2.24.0