| 1304 | } |
| 1305 | |
| 1306 | func assertConnLogContains(t *testing.T, rr *httptest.ResponseRecorder, r *http.Request, connLogger *connectionlog.FakeConnectionLogger, workspace codersdk.Workspace, agentName string, slugOrPort string, typ database.ConnectionType, userID uuid.UUID) { |
| 1307 | t.Helper() |
| 1308 | |
| 1309 | resp := rr.Result() |
| 1310 | defer resp.Body.Close() |
| 1311 | |
| 1312 | require.True(t, connLogger.Contains(t, database.UpsertConnectionLogParams{ |
| 1313 | OrganizationID: workspace.OrganizationID, |
| 1314 | WorkspaceOwnerID: workspace.OwnerID, |
| 1315 | WorkspaceID: workspace.ID, |
| 1316 | WorkspaceName: workspace.Name, |
| 1317 | AgentName: agentName, |
| 1318 | Type: typ, |
| 1319 | IP: database.ParseIP(r.RemoteAddr), |
| 1320 | UserAgent: sql.NullString{Valid: r.UserAgent() != "", String: r.UserAgent()}, |
| 1321 | Code: sql.NullInt32{ |
| 1322 | Int32: int32(resp.StatusCode), // nolint:gosec |
| 1323 | Valid: true, |
| 1324 | }, |
| 1325 | UserID: uuid.NullUUID{ |
| 1326 | UUID: userID, |
| 1327 | Valid: true, |
| 1328 | }, |
| 1329 | SlugOrPort: sql.NullString{Valid: slugOrPort != "", String: slugOrPort}, |
| 1330 | })) |
| 1331 | } |