MCPcopy
hub / github.com/crowdsecurity/crowdsec / GetAlertReaderFromFile

Function GetAlertReaderFromFile

pkg/apiserver/apiserver_test.go:227–244  ·  view source on GitHub ↗
(t *testing.T, path string)

Source from the content-addressed store, hash-verified

225}
226
227func GetAlertReaderFromFile(t *testing.T, path string) *strings.Reader {
228 alertContentBytes, err := os.ReadFile(path)
229 require.NoError(t, err)
230
231 alerts := make([]*models.Alert, 0)
232 err = json.Unmarshal(alertContentBytes, &alerts)
233 require.NoError(t, err)
234
235 for _, alert := range alerts {
236 *alert.StartAt = time.Now().UTC().Format(time.RFC3339)
237 *alert.StopAt = time.Now().UTC().Format(time.RFC3339)
238 }
239
240 alertContent, err := json.Marshal(alerts)
241 require.NoError(t, err)
242
243 return strings.NewReader(string(alertContent))
244}
245
246func readDecisionsGetResp(t *testing.T, resp *httptest.ResponseRecorder) ([]*models.Decision, int) {
247 var response []*models.Decision

Callers 7

InsertAlertFromFileMethod · 0.85
TestSimulatedAlertFunction · 0.85
TestCreateAlertFunction · 0.85
TestAlertListFiltersFunction · 0.85
TestAlertBulkInsertFunction · 0.85
TestCreateAlertErrorsFunction · 0.85

Calls 2

NewReaderMethod · 0.80
FormatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…