diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-02-02 09:32:00 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-02-02 09:32:00 -0500 |
commit | 701d1ab638b23c24877fc41824add66232446676 (patch) | |
tree | ec120c88d38ac9d38d9eabdd3270b52bb6ac9d96 /vendor/github.com/go-ldap/ldap/control_test.go | |
parent | ca3211bc04f6dea34e8168217182637d1419f998 (diff) | |
download | chat-701d1ab638b23c24877fc41824add66232446676.tar.gz chat-701d1ab638b23c24877fc41824add66232446676.tar.bz2 chat-701d1ab638b23c24877fc41824add66232446676.zip |
Updating server dependancies (#5249)
Diffstat (limited to 'vendor/github.com/go-ldap/ldap/control_test.go')
-rw-r--r-- | vendor/github.com/go-ldap/ldap/control_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/go-ldap/ldap/control_test.go b/vendor/github.com/go-ldap/ldap/control_test.go index 3fcdab0d7..11527463e 100644 --- a/vendor/github.com/go-ldap/ldap/control_test.go +++ b/vendor/github.com/go-ldap/ldap/control_test.go @@ -56,3 +56,42 @@ func runControlTest(t *testing.T, originalControl Control) { t.Errorf("%sgot different type decoding from encoded bytes: %T vs %T", header, fromBytes, originalControl) } } + +func TestDescribeControlManageDsaIT(t *testing.T) { + runAddControlDescriptions(t, NewControlManageDsaIT(false), "Control Type (Manage DSA IT)") + runAddControlDescriptions(t, NewControlManageDsaIT(true), "Control Type (Manage DSA IT)", "Criticality") +} + +func TestDescribeControlPaging(t *testing.T) { + runAddControlDescriptions(t, NewControlPaging(100), "Control Type (Paging)", "Control Value (Paging)") + runAddControlDescriptions(t, NewControlPaging(0), "Control Type (Paging)", "Control Value (Paging)") +} + +func TestDescribeControlString(t *testing.T) { + runAddControlDescriptions(t, NewControlString("x", true, "y"), "Control Type ()", "Criticality", "Control Value") + runAddControlDescriptions(t, NewControlString("x", true, ""), "Control Type ()", "Criticality", "Control Value") + runAddControlDescriptions(t, NewControlString("x", false, "y"), "Control Type ()", "Control Value") + runAddControlDescriptions(t, NewControlString("x", false, ""), "Control Type ()", "Control Value") +} + +func runAddControlDescriptions(t *testing.T, originalControl Control, childDescriptions ...string) { + header := "" + if callerpc, _, line, ok := runtime.Caller(1); ok { + if caller := runtime.FuncForPC(callerpc); caller != nil { + header = fmt.Sprintf("%s:%d: ", caller.Name(), line) + } + } + + encodedControls := encodeControls([]Control{originalControl}) + addControlDescriptions(encodedControls) + encodedPacket := encodedControls.Children[0] + if len(encodedPacket.Children) != len(childDescriptions) { + t.Errorf("%sinvalid number of children: %d != %d", header, len(encodedPacket.Children), len(childDescriptions)) + } + for i, desc := range childDescriptions { + if encodedPacket.Children[i].Description != desc { + t.Errorf("%sdescription not as expected: %s != %s", header, encodedPacket.Children[i].Description, desc) + } + } + +} |