test-method-gpgv 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. cat > faked-apt-key <<EOF
  8. #!/bin/sh
  9. set -e
  10. echo "FFOO"
  11. find_gpgv_status_fd() {
  12. while [ -n "\$1" ]; do
  13. if [ "\$1" = '--status-fd' ]; then
  14. shift
  15. echo "\$1"
  16. break
  17. fi
  18. shift
  19. done
  20. }
  21. GPGSTATUSFD="\$(find_gpgv_status_fd "\$@")"
  22. cat >&\${GPGSTATUSFD} gpgv.output
  23. cat gpgv.output
  24. EOF
  25. chmod +x faked-apt-key
  26. testgpgv() {
  27. echo "$3" > gpgv.output
  28. msgtest "$1" "$2"
  29. gpgvmethod >method.output 2>&1 || true
  30. testsuccess --nomsg grep "$2" method.output
  31. }
  32. testrun() {
  33. testgpgv 'Good signed with long keyid' 'Good: GOODSIG 5A90D141DBAC8DAE,' '[GNUPG:] GOODSIG 5A90D141DBAC8DAE Joe Sixpack (APT Testcases Dummy) <joe@example.org>
  34. [GNUPG:] VALIDSIG 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE 2016-09-01 1472742625 0 4 0 1 11 00 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE'
  35. testgpgv 'Good signed with fingerprint' 'Good: GOODSIG 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE,' '[GNUPG:] GOODSIG 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE Joe Sixpack (APT Testcases Dummy) <joe@example.org>
  36. [GNUPG:] VALIDSIG 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE 2016-09-01 1472742625 0 4 0 1 11 00 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE'
  37. testgpgv 'No Pubkey with long keyid' 'NoPubKey: NO_PUBKEY E8525D47528144E2,' '[GNUPG:] ERRSIG E8525D47528144E2 1 11 00 1472744666 9
  38. [GNUPG:] NO_PUBKEY E8525D47528144E2'
  39. testgpgv 'No Pubkey with fingerprint' 'NoPubKey: NO_PUBKEY DE66AECA9151AFA1877EC31DE8525D47528144E2,' '[GNUPG:] ERRSIG DE66AECA9151AFA1877EC31DE8525D47528144E2 1 11 00 1472744666 9
  40. [GNUPG:] NO_PUBKEY DE66AECA9151AFA1877EC31DE8525D47528144E2'
  41. testgpgv 'Expired key with long keyid' 'Worthless: EXPKEYSIG 4BC0A39C27CE74F9 Rex Expired <rex@example.org>,' '[GNUPG:] EXPKEYSIG 4BC0A39C27CE74F9 Rex Expired <rex@example.org>
  42. [GNUPG:] VALIDSIG 891CC50E605796A0C6E733F74BC0A39C27CE74F9 2016-09-01 1472742629 0 4 0 1 11 00 891CC50E605796A0C6E733F74BC0A39C27CE74F9'
  43. testgpgv 'Expired key with fingerprint' 'Worthless: EXPKEYSIG 891CC50E605796A0C6E733F74BC0A39C27CE74F9 Rex Expired <rex@example.org>,' '[GNUPG:] EXPKEYSIG 891CC50E605796A0C6E733F74BC0A39C27CE74F9 Rex Expired <rex@example.org>
  44. [GNUPG:] VALIDSIG 891CC50E605796A0C6E733F74BC0A39C27CE74F9 2016-09-01 1472742629 0 4 0 1 11 00 891CC50E605796A0C6E733F74BC0A39C27CE74F9'
  45. }
  46. gpgvmethod() {
  47. echo '601 Configuration
  48. Config-Item: Debug::Acquire::gpgv=1
  49. Config-Item: Dir::Bin::apt-key=./faked-apt-key
  50. 600 URI Acquire
  51. URI: file:///dev/null
  52. Filename: /dev/zero
  53. ' | runapt "${METHODSDIR}/gpgv"
  54. }
  55. testrun
  56. gpgvmethod() {
  57. echo '601 Configuration
  58. Config-Item: Debug::Acquire::gpgv=1
  59. Config-Item: Dir::Bin::apt-key=./faked-apt-key
  60. 600 URI Acquire
  61. URI: file:///dev/null
  62. Filename: /dev/zero
  63. Signed-By: 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
  64. ' | runapt "${METHODSDIR}/gpgv"
  65. }
  66. testrun