test: add helper script to run openid server
Add a new helper script to run the mock open id server that is shipped inside the osbuild-composer-tests package.
This commit is contained in:
parent
940e122ae9
commit
4e1039bed7
2 changed files with 55 additions and 0 deletions
|
|
@ -71,6 +71,7 @@ install -m 0755 -vd %{buildroot}/%{_
|
|||
install -m 0755 -vp test/make-certs.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/build-container.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/run-koji-container.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/run-openid.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/copy-creds.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/run-builder.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
install -m 0755 -vp test/make-tags.sh %{buildroot}/%{_libexecdir}/%{name}-tests/
|
||||
|
|
|
|||
54
test/run-openid.sh
Executable file
54
test/run-openid.sh
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/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 --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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue