fix: 完成商务迁移复核与接口优化并清理历史资料
This commit is contained in:
@@ -501,7 +501,12 @@ func IsIntegrationSecretKey(key string) bool {
|
||||
if strings.Contains(normalized, "secret") || strings.Contains(normalized, "password") || strings.Contains(normalized, "private") || strings.Contains(normalized, "credential") || strings.Contains(normalized, "token") {
|
||||
return true
|
||||
}
|
||||
for _, item := range []string{"key_pem", "api_key", "mch_key", "client_key", "certificate", "cert", "cert_pem", "p12", "pkcs12", "public_key", "platform_cert", "root_cert"} {
|
||||
// Providers accept inline PEM, file and path aliases of the same secret.
|
||||
// Strip only these transport suffixes; ordinary content/path fields stay public.
|
||||
for _, suffix := range []string{"_content", "_path", "_file", "_pem"} {
|
||||
normalized = strings.TrimSuffix(normalized, suffix)
|
||||
}
|
||||
for _, item := range []string{"key", "api_key", "mch_key", "client_key", "certificate", "cert", "p12", "pkcs12", "public_key", "platform_cert", "root_cert"} {
|
||||
if normalized == item || strings.HasSuffix(normalized, "_"+item) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package integration
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIntegrationCertificateAliases(t *testing.T) {
|
||||
for _, key := range []string{"app_cert_content", "root_cert_path", "alipay_public_cert_content", "pkcs12_content", "p12_file", "cert_content", "key_content", "cert_path", "key_file", "client_key", "public_key_pem"} {
|
||||
if !IsIntegrationSecretKey(key) {
|
||||
t.Errorf("secret alias was not recognized: %s", key)
|
||||
}
|
||||
}
|
||||
for _, key := range []string{"content", "path", "notify_url", "template_content", "content_type", "platform_serial_no", "public_key_id"} {
|
||||
if IsIntegrationSecretKey(key) {
|
||||
t.Errorf("public field was masked: %s", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user