Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of environment variables checks #382

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions image/service/slapd/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ if [ ! -e "$FIRST_START_DONE" ]; then
fi
# Check that LDAP_BASE_DN and LDAP_DOMAIN are in sync
domain_from_base_dn=$(echo $LDAP_BASE_DN | tr ',' '\n' | sed -e 's/^.*=//' | tr '\n' '.' | sed -e 's/\.$//')
set +e
echo "$domain_from_base_dn" | egrep -q ".*$LDAP_DOMAIN\$"
if [ $? -ne 0 ]; then
if `echo "$domain_from_base_dn" | egrep -q ".*$LDAP_DOMAIN\$" || echo $LDAP_DOMAIN | egrep -q ".*$domain_from_base_dn\$"`; then
: # pass
else
log-helper error "Error: domain $domain_from_base_dn derived from LDAP_BASE_DN $LDAP_BASE_DN does not match LDAP_DOMAIN $LDAP_DOMAIN"
exit 1
fi
set -e
}

function is_new_schema() {
Expand Down
17 changes: 15 additions & 2 deletions test/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load test_helper

}

@test "ldap domain with ldap base dn" {
@test "ldap domain with non-matching ldap base dn" {

run_image -h ldap.example.org -e LDAP_TLS=false -e LDAP_DOMAIN=example.com -e LDAP_BASE_DN="dc=example,dc=org"

Expand All @@ -35,7 +35,7 @@ load test_helper

}

@test "ldap domain with ldap base dn subdomain" {
@test "ldap domain with matching ldap base dn subdomain" {

run_image -h ldap.example.fr -e LDAP_TLS=false -e LDAP_DOMAIN=example.fr -e LDAP_BASE_DN="ou=myou,o=example,c=fr"

Expand All @@ -48,6 +48,19 @@ load test_helper

}

@test "ldap base dn domain with matching ldap subdomain" {

run_image -h ldap.example.fr -e LDAP_TLS=false -e LDAP_DOMAIN=mysub.example.fr -e LDAP_BASE_DN="o=example,c=fr"

sleep 5

CSTATUS=$(check_container)
clear_container

[ "$CSTATUS" == "running 0" ]

}

@test "ldap domain with ldap base dn subdomain included" {

run_image -h ldap.example.com -e LDAP_TLS=false -e LDAP_DOMAIN=example.com -e LDAP_BASE_DN="ou=myou,o=example,dc=com,c=fr"
Expand Down