proxmox/proxmox-ldap/run_integration_tests.sh
Lukas Wagner 582e994cca ldap: tests: add LDAP integration tests
This commit adds integration tests to ensure that the crate works as intended.
The tests are executed against a real LDAP server, namely `glauth`. `glauth` was
chosen because it ships as a single, statically compiled binary and can
be configured with a single configuration file.

The tests are written as off-the-shelf unit tests. However, they are
 #[ignored] by default, as they have some special requirements:
   * They required the GLAUTH_BIN environment variable to be set,
     pointing to the location of the `glauth` binary. `glauth` will be
     started and stopped automatically by the test suite.
   * Tests have to be executed sequentially (`--test-threads 1`),
     otherwise multiple instances of the glauth server might bind to the
     same port.

The `run_integration_tests.sh` checks whether GLAUTH_BIN is set, or if
not, attempts to find `glauth` on PATH. The script also ensures that the
tests are run sequentially.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:21 +01:00

32 lines
745 B
Bash
Executable File

#!/bin/bash
#
# Run integration tests for the proxmox_ldap crate.
# At this time, the tests require `glauth` to be available,
# either explicitly passed via $GLAUTH_PATH, or somewhere
# on $PATH.
#
# Tested with glauth v2.1.0
function run_tests {
# All tests that need glauth running are ignored, so
# that we can run `cargo test` without caring about them
# Also, only run on 1 thread, because otherwise
# glauth would need a separate port for each rurnning test
exec cargo test -- --ignored --test-threads 1
}
if [ -z ${GLAUTH_BIN+x} ];
then
GLAUTH_BIN=$(command -v glauth)
if [ $? -eq 0 ] ;
then
export GLAUTH_BIN
else
echo "glauth not found in PATH"
exit 1
fi
fi
run_tests