forked from smartwalle/alipay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
authorize_test.go
92 lines (80 loc) · 2.1 KB
/
authorize_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
82
83
84
85
86
87
88
89
90
91
92
package alipay_test
import (
"testing"
"github.com/smartwalle/alipay/v3"
)
func TestClient_PublicAppAuthorize(t *testing.T) {
t.Log("========== PublicAppAuthorize ==========")
var result, err = client.PublicAppAuthorize([]string{"auth_user"}, "http://127.0.0.1", "hhh")
t.Log(result, err)
}
func TestClient_SystemOauthToken(t *testing.T) {
t.Log("========== SystemOauthToken ==========")
var p = alipay.SystemOauthToken{}
p.GrantType = "authorization_code"
p.Code = "647f16afe0b44c49a8eb1cb3c02aXX31"
rsp, err := client.SystemOauthToken(p)
if err != nil {
t.Fatal(err)
}
if rsp.IsFailure() {
t.Fatal(rsp.Msg, rsp.SubMsg)
}
t.Logf("%v", rsp)
}
func TestClient_UserInfoShare(t *testing.T) {
t.Log("========== UserInfoShare ==========")
var p = alipay.UserInfoShare{}
p.AuthToken = "authusrB133e40c363934488a9c3e25e17fd9X31"
rsp, err := client.UserInfoShare(p)
if err != nil {
t.Fatal(err)
}
if rsp.IsFailure() {
t.Fatal(rsp.Msg, rsp.SubMsg)
}
t.Logf("%v", rsp)
}
func TestClient_AppToAppAuth(t *testing.T) {
t.Log("========== AppToAppAuth ==========")
var result, err = client.AppToAppAuth("http://127.0.0.1", "")
t.Log(result, err)
}
func TestClient_OpenAuthTokenApp(t *testing.T) {
t.Log("========== OpenAuthTokenApp ==========")
var p = alipay.OpenAuthTokenApp{}
p.GrantType = "authorization_code"
p.Code = "5a14fd7482254120a351109daedbdX31"
rsp, err := client.OpenAuthTokenApp(p)
if err != nil {
t.Fatal(err)
}
if rsp.IsFailure() {
t.Fatal(rsp.Msg, rsp.SubMsg)
}
t.Logf("%v", rsp)
}
func TestClient_AccountAuth(t *testing.T) {
t.Log("========== AccountAuth ==========")
var p = alipay.AccountAuth{}
p.Pid = "2088123456789012"
p.TargetId = "kkkkk091125"
p.AuthType = "AUTHACCOUNT"
result, err := client.AccountAuth(p)
if err != nil {
t.Fatal(err)
}
if result == "" {
t.Fatal(err)
}
t.Log(result)
}
func TestClient_OpenAuthAppAuthInviteCreate(t *testing.T) {
t.Log("========== OpenAuthAppAuthInviteCreate ==========")
var p = alipay.OpenAuthAppAuthInviteCreate{}
result, err := client.OpenAuthAppAuthInviteCreate(p)
if err != nil {
t.Fatal(err)
}
t.Log(result)
}