#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: Validate the OpenAPI schema
## tags: [udm,apptest,openapi]
## roles: [domaincontroller_master]
## exposure: careful
## packages:
##   - univention-directory-manager-rest

# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137
. /usr/share/univention-lib/ldap.sh || exit 137

set -ex

[ -e ucs-test-udm-rest-api/bin/activate ] || python3 -m venv ucs-test-udm-rest-api
. ucs-test-udm-rest-api/bin/activate

cleanup() {
	deactivate
	rm -rf "$DIR"
}
trap cleanup INT TERM EXIT

python3 -m pip install -U pip
python3 -m pip install "typing-extensions<4.6"
python3 -m pip install openapi-spec-validator


curl -u "$(ucs_convertDN2UID ${tests_domainadmin_account})":"${tests_domainadmin_pwd}" http://localhost/univention/udm/openapi.json | python3 -m openapi_spec_validator - || fail_fast 1
