=================================================================== Test 2: Register should use real hostname and meaningful username ===================================================================
(t *testing.T)
| 59 | // =================================================================== |
| 60 | |
| 61 | func TestE2E_Register_FieldMapping(t *testing.T) { |
| 62 | srv, rpcClient, cleanup := startTestServer(t) |
| 63 | defer cleanup() |
| 64 | |
| 65 | mgr := sessions.NewManager(10 * time.Minute) |
| 66 | origGlobal := swapGlobalManager(mgr) |
| 67 | |
| 68 | b := newTestBridgeWithRPC(t, rpcClient) |
| 69 | defer cancelAndRestore(b, origGlobal) |
| 70 | |
| 71 | sess := mgr.Touch("test-key", "claude-code/1.0.33 (Linux 6.1.0; x86_64)", "claude", "") |
| 72 | b.onNewSession(sess) |
| 73 | |
| 74 | // Wait briefly for registration RPC to complete. |
| 75 | time.Sleep(200 * time.Millisecond) |
| 76 | |
| 77 | regs := srv.getRegisteredSessions() |
| 78 | if len(regs) == 0 { |
| 79 | t.Fatal("expected at least 1 registered session") |
| 80 | } |
| 81 | |
| 82 | reg := regs[0] |
| 83 | sysinfo := reg.RegisterData.Sysinfo |
| 84 | if sysinfo == nil || sysinfo.Os == nil { |
| 85 | t.Fatal("expected non-nil SysInfo.Os") |
| 86 | } |
| 87 | |
| 88 | // Hostname should be the real machine hostname, not the agent name. |
| 89 | expectedHostname, _ := os.Hostname() |
| 90 | if expectedHostname == "" { |
| 91 | expectedHostname = "unknown" |
| 92 | } |
| 93 | if sysinfo.Os.Hostname != expectedHostname { |
| 94 | t.Errorf("expected Hostname=%q (real hostname), got %q", expectedHostname, sysinfo.Os.Hostname) |
| 95 | } |
| 96 | |
| 97 | // Username should be agent_name/version, not an API key hash. |
| 98 | if sysinfo.Os.Username != "claude-code/1.0.33" { |
| 99 | t.Errorf("expected Username=%q, got %q", "claude-code/1.0.33", sysinfo.Os.Username) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // =================================================================== |
| 104 | // Test 3: waitForSession should respond quickly (not poll every 1s) |
nothing calls this directly
no test coverage detected