]> git.notmuchmail.org Git - notmuch/blob - test/T355-smime.sh
test: initial tests for S/MIME and notmuch-emacs
[notmuch] / test / T355-smime.sh
1 #!/usr/bin/env bash
2
3 test_description='S/MIME signature verification and decryption'
4 . ./test-lib.sh || exit 1
5
6 test_require_external_prereq openssl
7 test_require_external_prereq gpgsm
8
9 cp $TEST_DIRECTORY/smime/key+cert.pem test_suite.pem
10
11 FINGERPRINT=$(openssl x509 -fingerprint -in test_suite.pem -noout | sed -e 's/^.*=//' -e s/://g)
12
13 test_expect_success 'emacs delivery of S/MIME signed message' \
14      'emacs_fcc_message \
15      "test signed message 001" \
16      "This is a test signed message." \
17      "(mml-secure-message-sign \"smime\")"'
18
19 # Hard code the MML to avoid several interactive questions
20 test_expect_success 'emacs delivery of S/MIME encrypted + signed message' \
21 'emacs_fcc_message \
22     "test encrypted message 001" \
23     "<#secure method=smime mode=signencrypt keyfile=\\\"test_suite.pem\\\" certfile=\\\"test_suite.pem\\\">\nThis is a test encrypted message.\n"'
24
25 test_begin_subtest "Signature verification (openssl)"
26 notmuch show --format=raw subject:"test signed message 001" |\
27     openssl smime -verify -CAfile $TEST_DIRECTORY/smime/test.crt 2>OUTPUT
28 cat <<EOF > EXPECTED
29 Verification successful
30 EOF
31 test_expect_equal_file EXPECTED OUTPUT
32
33 test_begin_subtest "Decryption and signature verification (openssl)"
34 notmuch show --format=raw subject:"test encrypted message 001" |\
35     openssl smime -decrypt -recip test_suite.pem |\
36     openssl smime -verify -CAfile $TEST_DIRECTORY/smime/test.crt 2>OUTPUT
37 cat <<EOF > EXPECTED
38 Verification successful
39 EOF
40 test_expect_equal_file EXPECTED OUTPUT
41
42 test_done