Browse Source

Merge branch 'obourdon-fix-v1.3.0' into release-1.4.0

Bertrand Gouny 5 years ago
parent
commit
78925bf649
2 changed files with 18 additions and 6 deletions
  1. 3 4
      image/service/slapd/startup.sh
  2. 15 2
      test/test.bats

+ 3 - 4
image/service/slapd/startup.sh

@@ -97,13 +97,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() {

+ 15 - 2
test/test.bats

@@ -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"
 
@@ -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"
 
@@ -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"