From 438bd2cc9821da85d9f396b01bb14c8b770679c0 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sat, 9 Nov 2013 16:16:00 -0800 Subject: [PATCH] Add tests for retrieving by sub key ID 2 tests for retrieving a key by a short 32 bit key id of a subkey and the full 64 bit sub key id. --- t/all-080-get-subkey.t | 25 +++++++++++++++++++++++++ t/all-090-get-subkey-short.t | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 t/all-080-get-subkey.t create mode 100755 t/all-090-get-subkey-short.t diff --git a/t/all-080-get-subkey.t b/t/all-080-get-subkey.t new file mode 100755 index 0000000..ecccdf4 --- /dev/null +++ b/t/all-080-get-subkey.t @@ -0,0 +1,25 @@ +#!/bin/sh +# Check we can retrieve a key by keyid + +set -e + +# Backends should really support this, but the file one is as simple as +# possible, so doesn't. Skip the test for it. +if [ "$1" = "file" ]; then + exit 0 +fi + +cd t +../onak -b -c test.conf add < ../keys/noodles.key +if ! ../onak -c test.conf get 0x045281F1B9A66E35 2> /dev/null | \ + grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then + echo "* Did not correctly retrieve key by subkey id." + exit 1 +fi +if ! ../onak -c test.conf get 0xFF162FC5CF3FBAD1 2> /dev/null | \ + grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then + echo "* Did not correctly retrieve key by subkey id." + exit 1 +fi + +exit 0 diff --git a/t/all-090-get-subkey-short.t b/t/all-090-get-subkey-short.t new file mode 100755 index 0000000..891a566 --- /dev/null +++ b/t/all-090-get-subkey-short.t @@ -0,0 +1,25 @@ +#!/bin/sh +# Check we can retrieve a key by keyid + +set -e + +# Backends should really support this, but the file one is as simple as +# possible, so doesn't. Skip the test for it. +if [ "$1" = "file" ]; then + exit 0 +fi + +cd t +../onak -b -c test.conf add < ../keys/noodles.key +if ! ../onak -c test.conf get 0xB9A66E35 2> /dev/null | \ + grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then + echo "* Did not correctly retrieve key by subkey id." + exit 1 +fi +if ! ../onak -c test.conf get 0xCF3FBAD1 2> /dev/null | \ + grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then + echo "* Did not correctly retrieve key by subkey id." + exit 1 +fi + +exit 0 -- 2.39.2