-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadministration_list_test.go
54 lines (43 loc) · 1.15 KB
/
administration_list_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
package minox_test
import (
"encoding/json"
"log"
"os"
"strconv"
"testing"
_ "github.com/joho/godotenv/autoload"
minox "github.com/omniboost/go-minox"
"golang.org/x/oauth2"
)
func TestAdministrationListGet(t *testing.T) {
clientID := os.Getenv("OAUTH_CLIENT_ID")
clientSecret := os.Getenv("OAUTH_CLIENT_SECRET")
accessToken := os.Getenv("OAUTH_ACCESS_TOKEN")
tokenURL := os.Getenv("OAUTH_TOKEN_URL")
tenant, err := strconv.Atoi(os.Getenv("MINOX_TENANT"))
if err != nil {
t.Error(err)
}
oauthConfig := minox.NewOauth2Config()
oauthConfig.ClientID = clientID
oauthConfig.ClientSecret = clientSecret
// set alternative token url
if tokenURL != "" {
oauthConfig.Endpoint.TokenURL = tokenURL
}
token := &oauth2.Token{
AccessToken: accessToken,
}
// get http client with automatic oauth logic
httpClient := oauthConfig.Client(oauth2.NoContext, token)
client := minox.NewClient(httpClient, tenant)
client.SetDebug(true)
client.SetDisallowUnknownFields(true)
req := client.NewAdministrationListGetRequest()
resp, err := req.Do()
if err != nil {
t.Error(err)
}
b, _ := json.MarshalIndent(resp, "", " ")
log.Println(string(b))
}