修复支付网关地址空白字符
This commit is contained in:
@@ -125,6 +125,14 @@ func TestCreatePaymentSetsCounterParamWhenPayModeConfigured(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePaymentTrimsGatewayURLWhitespace(t *testing.T) {
|
||||
body := captureCreatePaymentBody(t, "", "\t")
|
||||
reqData := body["req_data"].(map[string]any)
|
||||
if reqData["out_order_no"] != "ORDER1" {
|
||||
t.Fatalf("out_order_no = %#v, want ORDER1", reqData["out_order_no"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePaymentUsesShanghaiTimeWhenLocalIsUTC(t *testing.T) {
|
||||
oldLocal := time.Local
|
||||
time.Local = time.UTC
|
||||
@@ -179,7 +187,7 @@ func testKeyPairPEM(t *testing.T, key *rsa.PrivateKey) (string, string) {
|
||||
return privatePEM, certPEM
|
||||
}
|
||||
|
||||
func captureCreatePaymentBody(t *testing.T, payMode string) map[string]any {
|
||||
func captureCreatePaymentBody(t *testing.T, payMode string, gatewaySuffix ...string) map[string]any {
|
||||
t.Helper()
|
||||
var captured map[string]any
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -199,8 +207,12 @@ func captureCreatePaymentBody(t *testing.T, payMode string) map[string]any {
|
||||
t.Fatalf("generate key: %v", err)
|
||||
}
|
||||
privatePEM, certPEM := testKeyPairPEM(t, key)
|
||||
gatewayURL := server.URL
|
||||
if len(gatewaySuffix) > 0 {
|
||||
gatewayURL += gatewaySuffix[0]
|
||||
}
|
||||
client := NewClient(Config{
|
||||
GatewayURL: server.URL,
|
||||
GatewayURL: gatewayURL,
|
||||
AppID: "app-1",
|
||||
SerialNo: "serial-1",
|
||||
MerchantID: "merchant-1",
|
||||
|
||||
Reference in New Issue
Block a user