From 663baf152f954a5b0633319efb29d53ed73574d9 Mon Sep 17 00:00:00 2001 From: mateea326 Date: Wed, 1 Apr 2026 21:46:00 +0300 Subject: [PATCH] added tests in pico_test --- pkg/channels/pico/pico_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/channels/pico/pico_test.go b/pkg/channels/pico/pico_test.go index e712767ad..7e5a72e08 100644 --- a/pkg/channels/pico/pico_test.go +++ b/pkg/channels/pico/pico_test.go @@ -142,3 +142,25 @@ func (c *PicoChannel) addConnForTest(pc *picoConn) { } bySession[pc.id] = pc } + +func TestNewPicoChannel_LeavesCheckOriginUnsetWithoutAllowOrigins(t *testing.T) { + ch := newTestPicoChannel(t) + + if ch.upgrader.CheckOrigin != nil { + t.Fatalf("CheckOrigin = %v, want nil when allow_origins is empty", ch.upgrader.CheckOrigin) + } +} + +func TestNewPicoChannel_SetsCheckOriginWithAllowOrigins(t *testing.T) { + cfg := config.PicoConfig{AllowOrigins: []string{"https://example.com"}} + cfg.SetToken("test-token") + + ch, err := NewPicoChannel(cfg, bus.NewMessageBus()) + if err != nil { + t.Fatalf("NewPicoChannel: %v", err) + } + + if ch.upgrader.CheckOrigin == nil { + t.Fatal("CheckOrigin is nil, want custom allowlist validation when allow_origins is set") + } +} \ No newline at end of file