-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfraud_test.go
110 lines (88 loc) · 2.71 KB
/
fraud_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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package tests
import (
"context"
"github.com/craftgate/craftgate-go-client/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
"github.com/davecgh/go-spew/spew"
"testing"
)
var fraudClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io")
func Test_SearchFraudChecks(t *testing.T) {
request := adapter.SearchFraudChecksRequest{
Page: 0, Size: 10,
}
res, err := fraudClient.Fraud.SearchFraudChecks(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_RetrieveAllFraudValueList(t *testing.T) {
res, err := fraudClient.Fraud.RetrieveAllFraudValueList(context.Background())
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_RetrieveFraudValueList(t *testing.T) {
res, err := fraudClient.Fraud.RetrieveFraudValueList(context.Background(), "blockedBuyerIdList")
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_CreateFraudValueList(t *testing.T) {
err := fraudClient.Fraud.CreateFraudValueList(context.Background(), "ipList", craftgate.FraudValueType_IP)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_DeleteFraudValueList(t *testing.T) {
err := fraudClient.Fraud.DeleteFraudValueList(context.Background(), "myTestList")
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_AddValueToFraudValueList(t *testing.T) {
request := adapter.FraudValueListRequest{
ListName: "ipList",
Type: craftgate.FraudValueType_IP,
Label: "local ip 1",
Value: "127.0.0.1",
}
err := fraudClient.Fraud.AddValueToFraudValueList(context.Background(), request)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_AddTemporaryValueToFraudValueList(t *testing.T) {
request := adapter.FraudValueListRequest{
ListName: "ipList",
Type: craftgate.FraudValueType_IP,
Label: "local ip 2",
Value: "127.0.0.2",
DurationInSeconds: 60,
}
err := fraudClient.Fraud.AddValueToFraudValueList(context.Background(), request)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_AddCardFingerprintToFraudValueList(t *testing.T) {
request := adapter.FraudValueListRequest{
ListName: "cardList",
Type: craftgate.FraudValueType_CARD,
Label: "John Doe's Card",
PaymentId: 11675,
}
err := fraudClient.Fraud.AddValueToFraudValueList(context.Background(), request)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_RemoveValueFromFraudValueList(t *testing.T) {
err := fraudClient.Fraud.RemoveValueFromFraudValueList(context.Background(), "ipList", "7aac0ad8-d170-4c2b-89d3-440fcf145b35")
if err != nil {
t.Errorf("Error %s", err)
}
}