(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
+27
View File
@@ -255,6 +255,33 @@ func TestValidateWebhookTLSFiles(t *testing.T) {
}
}
func TestValidateWebhookSecretToken(t *testing.T) {
tests := []struct {
name string
token string
wantErr bool
}{
{name: "minimum", token: "a"},
{name: "allowed alphabet", token: "AZaz09_-"},
{name: "maximum", token: strings.Repeat("a", 256)},
{name: "empty", token: "", wantErr: true},
{name: "too long", token: strings.Repeat("a", 257), wantErr: true},
{name: "padding", token: "abc=", wantErr: true},
{name: "non ASCII", token: "секрет", wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := validateWebhookSecretToken(tt.token)
if tt.wantErr && !errors.Is(err, ErrBotWebhookOptsSecretTokenInvalid) {
t.Fatalf("expected ErrBotWebhookOptsSecretTokenInvalid, got %v", err)
}
if !tt.wantErr && err != nil {
t.Fatalf("unexpected error: %v", err)
}
})
}
}
func TestUpdateHandlerRejectsOversizedBody(t *testing.T) {
bot := &Bot[NoData]{
updateQueue: make(chan *tgapi.Update, 1),