From 69d26f531c77bc65eb2fedfe0efd43c67dbbba6f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 19 Oct 2022 13:34:46 -0300 Subject: bin/check: Move tests to Makefile --- opt/tests/assert-gpg-expiration.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 opt/tests/assert-gpg-expiration.sh (limited to 'opt/tests') diff --git a/opt/tests/assert-gpg-expiration.sh b/opt/tests/assert-gpg-expiration.sh new file mode 100755 index 0000000..d17486e --- /dev/null +++ b/opt/tests/assert-gpg-expiration.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -eu + + +SECRET_KEY='81F90EC3CD356060' +NEXT_6_MONTHS="$(echo "$(date '+%s') + (60 * 60 * 24 * 30 * 6)" | bc)" + +gpg --with-colons --fixed-list-mode --list-keys "$SECRET_KEY" | + grep -e ^pub -e ^sub | + while read -r subkey; do + EXPIRY="$(echo "$subkey" | cut -d: -f7)" + if [ -z "$EXPIRY" ]; then + continue + fi + + if [ "$EXPIRY" -gt "$(date '+%s')" ] && + [ "$EXPIRY" -lt "$NEXT_6_MONTHS" ]; then + printf 'Key %s to expire soon!.\n' \ + "$(echo "$subkey" | cut -d: -f5)" >&2 + exit 1 + fi + done -- cgit v1.2.3