mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-26 23:27:22 +00:00
fix: harden easypay custom method validation
This commit is contained in:
1 parent
bf76168ba5
commit
0dc6e56aae
4 files changed
+108
-4
No files matched your search
@@ -146,6 +146,18 @@ func TestValidateEasyPayCustomMethods(t *testing.T) {
|
||||
supportedTypes: "alipay,wxpay,ldc",
|
||||
wantErr: "duplicate customMethods type",
|
||||
},
|
||||
{
|
||||
name: "custom type must already be lowercase",
|
||||
config: map[string]string{"customMethods": `[{"type":"LDC","upstreamType":"epay"}]`},
|
||||
supportedTypes: "alipay,wxpay,ldc",
|
||||
wantErr: "customMethods type may only contain lowercase letters",
|
||||
},
|
||||
{
|
||||
name: "upstream type must already be lowercase",
|
||||
config: map[string]string{"customMethods": `[{"type":"ldc","upstreamType":"ALIPAY"}]`},
|
||||
supportedTypes: "alipay,wxpay,ldc",
|
||||
wantErr: "customMethods upstreamType may only contain lowercase letters",
|
||||
},
|
||||
{
|
||||
name: "custom type uses alipay prefix",
|
||||
config: map[string]string{"customMethods": `[{"type":"alipay_hk","upstreamType":"hkpay"}]`},
|
||||
@@ -164,6 +176,12 @@ func TestValidateEasyPayCustomMethods(t *testing.T) {
|
||||
supportedTypes: "alipay,wxpay,ldc,usdt_trc20",
|
||||
wantErr: "supported EasyPay custom type usdt_trc20 has no customMethods mapping",
|
||||
},
|
||||
{
|
||||
name: "supported custom type must already be lowercase",
|
||||
config: map[string]string{"customMethods": `[{"type":"ldc","upstreamType":"epay"}]`},
|
||||
supportedTypes: "alipay,wxpay,LDC",
|
||||
wantErr: "supported EasyPay custom type LDC may only contain lowercase letters",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
||||
Reference in new issue
Block a user