#!/bin/sh

set -eu

echo "Copying keys needed for tests..."
export HOME="$AUTOPKGTEST_TMP/home"
mkdir -p "$HOME/.local/share/patatt/public/"
cp -r .keys/. "$HOME/.local/share/patatt/public/"

echo "Running ed25519 positive test..."
patatt validate samples/ed25519-signed.txt

echo "Running ed25519 negative test..."
if patatt validate debian/tests/ed25519-sign-fail.txt; then
    echo "Invalid Ed25519 signature was accepted" >&2
    exit 1
fi

echo "Running pgp positive test..."
patatt validate samples/pgp-signed.txt

echo "Running pgp negative test..."
if patatt validate debian/tests/pgp-sign-fail.txt; then
    echo "Invalid OpenPGP signature was accepted" >&2
    exit 1
fi

echo "Tests PASS"
