From 2d16aeb467a23f50c5dcb7f38649da582d83553b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Tue, 22 Feb 2022 23:18:54 +0100 Subject: [PATCH] tests: add an E2E test for multi-tenancy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the comment. It's imho still very important to have this test but its powers are limited. Signed-off-by: Ondřej Budai --- .gitlab-ci.yml | 12 ++ test/cases/multi-tenancy.sh | 256 ++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100755 test/cases/multi-tenancy.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae5852cfc..e73c6b0e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -421,6 +421,18 @@ RHEL 9 on 8: INTERNAL_NETWORK: "true" DISTRO_CODE: rhel-90 +Multi-tenancy: + stage: test + extends: .terraform + rules: + - if: '$CI_PIPELINE_SOURCE != "schedule"' + script: + - schutzbot/deploy.sh + - /usr/libexec/tests/osbuild-composer/multi-tenancy.sh + variables: + RUNNER: aws/rhel-8.5-ga-x86_64 + INTERNAL_NETWORK: "true" + Upgrade: stage: test extends: .terraform/openstack diff --git a/test/cases/multi-tenancy.sh b/test/cases/multi-tenancy.sh new file mode 100755 index 000000000..8a76fe211 --- /dev/null +++ b/test/cases/multi-tenancy.sh @@ -0,0 +1,256 @@ +#!/bin/bash + +# Tests the multi-tenancy feature of cloud and remote worker API. +# +# Note that the power of this is very limited. It cannot check that a certain +# tenant can only access jobs on its channel. It has its value though that +# it checks the whole E2E setup including parsing of the JWT token which is +# not tested in the unit test. + + +set -euo pipefail + +OSBUILD_COMPOSER_TEST_DATA=/usr/share/tests/osbuild-composer/ + +# Get OS data. +source /usr/libexec/osbuild-composer-test/set-env-variables.sh + +# Colorful output. +function greenprint { + echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" +} + +# Provision the software under test. +/usr/libexec/osbuild-composer-test/provision.sh + +greenprint "Registering clean ups" +KILL_PIDS=() +function cleanup() { + set +eu + greenprint "Stopping containers" + sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh stop + + greenprint "Removing generated CA cert" + sudo rm \ + /etc/pki/ca-trust/source/anchors/osbuild-composer-tests-ca-crt.pem + sudo update-ca-trust + + for P in "${KILL_PIDS[@]}"; do + sudo pkill -P "$P" + done + set -eu +} +trap cleanup EXIT + +greenprint "Adding the testsuite's CA cert to the system trust store" +# the worker cannot handle koji with self-signed certs +sudo cp \ + /etc/osbuild-composer/ca-crt.pem \ + /etc/pki/ca-trust/source/anchors/osbuild-composer-tests-ca-crt.pem +sudo update-ca-trust + +greenprint "Starting containers" +sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh start + +greenprint "Adding kerberos config" +sudo cp \ + /tmp/osbuild-composer-koji-test/client.keytab \ + /etc/osbuild-worker/client.keytab +sudo cp \ + "${OSBUILD_COMPOSER_TEST_DATA}"/kerberos/krb5-local.conf \ + /etc/krb5.conf.d/local + +greenprint "Configuring composer and worker" +sudo tee "/etc/osbuild-composer/osbuild-composer.toml" >/dev/null </dev/null </dev/null </dev/null <