-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #659 from edsantiago/systemtests
systemtest - new set of BATS tests for RHEL8 gating
- Loading branch information
Showing
11 changed files
with
796 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Before running podman for the first time, make sure | ||
# to set storage to vfs (not overlay): podman-in-podman | ||
# doesn't work with overlay. And, disable mountopt, | ||
# which causes error with vfs. | ||
sed -i \ | ||
-e 's/^driver\s*=.*/driver = "vfs"/' \ | ||
-e 's/^mountopt/#mountopt/' \ | ||
/etc/containers/storage.conf | ||
|
||
# Build skopeo, install into /usr/bin | ||
make binary-local ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"} | ||
make install | ||
|
||
# Run tests | ||
SKOPEO_BINARY=/usr/bin/skopeo bats --tap systemtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bats | ||
# | ||
# Simplest set of skopeo tests. If any of these fail, we have serious problems. | ||
# | ||
|
||
load helpers | ||
|
||
# Override standard setup! We don't yet trust anything | ||
function setup() { | ||
: | ||
} | ||
|
||
@test "skopeo version emits reasonable output" { | ||
run_skopeo --version | ||
|
||
expect_output --substring "skopeo version [0-9.]+" | ||
} | ||
|
||
# vim: filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bats | ||
# | ||
# Simplest test for skopeo inspect | ||
# | ||
|
||
load helpers | ||
|
||
@test "inspect: basic" { | ||
workdir=$TESTDIR/inspect | ||
|
||
remote_image=docker://quay.io/libpod/alpine_labels:latest | ||
# Inspect remote source, then pull it. There's a small race condition | ||
# in which the remote image can get updated between the inspect and | ||
# the copy; let's just not worry about it. | ||
run_skopeo inspect $remote_image | ||
inspect_remote=$output | ||
|
||
# Now pull it into a directory | ||
run_skopeo copy $remote_image dir:$workdir | ||
expect_output --substring "Getting image source signatures" | ||
expect_output --substring "Writing manifest to image destination" | ||
|
||
# Unpacked contents must include a manifest and version | ||
[ -e $workdir/manifest.json ] | ||
[ -e $workdir/version ] | ||
|
||
# Now run inspect locally | ||
run_skopeo inspect dir:$workdir | ||
inspect_local=$output | ||
|
||
# Each SHA-named file must be listed in the output of 'inspect' | ||
for sha in $(find $workdir -type f | xargs -l1 basename | egrep '^[0-9a-f]{64}$'); do | ||
expect_output --from="$inspect_local" --substring "sha256:$sha" \ | ||
"Locally-extracted SHA file is present in 'inspect'" | ||
done | ||
|
||
# Simple sanity check on 'inspect' output. | ||
# For each of the given keys (LHS of the table below): | ||
# 1) Get local and remote values | ||
# 2) Sanity-check local value using simple expression | ||
# 3) Confirm that local and remote values match. | ||
# | ||
# The reason for (2) is to make sure that we don't compare bad results | ||
# | ||
# The reason for a hardcoded list, instead of 'jq keys', is that RepoTags | ||
# is always empty locally, but a list remotely. | ||
while read key expect; do | ||
local=$(echo "$inspect_local" | jq -r ".$key") | ||
remote=$(echo "$inspect_remote" | jq -r ".$key") | ||
|
||
expect_output --from="$local" --substring "$expect" \ | ||
"local $key is sane" | ||
|
||
expect_output --from="$remote" "$local" \ | ||
"local $key matches remote" | ||
done <<END_EXPECT | ||
Architecture amd64 | ||
Created [0-9-]+T[0-9:]+\.[0-9]+Z | ||
Digest sha256:[0-9a-f]{64} | ||
DockerVersion [0-9]+\.[0-9][0-9.-]+ | ||
Labels \\\{.*PODMAN.*podman.*\\\} | ||
Layers \\\[.*sha256:.*\\\] | ||
Os linux | ||
END_EXPECT | ||
} | ||
|
||
# vim: filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env bats | ||
# | ||
# Copy tests | ||
# | ||
|
||
load helpers | ||
|
||
function setup() { | ||
standard_setup | ||
|
||
start_registry reg | ||
} | ||
|
||
# From remote, to dir1, to local, to dir2; | ||
# compare dir1 and dir2, expect no changes | ||
@test "copy: dir, round trip" { | ||
local remote_image=docker://busybox:latest | ||
local localimg=docker://localhost:5000/busybox:unsigned | ||
|
||
local dir1=$TESTDIR/dir1 | ||
local dir2=$TESTDIR/dir2 | ||
|
||
run_skopeo copy $remote_image dir:$dir1 | ||
run_skopeo copy --dest-tls-verify=false dir:$dir1 $localimg | ||
run_skopeo copy --src-tls-verify=false $localimg dir:$dir2 | ||
|
||
# Both extracted copies must be identical | ||
diff -urN $dir1 $dir2 | ||
} | ||
|
||
# Same as above, but using 'oci:' instead of 'dir:' and with a :latest tag | ||
@test "copy: oci, round trip" { | ||
local remote_image=docker://busybox:latest | ||
local localimg=docker://localhost:5000/busybox:unsigned | ||
|
||
local dir1=$TESTDIR/oci1 | ||
local dir2=$TESTDIR/oci2 | ||
|
||
run_skopeo copy $remote_image oci:$dir1:latest | ||
run_skopeo copy --dest-tls-verify=false oci:$dir1:latest $localimg | ||
run_skopeo copy --src-tls-verify=false $localimg oci:$dir2:latest | ||
|
||
# Both extracted copies must be identical | ||
diff -urN $dir1 $dir2 | ||
} | ||
|
||
# Same image, extracted once with :tag and once without | ||
@test "copy: oci w/ and w/o tags" { | ||
local remote_image=docker://busybox:latest | ||
|
||
local dir1=$TESTDIR/dir1 | ||
local dir2=$TESTDIR/dir2 | ||
|
||
run_skopeo copy $remote_image oci:$dir1 | ||
run_skopeo copy $remote_image oci:$dir2:withtag | ||
|
||
# Both extracted copies must be identical, except for index.json | ||
diff -urN --exclude=index.json $dir1 $dir2 | ||
|
||
# ...which should differ only in the tag. (But that's too hard to check) | ||
grep '"org.opencontainers.image.ref.name":"withtag"' $dir2/index.json | ||
} | ||
|
||
# This one seems unlikely to get fixed | ||
@test "copy: bug 651" { | ||
skip "Enable this once skopeo issue #651 has been fixed" | ||
|
||
run_skopeo copy --dest-tls-verify=false \ | ||
docker://quay.io/libpod/alpine_labels:latest \ | ||
docker://localhost:5000/foo | ||
} | ||
|
||
teardown() { | ||
podman rm -f reg | ||
|
||
standard_teardown | ||
} | ||
|
||
# vim: filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bats | ||
# | ||
# Confirm that skopeo will push to and pull from a local | ||
# registry with locally-created TLS certificates. | ||
# | ||
load helpers | ||
|
||
function setup() { | ||
standard_setup | ||
|
||
start_registry --with-cert reg | ||
} | ||
|
||
@test "local registry, with cert" { | ||
# Push to local registry... | ||
run_skopeo copy --dest-cert-dir=$TESTDIR/client-auth \ | ||
docker://busybox:latest \ | ||
docker://localhost:5000/busybox:unsigned | ||
|
||
# ...and pull it back out | ||
run_skopeo copy --src-cert-dir=$TESTDIR/client-auth \ | ||
docker://localhost:5000/busybox:unsigned \ | ||
dir:$TESTDIR/extracted | ||
} | ||
|
||
teardown() { | ||
podman rm -f reg | ||
|
||
standard_teardown | ||
} | ||
|
||
# vim: filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env bats | ||
# | ||
# Tests with a local registry with auth | ||
# | ||
|
||
load helpers | ||
|
||
function setup() { | ||
standard_setup | ||
|
||
# Remove old/stale cred file | ||
_cred_dir=$TESTDIR/credentials | ||
export XDG_RUNTIME_DIR=$_cred_dir | ||
mkdir -p $_cred_dir/containers | ||
rm -f $_cred_dir/containers/auth.json | ||
|
||
# Start authenticated registry with random password | ||
testuser=testuser | ||
testpassword=$(random_string 15) | ||
|
||
start_registry --testuser=testuser --testpassword=$testpassword reg | ||
} | ||
|
||
@test "auth: credentials on command line" { | ||
# No creds | ||
run_skopeo 1 inspect --tls-verify=false docker://localhost:5000/nonesuch | ||
expect_output --substring "unauthorized: authentication required" | ||
|
||
# Wrong user | ||
run_skopeo 1 inspect --tls-verify=false --creds=baduser:badpassword \ | ||
docker://localhost:5000/nonesuch | ||
expect_output --substring "unauthorized: authentication required" | ||
|
||
# Wrong password | ||
run_skopeo 1 inspect --tls-verify=false --creds=$testuser:badpassword \ | ||
docker://localhost:5000/nonesuch | ||
expect_output --substring "unauthorized: authentication required" | ||
|
||
# Correct creds, but no such image | ||
run_skopeo 1 inspect --tls-verify=false --creds=$testuser:$testpassword \ | ||
docker://localhost:5000/nonesuch | ||
expect_output --substring "manifest unknown: manifest unknown" | ||
|
||
# These should pass | ||
run_skopeo copy --dest-tls-verify=false --dcreds=$testuser:$testpassword \ | ||
docker://busybox:latest docker://localhost:5000/busybox:mine | ||
run_skopeo inspect --tls-verify=false --creds=$testuser:$testpassword \ | ||
docker://localhost:5000/busybox:mine | ||
expect_output --substring "localhost:5000/busybox" | ||
} | ||
|
||
@test "auth: credentials via podman login" { | ||
# Logged in: skopeo should work | ||
podman login --tls-verify=false -u $testuser -p $testpassword localhost:5000 | ||
|
||
run_skopeo copy --dest-tls-verify=false \ | ||
docker://busybox:latest docker://localhost:5000/busybox:mine | ||
run_skopeo inspect --tls-verify=false docker://localhost:5000/busybox:mine | ||
expect_output --substring "localhost:5000/busybox" | ||
|
||
# Logged out: should fail | ||
podman logout localhost:5000 | ||
|
||
run_skopeo 1 inspect --tls-verify=false docker://localhost:5000/busybox:mine | ||
expect_output --substring "unauthorized: authentication required" | ||
} | ||
|
||
teardown() { | ||
podman rm -f reg | ||
|
||
if [[ -n $_cred_dir ]]; then | ||
rm -rf $_cred_dir | ||
fi | ||
|
||
standard_teardown | ||
} | ||
|
||
# vim: filetype=sh |
Oops, something went wrong.