-
Notifications
You must be signed in to change notification settings - Fork 28
/
timeout_test.go
77 lines (67 loc) · 1.49 KB
/
timeout_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package ldap
import (
"crypto/tls"
"fmt"
"testing"
"time"
)
func TestSearchTimeout(t *testing.T) {
fmt.Printf("TestSearchTimeout: starting...\n")
l := NewLDAPConnection(ldap_server, ldap_port)
l.NetworkConnectTimeout = 5000 * time.Millisecond
l.ReadTimeout = 30 * time.Second
l.AbandonMessageOnReadTimeout = true
err := l.Connect()
if err != nil {
t.Error(err)
return
}
if l == nil {
t.Errorf("No Connection.")
return
}
defer l.Close()
search_request := NewSimpleSearchRequest(
base_dn,
ScopeWholeSubtree,
filter[0],
attributes,
)
sr, err := l.Search(search_request)
if err != nil {
t.Error(err)
return
}
fmt.Printf("TestSearchTimeout: %s -> num of entries = %d\n", search_request.Filter, len(sr.Entries))
}
func TestSearchTimeoutSSL(t *testing.T) {
fmt.Printf("TestSearchTimeoutSSL: starting...\n")
config := &tls.Config{
InsecureSkipVerify: true,
}
l := &LDAPConnection{
Addr: fmt.Sprintf("%s:%d", ldap_server, 636),
IsSSL: true,
TlsConfig: config,
NetworkConnectTimeout: 5000 * time.Millisecond,
ReadTimeout: 30 * time.Second,
}
err := l.Connect()
if err != nil {
t.Error(err)
return
}
defer l.Close()
search_request := NewSimpleSearchRequest(
base_dn,
ScopeWholeSubtree,
filter[0],
attributes,
)
sr, err := l.Search(search_request)
if err != nil {
t.Error(err)
return
}
fmt.Printf("TestSearchTimeoutSSL: %s -> num of entries = %d\n", search_request.Filter, len(sr.Entries))
}