MCPcopy Create free account
hub / github.com/compozy/agh / TestNormalizeEnvelopeValidKinds

Function TestNormalizeEnvelopeValidKinds

internal/network/validate_test.go:15–227  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestNormalizeEnvelopeValidKinds(t *testing.T) {
16 t.Parallel()
17
18 now := time.Date(2026, 4, 10, 12, 0, 0, 0, time.UTC)
19 opts := ValidateOptions{Now: now, MaxReplayAge: DefaultMaxReplayAge}
20
21 target := "reviewer.sess-xyz"
22 workID := "work_patch_42"
23 replyTo := "msg_direct_00"
24 traceID := "trace_patch_42"
25
26 cases := []struct {
27 name string
28 envelope Envelope
29 wantKind Kind
30 wantType reflect.Type
31 }{
32 {
33 name: "Should normalize greet envelopes",
34 envelope: Envelope{
35 Protocol: " agh-network/v0 ",
36 WorkspaceID: " wks_test ",
37 ID: " msg_greet_01 ",
38 Kind: " greet ",
39 Channel: " builders ",
40 From: " coder.sess-abc ",
41 To: nil,
42 TS: now.Unix(),
43 Body: mustRawJSON(t, map[string]any{
44 "peer_card": map[string]any{
45 "peer_id": "coder.sess-abc",
46 "profiles_supported": []string{"agh-network/v0"},
47 "capabilities": []string{"workspace.patch.apply"},
48 "artifacts_supported": []string{"capability"},
49 "trust_modes_supported": []string{"unverified"},
50 },
51 "summary": "hello",
52 }),
53 },
54 wantKind: KindGreet,
55 wantType: reflect.TypeFor[GreetBody](),
56 },
57 {
58 name: "Should normalize whois response envelopes",
59 envelope: Envelope{
60 Protocol: "agh-network/v0",
61 WorkspaceID: testWorkspaceID,
62 ID: "msg_whois_01",
63 Kind: KindWhois,
64 Channel: "builders",
65 From: "coder.sess-abc",
66 To: &target,
67 ReplyTo: &replyTo,
68 TS: now.Unix(),
69 Body: mustRawJSON(t, map[string]any{
70 "type": "response",
71 "peer_card": map[string]any{
72 "peer_id": "coder.sess-abc",

Callers

nothing calls this directly

Calls 6

mustCapabilityBodyJSONFunction · 0.85
NormalizeEnvelopeFunction · 0.85
ContainsMethod · 0.80
DecodeBodyMethod · 0.80
mustRawJSONFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected