-
Notifications
You must be signed in to change notification settings - Fork 12
/
environment_test.go
121 lines (97 loc) · 3.05 KB
/
environment_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
111
112
113
114
115
116
117
118
119
120
121
package adyen
import "testing"
func TestTestEnvironment(t *testing.T) {
act := TestEnvironment()
equals(t, Testing.apiURL, act.apiURL)
equals(t, Testing.clientURL, act.clientURL)
equals(t, Testing.hppURL, act.hppURL)
}
func TestBaseURLEnvironmentTesting(t *testing.T) {
env := TestEnvironment()
act := env.BaseURL("service", "version")
exp := "https://pal-test.adyen.com/pal/servlet/service/version"
equals(t, exp, act)
}
func TestClientURLEnvironmentTesting(t *testing.T) {
env := TestEnvironment()
act := env.ClientURL("clientID")
exp := "https://test.adyen.com/hpp/cse/js/clientID.shtml"
equals(t, exp, act)
}
func TestHppURLEnvironmentTest(t *testing.T) {
env := TestEnvironment()
act := env.HppURL("request")
exp := "https://test.adyen.com/hpp/request.shtml"
equals(t, exp, act)
}
func TestCheckoutURLEnvironmentTesting(t *testing.T) {
env := TestEnvironment()
act := env.CheckoutURL("service", "version")
exp := "https://checkout-test.adyen.com/services/PaymentSetupAndVerification/version/service"
equals(t, exp, act)
}
func TestEnvironmentProductionValidation(t *testing.T) {
cases := []struct {
name string
random string
companyName string
}{
{
name: "missing random",
random: "",
companyName: "AcmeAccount123",
},
{
name: "missing company name",
random: "5409c4fd1cc98a4e",
companyName: "",
},
{
name: "missing random and company name",
random: "",
companyName: "",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
_, err := ProductionEnvironment(c.random, c.companyName)
equals(t, errProdEnvValidation, err)
})
}
}
func TestBaseURLEnvironmentProduction(t *testing.T) {
env, err := ProductionEnvironment("5409c4fd1cc98a4e", "AcmeAccount123")
if err != nil {
t.Fatalf("error creating production environment: %v", err)
}
act := env.BaseURL("service", "version")
exp := "https://5409c4fd1cc98a4e-AcmeAccount123-pal-live.adyenpayments.com/pal/servlet/service/version"
equals(t, exp, act)
}
func TestClientURLEnvironmentProduction(t *testing.T) {
env, err := ProductionEnvironment("5409c4fd1cc98a4e", "AcmeAccount123")
if err != nil {
t.Fatalf("error creating production environment: %v", err)
}
act := env.ClientURL("clientID")
exp := "https://live.adyen.com/hpp/cse/js/clientID.shtml"
equals(t, exp, act)
}
func TestHppURLEnvironmentProduction(t *testing.T) {
env, err := ProductionEnvironment("5409c4fd1cc98a4e", "AcmeAccount123")
if err != nil {
t.Fatalf("error creating production environment: %v", err)
}
act := env.HppURL("request")
exp := "https://live.adyen.com/hpp/request.shtml"
equals(t, exp, act)
}
func TestCheckoutURLEnvironmentProduction(t *testing.T) {
env, err := ProductionEnvironment("5409c4fd1cc98a4e", "AcmeAccount123")
if err != nil {
t.Fatalf("error creating production environment: %v", err)
}
act := env.CheckoutURL("service", "version")
exp := "https://5409c4fd1cc98a4e-AcmeAccount123-checkout-live.adyenpayments.com/services/PaymentSetupAndVerification/version/service"
equals(t, exp, act)
}