-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_test.go
55 lines (46 loc) · 1.25 KB
/
setup_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
package webservices_test
import (
"crypto/tls"
"log"
"net/http"
"net/url"
"os"
"testing"
"github.com/Azure/go-ntlmssp"
webservices "github.com/omniboost/go-exactglobe-webservices"
// ntlm "github.com/vadimi/go-http-ntlm"
)
var (
client *webservices.Client
)
func TestMain(m *testing.M) {
baseURLString := os.Getenv("GLOBE_BASE_URL")
baseURL, err := url.Parse(baseURLString)
if err != nil {
log.Fatal(err)
}
databaseName := os.Getenv("GLOBE_DATABASE_NAME")
databaseServerName := os.Getenv("GLOBE_DATABASE_SERVER_NAME")
username := os.Getenv("GLOBE_USERNAME")
password := os.Getenv("GLOBE_PASSWORD")
debug := os.Getenv("GLOBE_DEBUG")
log.Println(baseURLString, databaseName, username, password)
client = webservices.NewClient(nil, *baseURL, databaseName, databaseServerName)
if debug != "" {
client.SetDebug(true)
}
client.SetDisallowUnknownFields(true)
client.SetBeforeRequestDo(func(httpClient *http.Client, req *http.Request, body interface{}) {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
ForceAttemptHTTP2: false,
}
ntlmTransport := ntlmssp.Negotiator{
RoundTripper: tr,
}
httpClient.Transport = ntlmTransport
// Set credentials
req.SetBasicAuth(username, password)
})
m.Run()
}