#!/bin/bash

set -e
set -x

app_id="collabora-online"
hostname="$(hostname -f)"
username="$(univention-app shell $app_id cat /etc/univention/base.conf | sed -n 's/^username: \(.*\)/\1/p')"
password="$(univention-app shell $app_id cat /etc/univention/base.conf | sed -n 's/^password: \(.*\)/\1/p')"

python -c "
import requests
r = requests.get('https://$hostname/loleaflet/dist/admin/admin.html', auth=('$username', '$password'))
print r.status_code
print r.content
assert r.status_code == 200
"
exit $?
