#!/usr/bin/env bash Describe 'etc/lib/shell helpers' Include etc/lib/shell/prole_env.sh Include etc/lib/shell/prole_string.sh Include etc/lib/shell/prole_secrets.sh Include etc/lib/shell/prole_yaml.sh Include etc/lib/shell/prole_guardrails.sh Include etc/lib/shell/prole_cmd.sh Describe 'prole_first_nonempty' It 'returns the first non-empty argument' When call prole_first_nonempty '' 'a' 'b' The status should be success The output should eq 'a' End It 'fails when all are empty' When call prole_first_nonempty '' '' The status should be failure End End Describe 'prole_normalize_realm' It 'trims and uppercases' When call prole_normalize_realm ' prole.org ' The output should eq 'PROLE.ORG' End It 'returns empty for empty input' When call prole_normalize_realm '' The output should eq '' End End Describe 'prole_secret_choose_value' It 'keeps literal current values' When call prole_secret_choose_value 'literal' 'fetched' The output should eq 'literal' End It 'prefers fetched when current is empty' When call prole_secret_choose_value '' 'fetched' The output should eq 'fetched' End It 'prefers fetched when current is a secret ref' When call prole_secret_choose_value '${OPENBAO:kv/prole/default/kerberos#password}' 'fetched' The output should eq 'fetched' End End Describe 'prole_yaml_get_scalar' setup_yaml() { yml_file="$(mktemp)" cat >"$yml_file" <<'EOF' samba_dns_server: "10.0.0.10" samba_dns_admin_user: administrator EOF } teardown_yaml() { rm -f "${yml_file:-}" } BeforeAll 'setup_yaml' AfterAll 'teardown_yaml' It 'extracts quoted scalars' When call prole_yaml_get_scalar "$yml_file" samba_dns_server The output should eq '10.0.0.10' End It 'extracts unquoted scalars' When call prole_yaml_get_scalar "$yml_file" samba_dns_admin_user The output should eq 'administrator' End End Describe 'prole_guard_nonempty' It 'returns 2 and emits an error for missing values' When run prole_guard_nonempty 'KRB5_REALM' '' The status should eq 2 The stderr should include 'ERROR: KRB5_REALM is required' End End Describe 'prole_kubectl_exec_cmd' It 'assembles a deterministic, escaped command' When call prole_kubectl_exec_cmd default pod-1 'echo hi' The output should eq 'kubectl -n default exec pod-1 -- sh -c echo\ hi' End End End