1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-30 22:08:02 +02:00
gnupg/tests/openpgp/gpgtar.test
Justus Winter 45c814f348 tools/gpgtar: Implement signing.
* tests/openpgp/gpgtar.test: Test signing.
* tools/gpgtar-create.c (gpgtar_create): Add 'sign' option, add the
appropriate gpg arguments to implement signing and selecting the local
user.
* tools/gpgtar.c (parse_options): We do handle '--local-user' now.
(main): Handle signing, encrypting, and doing both when creating an
archive.
* tools/gpgtar.h (gpgtar_create): Update prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-12-04 12:52:40 +01:00

92 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
#set -x
# Make sure $srcdir is set.
if test "x$srcdir" = x
then
echo srcdir environment variable not set!
exit 1
fi
. $srcdir/defs.inc || exit 3
set -e
# Make sure $GNUPGHOME is set.
if test "x$GNUPGHOME" = x
then
echo "GNUPGHOME not set."
exit 1
fi
TESTFILES="$plain_files $data_files"
TESTDIR=gpgtar.d
FILELIST="${TESTDIR}/filelist"
GPG=../../g10/gpg2
GPGARGS="$opt_always --no-permission-warning"
GPGTAR="../../tools/gpgtar"
GPGZIP="sh ../../tools/gpg-zip"
# Create, inspect, and extract an archive with the given options.
#
# $1 the tool to test
# $2 options used to create the archive
# $3 options used to inspect the archive
# $4 options used to extract the archive
do_test()
{
(
TOOL="$1"
CREATE_FLAGS="$2"
INSPECT_FLAGS="$3"
EXTRACT_FLAGS="$4"
rm -rf -- "${TESTDIR}"
mkdir "${TESTDIR}"
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $CREATE_FLAGS \
--output "${TESTDIR}/test.tar.pgp" $TESTFILES
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $INSPECT_FLAGS \
"${TESTDIR}/test.tar.pgp" \
>"$FILELIST"
for F in $TESTFILES
do
grep -qe "\\b${F}\\b" "$FILELIST"
done
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $EXTRACT_FLAGS \
--tar-args --directory="${TESTDIR}" \
"${TESTDIR}/test.tar.pgp"
for F in $TESTFILES
do
diff -q "$F" "${TESTDIR}/$F"
done
)
}
for TOOL in "$GPGTAR" "$GPGZIP"
do
do_test "$TOOL" \
"--encrypt --recipient $usrname2" \
"--list-archive" \
"--decrypt"
do_test "$TOOL" \
"--encrypt --recipient $usrname2 --sign --local-user $usrname3" \
"--list-archive" \
"--decrypt"
do_test "$TOOL" \
"--sign --local-user $usrname3" \
"--list-archive" \
"--decrypt"
done
# Success!
exit 0