This repository has been archived on 2026-09-17. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
nixos-config/scripts/test-dex-ldap-env.sh
pijukka af45c30167 host(pinix): record identity DNS bootstrap for dex and head
Candidate-zone CNAMEs and Unbound local names for dex./head. under
domain2, the public-record helper and Dex LDAP env test, plus the
matching docs. This work predates this session and went live with the
2026-09-14 switch on pinix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JGodmgtRqahbT52gApsM8N
2026-09-14 12:55:11 +02:00

17 lines
899 B
Bash

#!/usr/bin/env bash
# Run as root on a systemd host; uses only synthetic credentials.
set -euo pipefail
test_dir=$(mktemp -d /tmp/dex-ldap-env-test.XXXXXX)
trap 'rm -f "$test_dir/password" "$test_dir/environment" "$test_dir/actual"; rmdir "$test_dir"' EXIT
script_dir=$(cd -- "$(dirname -- "$0")" && pwd)
for password in 'simple' ' spaces "quotes" \slash $dollar `backtick` #hash ;semi ' $'line one\nline two'; do
printf '%s' "$password" > "$test_dir/password"
bash "$script_dir/dex-ldap-env.sh" "$test_dir/password" "$test_dir/environment"
test "$(stat -c %a "$test_dir/environment")" = 600
systemd-run --quiet --wait --pipe --collect \
--property="EnvironmentFile=$test_dir/environment" \
"$(command -v bash)" -c 'printf "%s" "$LDAP_BIND_PW"' > "$test_dir/actual"
cmp "$test_dir/password" "$test_dir/actual"
done
printf 'Dex LDAP EnvironmentFile round-trip: 3 cases passed\n'