@@ -8,32 +8,43 @@ import (
8
8
"time"
9
9
10
10
// Packages
11
-
12
- "github.com/mutablelogic/go-server/pkg/httpresponse"
11
+ httpresponse "github.com/mutablelogic/go-server/pkg/httpresponse"
13
12
ldap "github.com/mutablelogic/go-server/pkg/ldap"
14
13
schema "github.com/mutablelogic/go-server/pkg/ldap/schema"
15
14
assert "github.com/stretchr/testify/assert"
16
15
)
17
16
17
+ const (
18
+ User , Pass = "uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org" , "Secret123"
19
+ URL = "ldaps://ipa.demo1.freeipa.org/"
20
+ BaseDN = "dc=demo1,dc=freeipa,dc=org"
21
+ )
22
+
23
+ var (
24
+ opts = []ldap.Opt {}
25
+ )
26
+
18
27
/////////////////////////////////////////////////////////////////////////////////
19
28
// PUBLIC METHODS
20
29
21
- func Test_Manager_001 (t * testing.T ) {
22
- assert := assert .New (t )
23
-
30
+ func TestMain (m * testing.M ) {
24
31
// Get opts
25
- opts := []ldap.Opt {}
26
32
if url := os .Getenv ("LDAP_URL" ); url != "" {
27
- opts = append (opts , ldap .WithUrl (url ))
28
- } else {
29
- t .Skip ("Skipping test, LDAP_URL not set" )
30
- }
31
- if dn := os .Getenv ("LDAP_BASE_DN" ); dn != "" {
32
- opts = append (opts , ldap .WithBaseDN (dn ))
33
+ opts = append (opts , ldap .WithUrl (url ), ldap .WithUser (os .Getenv ("LDAP_USER" )), ldap .WithPassword (os .Getenv ("LDAP_PASSWORD" )))
34
+ if dn := os .Getenv ("LDAP_BASE_DN" ); dn != "" {
35
+ opts = append (opts , ldap .WithBaseDN (dn ))
36
+ }
33
37
} else {
34
- t . Skip ( "Skipping test, LDAP_BASE_DN not set" )
38
+ opts = append ( opts , ldap . WithUrl ( URL ), ldap . WithUser ( User ), ldap . WithPassword ( Pass ), ldap . WithBaseDN ( BaseDN ), ldap . WithSkipVerify () )
35
39
}
36
40
41
+ exitCode := m .Run ()
42
+ os .Exit (exitCode )
43
+ }
44
+
45
+ func Test_Manager_001 (t * testing.T ) {
46
+ assert := assert .New (t )
47
+
37
48
// Create a new queue manager
38
49
manager , err := ldap .NewManager (opts ... )
39
50
if ! assert .NoError (err ) {
@@ -79,19 +90,6 @@ func Test_Manager_001(t *testing.T) {
79
90
func Test_Manager_002 (t * testing.T ) {
80
91
assert := assert .New (t )
81
92
82
- // Get opts
83
- opts := []ldap.Opt {}
84
- if url := os .Getenv ("LDAP_URL" ); url != "" {
85
- opts = append (opts , ldap .WithUrl (url ))
86
- } else {
87
- t .Skip ("Skipping test, LDAP_URL not set" )
88
- }
89
- if dn := os .Getenv ("LDAP_BASE_DN" ); dn != "" {
90
- opts = append (opts , ldap .WithBaseDN (dn ))
91
- } else {
92
- t .Skip ("Skipping test, LDAP_BASE_DN not set" )
93
- }
94
-
95
93
// Create a new queue manager
96
94
manager , err := ldap .NewManager (opts ... )
97
95
if ! assert .NoError (err ) {
@@ -126,19 +124,6 @@ func Test_Manager_002(t *testing.T) {
126
124
func Test_Manager_003 (t * testing.T ) {
127
125
assert := assert .New (t )
128
126
129
- // Get opts
130
- opts := []ldap.Opt {}
131
- if url := os .Getenv ("LDAP_URL" ); url != "" {
132
- opts = append (opts , ldap .WithUrl (url ))
133
- } else {
134
- t .Skip ("Skipping test, LDAP_URL not set" )
135
- }
136
- if dn := os .Getenv ("LDAP_BASE_DN" ); dn != "" {
137
- opts = append (opts , ldap .WithBaseDN (dn ))
138
- } else {
139
- t .Skip ("Skipping test, LDAP_BASE_DN not set" )
140
- }
141
-
142
127
// Create a new queue manager
143
128
manager , err := ldap .NewManager (opts ... )
144
129
if ! assert .NoError (err ) {
0 commit comments