package channels import "testing" func TestBaseChannelIsAllowed(t *testing.T) { tests := []struct { name string allowList []string senderID string want bool }{ { name: "empty allowlist allows all", allowList: nil, senderID: "anyone", want: true, }, { name: "compound sender matches numeric allowlist", allowList: []string{"123456"}, senderID: "123456|alice", want: true, }, { name: "compound sender matches username allowlist", allowList: []string{"@alice"}, senderID: "123456|alice", want: true, }, { name: "numeric sender matches legacy compound allowlist", allowList: []string{"123456|alice"}, senderID: "123456", want: true, }, { name: "non matching sender is denied", allowList: []string{"123456"}, senderID: "654321|bob", want: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ch := NewBaseChannel("test", nil, nil, tt.allowList) if got := ch.IsAllowed(tt.senderID); got != tt.want { t.Fatalf("IsAllowed(%q) = %v, want %v", tt.senderID, got, tt.want) } }) } }