yao/integrations/telegram/verify_test.go
Max ea9e070f29 Enhance robot integration with Telegram and improve event handling
- Add Telegram integration support by introducing a dispatcher for handling Telegram events and messages.
- Implement event notifications for robot configuration changes (creation, update, deletion) to facilitate integration with external services.
- Refactor the robot initialization process to load robots into cache and start the dispatcher, improving the overall system setup.
- Update the delivery event structure to include additional metadata for better context during message handling.
- Enhance logging capabilities for better observability during robot execution and event processing.
2026-03-01 22:03:25 +08:00

32 lines
750 B
Go

package telegram
import (
"testing"
)
func TestVerifyWebhook_NoSecret(t *testing.T) {
b := NewBot("token", "")
if !b.VerifyWebhook("anything") {
t.Fatal("should pass when no secret configured")
}
if !b.VerifyWebhook("") {
t.Fatal("should pass with empty header when no secret configured")
}
}
func TestVerifyWebhook_CorrectSecret(t *testing.T) {
b := NewBot("token", "s3cr3t-t0ken")
if !b.VerifyWebhook("s3cr3t-t0ken") {
t.Fatal("should pass with matching secret")
}
}
func TestVerifyWebhook_WrongSecret(t *testing.T) {
b := NewBot("token", "s3cr3t-t0ken")
if b.VerifyWebhook("wrong") {
t.Fatal("should reject mismatched secret")
}
if b.VerifyWebhook("") {
t.Fatal("should reject empty header when secret configured")
}
}