From 7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 21 Jul 2021 00:27:43 +0800 Subject: strings in LDAP are case-insensitive (#8) Thank you @wxiaoguang ! * strings in LDAP are case-insensitive * optmize routeFunc (faster, case-insensitive) * small optimiztion to routeFunc * request the directory server to return operational attributes by adding + (the plus sign) in your ldapsearch command. * request the directory server to return operational attributes by adding + (the plus sign) in your ldapsearch command. * request the directory server to return operational attributes by adding + (the plus sign) in your ldapsearch command. * remove operational attributes --- server_search_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'server_search_test.go') diff --git a/server_search_test.go b/server_search_test.go index 5a083b0..09e2b14 100644 --- a/server_search_test.go +++ b/server_search_test.go @@ -451,6 +451,42 @@ func TestSearchScope(t *testing.T) { quit <- true } + +///////////////////////// +func TestSearchScopeCaseInsensitive(t *testing.T) { + quit := make(chan bool) + done := make(chan bool) + go func() { + s := NewServer() + s.EnforceLDAP = true + s.QuitChannel(quit) + s.SearchFunc("", searchCaseInsensitive{}) + s.BindFunc("", bindCaseInsensitive{}) + if err := s.ListenAndServe(listenString); err != nil { + t.Errorf("s.ListenAndServe failed: %s", err.Error()) + } + }() + + go func() { + cmd := exec.Command("ldapsearch", "-H", ldapURL, "-x", + "-b", "cn=Case,o=testers,c=test", "-D", "cn=CAse,o=testers,c=test", "-w", "iLike2test", "-s", "base", "cn=CASe") + out, _ := cmd.CombinedOutput() + if !strings.Contains(string(out), "dn: cn=CASE,o=testers,c=test") { + t.Errorf("ldapsearch 'base' scope failed - didn't find expected DN: %v", string(out)) + } + + done <- true + }() + + select { + case <-done: + case <-time.After(timeout): + t.Errorf("ldapsearch command timed out") + } + quit <- true +} + + func TestSearchControls(t *testing.T) { quit := make(chan bool) done := make(chan bool) -- cgit v1.2.3