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

Function TestCreateAlertChannels

pkg/apiserver/alerts_test.go:204–231  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

202}
203
204func TestCreateAlertChannels(t *testing.T) {
205 ctx := t.Context()
206 apiServer, config := NewAPIServer(t, ctx)
207 apiServer.controller.PluginChannel = make(chan models.ProfileAlert)
208 err := apiServer.InitController()
209 require.NoError(t, err)
210
211 loginResp := LoginToTestAPI(t, ctx, apiServer.router, config)
212 lapi := LAPI{router: apiServer.router, loginResp: loginResp}
213
214 var (
215 pd models.ProfileAlert
216 wg sync.WaitGroup
217 )
218
219 wg.Add(1)
220
221 go func() {
222 pd = <-apiServer.controller.PluginChannel
223
224 wg.Done()
225 }()
226
227 lapi.InsertAlertFromFile(t, ctx, "./tests/alert_ssh-bf.json")
228 wg.Wait()
229 assert.Len(t, pd.Alert.Decisions, 1)
230 apiServer.Close()
231}
232
233func TestAlertListFilters(t *testing.T) {
234 ctx := t.Context()

Callers

nothing calls this directly

Calls 7

InitControllerMethod · 0.95
InsertAlertFromFileMethod · 0.95
CloseMethod · 0.95
NewAPIServerFunction · 0.85
LoginToTestAPIFunction · 0.85
AddMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…