fix: 完成商务迁移复核与接口优化并清理历史资料
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package payment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
paymentbiz "kra/internal/biz/payment"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type diagnosticRepo struct{ paymentbiz.PaymentRepo }
|
||||
|
||||
func (diagnosticRepo) TestProvider(context.Context, string) (*paymentbiz.PaymentTestResult, error) {
|
||||
return &paymentbiz.PaymentTestResult{Provider: "alipay", Stages: []paymentbiz.PaymentTestStage{
|
||||
{Name: "config", Status: "passed", Message: "配置已检查"},
|
||||
{Name: "create", Status: "failed", Message: "https://merchant:secret@example.test/private?token=secret"},
|
||||
}}, errors.New("provider response contains a secret")
|
||||
}
|
||||
|
||||
func TestProviderDiagnosticsDoNotExposeRawErrors(t *testing.T) {
|
||||
s := NewPaymentService(paymentbiz.NewPaymentUsecase(diagnosticRepo{}, nil, nil, nil, nil, nil))
|
||||
result, err := s.TestProvider(context.Background(), "alipay")
|
||||
if err != paymentbiz.ErrPaymentTestFailed {
|
||||
t.Fatalf("unsafe diagnostic error: %v", err)
|
||||
}
|
||||
if result == nil || len(result.Stages) != 2 || result.Stages[0].Message != "配置已检查" || result.Stages[1].Message != "该步骤失败,请检查配置和服务端日志" {
|
||||
t.Fatalf("unexpected diagnostic response: %+v", result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user