-
Notifications
You must be signed in to change notification settings - Fork 27
/
modify_test.go
53 lines (47 loc) · 1.28 KB
/
modify_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ldap
import (
//"encoding/hex"
"fmt"
"github.com/mavricknz/asn1-ber"
"testing"
//"bytes"
)
var modDNs []string = []string{"cn=bob,o=bigcorp", "uid=eworker,ou=people,o=smallcrop"}
var modAttrs []string = []string{"cn"} //,"uid","sn"}
var modValues []string = []string{"aaa", "bbb", "ccc"}
func TestModify(t *testing.T) {
for _, dn := range modDNs {
modreq := NewModifyRequest(dn)
for _, attr := range modAttrs {
for _, val := range modValues {
mod := NewMod(ModAdd, attr, []string{val})
modreq.AddMod(mod)
}
}
fmt.Print(modreq)
}
}
func TestModifyMods(t *testing.T) {
for _, dn := range modDNs {
mods := make([]Mod, 0, 5)
modreq := NewModifyRequest(dn)
for _, attr := range modAttrs {
mod := NewMod(ModAdd, attr, modValues)
mods = append(mods, *mod)
}
modreq.AddMods(mods)
fmt.Print(modreq)
}
}
func TestModifyEncodeModifyRequest(t *testing.T) {
modreq := NewModifyRequest(modDNs[0])
mod := NewMod(ModAdd, modAttrs[0], modValues)
modundo := NewMod(ModDelete, modAttrs[0], modValues)
modreq.AddMod(mod)
modreq.AddMod(modundo)
p := encodeModifyRequest(modreq)
ber.PrintPacket(p)
}