#!/bin/sh
# Copyright (C) 2026 David Nichols
# SPDX-License-Identifier: MIT
set -eu
unset QORE_MODULE_DIR QORE_MODULE_DIR_ONLY QORE_INCLUDE_DIR LD_LIBRARY_PATH LD_PRELOAD LDAPCONF LDAPRC
cp -a test debian "$AUTOPKGTEST_TMP/"
cd "$AUTOPKGTEST_TMP"
cat > ldap-smoke.q <<'EOF'
%modern
%requires openldap
%requires LdapHelper
%requires LdapActiveDirectory
%requires LdapCli
%requires LdapAsync
%requires LdapConnectionPool
%requires LdifHelper
LdapClient client(uri: ENV.LDAP_URI, options: {"binddn": ENV.LDAP_BINDDN, "password": ENV.LDAP_PASSWORD});
hash<auto> entries = client.search(search_options: {"base": ENV.LDAP_BASEDN, "scope": LDAP_SCOPE_BASE, "filter": "(objectClass=*)"});
if (!entries.hasKey(ENV.LDAP_BASEDN)) throw "PACKAGE-TEST-ERROR", "Installed LDAP query returned no base entry";
EOF
/usr/bin/qcc -o ldap-smoke ldap-smoke.q
exec debian/tests/with-server timeout 60 ./ldap-smoke
