2026-07-30 12:38:28 -05:00
|
|
|
package wire
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestGeneratedWireContract(t *testing.T) {
|
|
|
|
|
if WireProtocolVersion != 1 {
|
|
|
|
|
t.Fatalf("unexpected wire protocol version: %d", WireProtocolVersion)
|
|
|
|
|
}
|
2026-08-03 23:29:16 -05:00
|
|
|
if len(CommandTypes) != 143 {
|
2026-07-30 12:38:28 -05:00
|
|
|
t.Fatalf("unexpected command count: %d", len(CommandTypes))
|
|
|
|
|
}
|
|
|
|
|
if len(CommandVersionSupport) != len(CommandTypes) {
|
|
|
|
|
t.Fatalf("command version catalog has %d entries, want %d", len(CommandVersionSupport), len(CommandTypes))
|
|
|
|
|
}
|
|
|
|
|
for _, command := range CommandTypes {
|
|
|
|
|
versionRange, ok := CommandVersionSupport[command]
|
|
|
|
|
if !ok {
|
|
|
|
|
t.Fatalf("missing version range for %s", command)
|
|
|
|
|
}
|
2026-08-20 10:57:56 -05:00
|
|
|
wantMin, wantMax := 1, 1
|
2026-08-20 09:01:27 -05:00
|
|
|
switch command {
|
|
|
|
|
case CommandBackstageStartBrowserInjected, CommandBackstageStartChromeInjected, CommandBackstageStartProcessInjected:
|
2026-08-20 10:57:56 -05:00
|
|
|
wantMin, wantMax = 2, 3
|
2026-08-20 09:01:27 -05:00
|
|
|
}
|
2026-08-20 10:57:56 -05:00
|
|
|
if versionRange.Min != wantMin || versionRange.Max != wantMax {
|
2026-07-30 12:38:28 -05:00
|
|
|
t.Fatalf("unexpected version range for %s: %+v", command, versionRange)
|
|
|
|
|
}
|
2026-08-20 10:57:56 -05:00
|
|
|
if IsSupportedCommandVersion(string(command), 1) != (wantMin == 1) {
|
|
|
|
|
t.Fatalf("unexpected v1 support for %s", command)
|
2026-07-30 12:38:28 -05:00
|
|
|
}
|
2026-08-20 10:57:56 -05:00
|
|
|
if IsSupportedCommandVersion(string(command), 2) != (wantMin <= 2 && wantMax >= 2) {
|
2026-08-20 09:01:27 -05:00
|
|
|
t.Fatalf("unexpected v2 support for %s", command)
|
2026-07-30 12:38:28 -05:00
|
|
|
}
|
2026-08-20 10:57:56 -05:00
|
|
|
if IsSupportedCommandVersion(string(command), 3) != (wantMin <= 3 && wantMax >= 3) {
|
|
|
|
|
t.Fatalf("unexpected v3 support for %s", command)
|
|
|
|
|
}
|
2026-07-30 12:38:28 -05:00
|
|
|
}
|
|
|
|
|
if !IsCommandType("desktop_start") {
|
|
|
|
|
t.Fatal("desktop_start must be a known command")
|
|
|
|
|
}
|
|
|
|
|
if !IsCommandType("virtual_window_list") {
|
|
|
|
|
t.Fatal("virtual_window_list must be a known command")
|
|
|
|
|
}
|
2026-08-03 23:29:16 -05:00
|
|
|
if !IsCommandType("file_upload_desktop") {
|
|
|
|
|
t.Fatal("file_upload_desktop must be a known command")
|
|
|
|
|
}
|
2026-07-30 12:38:28 -05:00
|
|
|
if IsCommandType("not_a_command") {
|
|
|
|
|
t.Fatal("unknown command was accepted")
|
|
|
|
|
}
|
|
|
|
|
if !IsServerToAgentMessageType("hello_ack") {
|
|
|
|
|
t.Fatal("hello_ack must be a known server message")
|
|
|
|
|
}
|
|
|
|
|
if IsServerToAgentMessageType("console_output") {
|
|
|
|
|
t.Fatal("agent-only message was accepted as a server message")
|
|
|
|
|
}
|
|
|
|
|
}
|