2020-11-23 08:55:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Simple buildah tests
|
|
|
|
#
|
2020-10-14 20:31:37 +00:00
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
export PATH=/usr/local/bin:/usr/sbin:/usr/bin
|
|
|
|
export TMPDIR=/var/tmp
|
2020-10-14 20:31:37 +00:00
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
TEST_LOG=/tmp/test.$(id -un).log
|
|
|
|
FULL_LOG=/tmp/test.$(id -un).debug.log
|
|
|
|
rm -f $TEST_LOG $FULL_LOG
|
2020-10-14 20:31:37 +00:00
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
# Log program versions
|
|
|
|
rpm -q buildah buildah-tests > $FULL_LOG
|
2020-10-14 20:31:37 +00:00
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
cd /usr/share/buildah/test/system || exit 1
|
2020-10-14 20:31:37 +00:00
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
start_registry() {
|
2020-10-14 20:31:37 +00:00
|
|
|
AUTHDIR=/tmp/buildah-tests-auth.$$
|
|
|
|
mkdir -p $AUTHDIR
|
|
|
|
|
|
|
|
CERT=$AUTHDIR/domain.crt
|
|
|
|
if [ ! -e $CERT ]; then
|
|
|
|
openssl req -newkey rsa:4096 -nodes -sha256 \
|
|
|
|
-keyout $AUTHDIR/domain.key -x509 -days 2 \
|
|
|
|
-out $AUTHDIR/domain.crt \
|
2020-11-23 08:55:20 +00:00
|
|
|
-subj "/C=US/ST=Foo/L=Bar/O=Red Hat, Inc./CN=localhost"
|
2020-10-14 20:31:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e $AUTHDIR/htpasswd ]; then
|
2020-11-23 08:55:20 +00:00
|
|
|
podman run --entrypoint htpasswd registry:2 \
|
|
|
|
-Bbn testuser testpassword > $AUTHDIR/htpasswd
|
2020-10-14 20:31:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
podman run -d -p 5000:5000 \
|
|
|
|
--name registry \
|
|
|
|
-v $AUTHDIR:/auth:Z \
|
|
|
|
-e "REGISTRY_AUTH=htpasswd" \
|
|
|
|
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
|
|
|
|
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
|
|
|
|
-e REGISTRY_HTTP_TLS_CERTIFICATE=/auth/domain.crt \
|
|
|
|
-e REGISTRY_HTTP_TLS_KEY=/auth/domain.key \
|
2020-11-23 08:55:20 +00:00
|
|
|
registry:2
|
2020-10-14 20:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
export BUILDAH_BINARY=/usr/bin/buildah
|
|
|
|
export IMGTYPE_BINARY=/usr/bin/buildah-imgtype
|
|
|
|
|
|
|
|
start_registry >> $FULL_LOG 2>&1
|
2020-10-14 20:31:37 +00:00
|
|
|
|
2020-11-23 08:55:20 +00:00
|
|
|
bats . &> $TEST_LOG
|
2020-10-14 20:31:37 +00:00
|
|
|
rc=$?
|
2020-11-23 08:55:20 +00:00
|
|
|
|
|
|
|
echo "------------------------------" >> $FULL_LOG
|
|
|
|
echo "bats completed with status $rc" >> $FULL_LOG
|
|
|
|
|
|
|
|
podman rm -f registry >> $FULL_LOG
|
2020-10-14 20:31:37 +00:00
|
|
|
|
|
|
|
exit $rc
|