MCPcopy Index your code
hub / github.com/coder/coder / TestConnectionLog

Function TestConnectionLog

coderd/agentapi/connectionlog_test.go:24–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestConnectionLog(t *testing.T) {
25 t.Parallel()
26
27 var (
28 owner = database.User{
29 ID: uuid.New(),
30 Username: "cool-user",
31 }
32 workspace = database.Workspace{
33 ID: uuid.New(),
34 OrganizationID: uuid.New(),
35 OwnerID: owner.ID,
36 Name: "cool-workspace",
37 }
38 agent = database.WorkspaceAgent{
39 ID: uuid.New(),
40 }
41 )
42
43 tests := []struct {
44 name string
45 id uuid.UUID
46 action *agentproto.Connection_Action
47 typ *agentproto.Connection_Type
48 time time.Time
49 ip string
50 status int32
51 reason string
52 }{
53 {
54 name: "SSH Connect",
55 id: uuid.New(),
56 action: agentproto.Connection_CONNECT.Enum(),
57 typ: agentproto.Connection_SSH.Enum(),
58 time: dbtime.Now(),
59 ip: "127.0.0.1",
60 status: 200,
61 },
62 {
63 name: "VS Code Connect",
64 id: uuid.New(),
65 action: agentproto.Connection_CONNECT.Enum(),
66 typ: agentproto.Connection_VSCODE.Enum(),
67 time: dbtime.Now(),
68 ip: "8.8.8.8",
69 },
70 {
71 name: "JetBrains Connect",
72 id: uuid.New(),
73 action: agentproto.Connection_CONNECT.Enum(),
74 typ: agentproto.Connection_JETBRAINS.Enum(),
75 time: dbtime.Now(),
76 // Sometimes, JetBrains clients report as localhost, see
77 // https://github.com/coder/coder/issues/20194
78 ip: "localhost",
79 },
80 {
81 name: "Reconnecting PTY Connect",

Callers

nothing calls this directly

Calls 14

EXPECTMethod · 0.95
ReportConnectionMethod · 0.95
NowFunction · 0.92
NewFakeFunction · 0.92
NewMockStoreFunction · 0.92
ParseIPFunction · 0.92
TimeFunction · 0.92
NewMethod · 0.65
RunMethod · 0.65
GetWorkspaceByAgentIDMethod · 0.65

Tested by

no test coverage detected