(new): rich message support
Golang lint / lint (pull_request) Successful in 1m20s
Golang lint / lint (push) Successful in 4m8s

(fix): runtime reliability
(tests): regression coverage
(doc): v1.1 release notes
This commit is contained in:
2026-08-12 16:34:44 +03:00
parent 48ddf66540
commit f03a081ed6
83 changed files with 6122 additions and 1925 deletions
+39
View File
@@ -0,0 +1,39 @@
package tgapi
import (
"strings"
"testing"
)
func TestRedactRequestLogRemovesSensitiveValues(t *testing.T) {
const input = `{"secret_token":"webhook-secret","provider_token":"payment-token","nested":{"data":"passport-data","callback_data":"callback-secret"},"chat_id":42}`
got := redactRequestLog([]byte(input))
for _, secret := range []string{"webhook-secret", "payment-token", "passport-data", "callback-secret"} {
if strings.Contains(got, secret) {
t.Errorf("redacted request contains %q: %s", secret, got)
}
}
if !strings.Contains(got, `"chat_id":42`) {
t.Errorf("redacted request lost non-sensitive field: %s", got)
}
}
func TestRedactRequestLogOmitsInvalidJSON(t *testing.T) {
const secret = "not-json-secret"
got := redactRequestLog([]byte(secret))
if strings.Contains(got, secret) {
t.Fatalf("invalid JSON was logged verbatim: %s", got)
}
}
func TestResponseLogSummaryNeverContainsBody(t *testing.T) {
const token = "managed-bot-token"
got := responseLogSummary("getManagedBotToken", len(token))
if strings.Contains(got, token) {
t.Fatalf("response summary contains response body: %s", got)
}
if !strings.Contains(got, "body=omitted") {
t.Fatalf("response summary does not explain omission: %s", got)
}
}