debian-koji-osbuild/test/run-openid.sh
Tomas Hozza 85d7120d9f CI: Use Fedora 36, RHEL-8.6 and the latest osbuild and composer
Use latest osbuild and osbuild-composer releases. This is important to
be later able to test direct uploading to the cloud for Koji composes.
Also the mock openid server had to be enhanced to be usable for testing
`koji-osbuild`.

Modify used osbuild-worker configuration to use JWT for authentication
with composer. Update configurations of both, composer and worker to
handle multi-tenancy.

Do not start any services in `schutzbot/deploy.sh`, because at that
point, none of the configuration files are in place.

Ensure that the correct units are started and masked by
`test/integration.sh` to simulate the Service scenario more closely.
This means that the local worker is masked and only remote worker is
started.

Co-authored-by: Jakub Rusz <jrusz@redhat.com>
2022-08-22 09:58:06 +02:00

54 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
set -eu
SERVER_PORT="8081"
PIDFILE="/run/composer-openid-server.pid"
server_start() {
echo "Starting mock OpenID server at :${SERVER_PORT}"
/usr/libexec/osbuild-composer-test/osbuild-mock-openid-provider \
-rsaPubPem /etc/osbuild-composer/client-crt.pem \
-rsaPem /etc/osbuild-composer/client-key.pem \
-cert /etc/osbuild-composer/composer-crt.pem \
-key /etc/osbuild-composer/composer-key.pem \
-a ":${SERVER_PORT}" \
-expires 10 &
until curl --data "grant_type=refresh_token" --output /dev/null --silent --fail "https://localhost:${SERVER_PORT}/token"; do
sleep 0.5
done
PID="$!"
echo "${PID}" > "${PIDFILE}"
echo "OpenID server running (${PID})"
}
server_stop() {
echo "Stopping mock OpenID server"
PID=$(cat "${PIDFILE}" 2> /dev/null || true)
if [ -z "$PID" ]; then
echo "Server not running!"
return
fi
echo "${PID}"
EXIT_CODE=0
kill "${PID}" > /dev/null || EXIT_CODE=$?
if [ "${EXIT_CODE}" != 0 ]; then
"Could not kill process ${PID}"
fi
}
if [ $# -lt 1 ]; then
echo -e "Usage: $0 <start|stop>"
elif [ $1 == "start" ]; then
server_start
elif [ $1 == "stop" ]; then
server_stop
fi