dana-medical-site/internal/bitrix/redact_test.go
2026-10-14 13:33:13 +00:00

26 lines
930 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package bitrix
import (
"context"
"strings"
"testing"
"time"
)
// Вебхук недоступен (сеть, таймаут): в тексте ошибки не должно быть адреса с секретным ключом —
// он уходит в лог, в базу и в админку.
func TestNetworkErrorsDoNotLeakWebhookKey(t *testing.T) {
c := New("http://127.0.0.1:1/rest/1/SECRETKEY123/")
c.HTTP.Timeout = 2 * time.Second
_, errAdd := c.AddLead(context.Background(), LeadDraft{Title: "x"})
_, errList := c.Leads(context.Background(), time.Time{}, time.Time{}, nil)
for name, err := range map[string]error{"crm.lead.add": errAdd, "crm.lead.list": errList} {
if err == nil {
t.Fatalf("%s: ожидали сетевую ошибку", name)
}
if strings.Contains(err.Error(), "SECRETKEY123") {
t.Errorf("%s: ключ вебхука в тексте ошибки: %q", name, err)
}
}
}