summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJosé Guilherme Vanz <jvanz@jvanz.com>2021-07-06 21:00:03 -0300
committerDaniel J Walsh <dwalsh@redhat.com>2021-11-11 15:11:19 -0500
commit6762d5e2381d79c26ecabac8c83d31d1f49e1325 (patch)
treee14bef604ca3723c866b15691ba3a115ebd2997e /test
parentd6d89fa79f1cb785e2f3f6b8d2295b97b19066e9 (diff)
downloadpodman-6762d5e2381d79c26ecabac8c83d31d1f49e1325.tar.gz
podman-6762d5e2381d79c26ecabac8c83d31d1f49e1325.tar.bz2
podman-6762d5e2381d79c26ecabac8c83d31d1f49e1325.zip
--authfile command line argument for image sign command.
Adds the --authfile command line argument to allow users to use alternative authfile paths when signing images. Replaces: https://github.com/containers/podman/pull/10975 Fixes: https://github.com/containers/podman/issues/10866 Signed-off-by: José Guilherme Vanz <jvanz@jvanz.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/system/011-image.bats54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/system/011-image.bats b/test/system/011-image.bats
new file mode 100644
index 000000000..5150e875e
--- /dev/null
+++ b/test/system/011-image.bats
@@ -0,0 +1,54 @@
+#!/usr/bin/env bats
+
+load helpers
+
+function setup() {
+ skip_if_remote "--sign-by does not work with podman-remote"
+
+ basic_setup
+
+ export _GNUPGHOME_TMP=$PODMAN_TMPDIR/.gnupg
+ mkdir --mode=0700 $_GNUPGHOME_TMP $PODMAN_TMPDIR/signatures
+
+ cat >$PODMAN_TMPDIR/keydetails <<EOF
+ %echo Generating a basic OpenPGP key
+ Key-Type: RSA
+ Key-Length: 2048
+ Subkey-Type: RSA
+ Subkey-Length: 2048
+ Name-Real: Foo
+ Name-Comment: Foo
+ Name-Email: foo@bar.com
+ Expire-Date: 0
+ %no-ask-passphrase
+ %no-protection
+ # Do a commit here, so that we can later print "done" :-)
+ %commit
+ %echo done
+EOF
+ GNUPGHOME=$_GNUPGHOME_TMP gpg --verbose --batch --gen-key $PODMAN_TMPDIR/keydetails
+}
+
+function check_signature() {
+ local sigfile=$1
+ ls -laR $PODMAN_TMPDIR/signatures
+ run_podman inspect --format '{{.Digest}}' $PODMAN_TEST_IMAGE_FQN
+ local repodigest=${output/:/=}
+
+ local dir="$PODMAN_TMPDIR/signatures/libpod/${PODMAN_TEST_IMAGE_NAME}@${repodigest}"
+ test -d $dir || die "Missing signature directory $dir"
+ test -e "$dir/$sigfile" || die "Missing signature file '$sigfile'"
+
+ # Confirm good signature
+ run env GNUPGHOME=$_GNUPGHOME_TMP gpg --verify "$dir/$sigfile"
+ is "$output" ".*Good signature from .Foo.*<foo@bar.com>" \
+ "gpg --verify $sigfile"
+}
+
+
+@test "podman image - sign with no sigfile" {
+ GNUPGHOME=$_GNUPGHOME_TMP run_podman image sign --sign-by foo@bar.com --directory $PODMAN_TMPDIR/signatures "docker://$PODMAN_TEST_IMAGE_FQN"
+ check_signature "signature-1"
+}
+
+# vim: filetype=sh