(new): rich message support
(fix): runtime reliability (tests): regression coverage (doc): v1.1 release notes
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user