package gatewayrpc import ( "context" "net/http" "net/http/httptest" "testing" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/samcharles93/archie-core/internal/domain/messaging" ) // TestChatWireKeepsGatewayInputs pins the fields the Gateway decides on // across the messaging-to-gateway hop. func TestChatWireKeepsGatewayInputs(t *testing.T) { in := messaging.Inbound{Message: messaging.Message{SenderID: "42"}, Platform: "telegram"} got := inboundValue(inboundProto(in)) if got.Message.SenderID != "42" || got.Platform != "telegram" { t.Fatalf("inbound round trip lost a field: %+v", got) } } // TestCheckInboundRefusesContradictoryMedia pins that a channel extension // cannot deliver an attachment whose declared type its bytes contradict. func TestCheckInboundRefusesContradictoryMedia(t *testing.T) { // The URL-only rows are served from a local host, which the production // client refuses, so the test client is a plain one. srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/png": _, _ = w.Write([]byte("\x89PNG\r\n\x1a\n")) case "/html": _, _ = w.Write([]byte("