diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-07-20 18:27:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 18:27:43 +0200 |
commit | 7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80 (patch) | |
tree | 16215733e543353c2bd5efd1dcf89c7879e2ad3d /server_test.go | |
parent | Fixed handling of UTF8 chars in filter value (#9) (diff) | |
download | ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.gz ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.bz2 ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.lz ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.xz ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.zst ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.zip |
Diffstat (limited to 'server_test.go')
-rw-r--r-- | server_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/server_test.go b/server_test.go index 88c47bf..233f7ea 100644 --- a/server_test.go +++ b/server_test.go @@ -329,6 +329,17 @@ func (b bindPanic) Bind(bindDN, bindSimplePw string, conn net.Conn) (LDAPResultC return LDAPResultInvalidCredentials, nil } +type bindCaseInsensitive struct { +} + +func (b bindCaseInsensitive) Bind(bindDN, bindSimplePw string, conn net.Conn) (LDAPResultCode, error) { + if strings.ToLower(bindDN) == "cn=case,o=testers,c=test" && bindSimplePw == "iLike2test" { + return LDAPResultSuccess, nil + } + return LDAPResultInvalidCredentials, nil +} + + type searchSimple struct { } @@ -408,3 +419,41 @@ func (s searchControls) Search(boundDN string, searchReq SearchRequest, conn net } return ServerSearchResult{entries, []string{}, []Control{}, LDAPResultSuccess}, nil } + + +type searchCaseInsensitive struct { +} + +func (s searchCaseInsensitive) Search(boundDN string, searchReq SearchRequest, conn net.Conn) (ServerSearchResult, error) { + entries := []*Entry{ + &Entry{"cn=CASE,o=testers,c=test", []*EntryAttribute{ + &EntryAttribute{"cn", []string{"CaSe"}}, + &EntryAttribute{"o", []string{"ate"}}, + &EntryAttribute{"uidNumber", []string{"5005"}}, + &EntryAttribute{"accountstatus", []string{"active"}}, + &EntryAttribute{"uid", []string{"trent"}}, + &EntryAttribute{"description", []string{"trent via sa"}}, + &EntryAttribute{"objectclass", []string{"posixaccount"}}, + }}, + } + return ServerSearchResult{entries, []string{}, []Control{}, LDAPResultSuccess}, nil +} + + +func TestRouteFunc(t *testing.T) { + if routeFunc("", []string{"a", "xyz", "tt"}) != "" { + t.Error("routeFunc failed") + } + if routeFunc("a=b", []string{"a=b", "x=y,a=b", "tt"}) != "a=b" { + t.Error("routeFunc failed") + } + if routeFunc("x=y,a=b", []string{"a=b", "x=y,a=b", "tt"}) != "x=y,a=b" { + t.Error("routeFunc failed") + } + if routeFunc("x=y,a=b", []string{"x=y,a=b", "a=b", "tt"}) != "x=y,a=b" { + t.Error("routeFunc failed") + } + if routeFunc("nosuch", []string{"x=y,a=b", "a=b", "tt"}) != "" { + t.Error("routeFunc failed") + } +} |