This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsangudana_test.go
81 lines (68 loc) · 1.58 KB
/
sangudana_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
78
79
80
81
package dana
import (
"fmt"
"io/ioutil"
"testing"
"github.com/BurntSushi/toml"
"github.com/stretchr/testify/suite"
)
type DanaSanguTestSuite struct {
suite.Suite
client Client
}
type credentials struct {
BaseUrl string
Version string
ClientId string
ClientSecret string
}
func TestDanaSanguTestSuite(t *testing.T) {
suite.Run(t, new(DanaSanguTestSuite))
}
func (d *DanaSanguTestSuite) SetupSuite() {
theToml, err := ioutil.ReadFile("credential_test.toml")
if err != nil {
d.T().Log(err)
d.T().FailNow()
}
var cred credentials
if _, err := toml.Decode(string(theToml), &cred); err != nil {
d.T().Log(err)
d.T().FailNow()
}
d.client = NewClient()
d.client.BaseUrl = cred.BaseUrl
d.client.Version = cred.Version
d.client.ClientId = cred.ClientId
d.client.ClientSecret = cred.ClientSecret
d.client.LogLevel = 3
d.client.SignatureEnabled = true
privateKey, err := ioutil.ReadFile("my_private.pem")
if err != nil {
d.T().Log(err)
d.T().FailNow()
}
d.client.PrivateKey = privateKey
publicKey, err := ioutil.ReadFile("dana_public.pem")
if err != nil {
d.T().Log(err)
d.T().FailNow()
}
d.client.PublicKey = publicKey
}
func (d *DanaSanguTestSuite) TestApplyTokenSuccess() {
coreGateway := CoreGateway{
Client: d.client,
}
reqBody := &RequestApplyAccessToken{
GrantType: "AUTHORIZATION_CODE",
AuthCode: "2P8pZedLvCW70sBKc7kWP5SZxlULgWDoeGCO7300",
RefreshToken: "",
}
resp, err := coreGateway.ApplyAccessToken(reqBody)
if err != nil {
fmt.Printf("error: %v\n", err)
} else {
fmt.Printf("response: %v\n", resp.Response.Body)
}
}