#!/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 -x

pip3 install openapi-spec-validator
pip3 install -U jsonschema

cleanup() {
	pip3 uninstall -y openapi-spec-validator
}
trap cleanup INT TERM EXIT

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