@@ -8,32 +8,43 @@ import (
88 "time"
99
1010 // Packages
11-
12- "github.com/mutablelogic/go-server/pkg/httpresponse"
11+ httpresponse "github.com/mutablelogic/go-server/pkg/httpresponse"
1312 ldap "github.com/mutablelogic/go-server/pkg/ldap"
1413 schema "github.com/mutablelogic/go-server/pkg/ldap/schema"
1514 assert "github.com/stretchr/testify/assert"
1615)
1716
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+
1827/////////////////////////////////////////////////////////////////////////////////
1928// PUBLIC METHODS
2029
21- func Test_Manager_001 (t * testing.T ) {
22- assert := assert .New (t )
23-
30+ func TestMain (m * testing.M ) {
2431 // Get opts
25- opts := []ldap.Opt {}
2632 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+ }
3337 } 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 () )
3539 }
3640
41+ exitCode := m .Run ()
42+ os .Exit (exitCode )
43+ }
44+
45+ func Test_Manager_001 (t * testing.T ) {
46+ assert := assert .New (t )
47+
3748 // Create a new queue manager
3849 manager , err := ldap .NewManager (opts ... )
3950 if ! assert .NoError (err ) {
@@ -79,19 +90,6 @@ func Test_Manager_001(t *testing.T) {
7990func Test_Manager_002 (t * testing.T ) {
8091 assert := assert .New (t )
8192
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-
9593 // Create a new queue manager
9694 manager , err := ldap .NewManager (opts ... )
9795 if ! assert .NoError (err ) {
@@ -126,19 +124,6 @@ func Test_Manager_002(t *testing.T) {
126124func Test_Manager_003 (t * testing.T ) {
127125 assert := assert .New (t )
128126
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-
142127 // Create a new queue manager
143128 manager , err := ldap .NewManager (opts ... )
144129 if ! assert .NoError (err ) {
0 commit comments