mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
Implement reinject command to send notifications of alerts (#1638)
* implement reinject command to send notifications of alerts using a profile Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
This commit is contained in:
parent
21255b6391
commit
7d0f89df29
4 changed files with 200 additions and 29 deletions
|
@ -14,8 +14,9 @@ import (
|
|||
|
||||
var ctx = context.Background()
|
||||
|
||||
func resetTestTomb(testTomb *tomb.Tomb) {
|
||||
func resetTestTomb(testTomb *tomb.Tomb, pw *PluginWatcher) {
|
||||
testTomb.Kill(nil)
|
||||
<-pw.PluginEvents
|
||||
if err := testTomb.Wait(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -64,8 +65,7 @@ func TestPluginWatcherInterval(t *testing.T) {
|
|||
defer cancel()
|
||||
err := listenChannelWithTimeout(ct, pw.PluginEvents)
|
||||
assert.ErrorContains(t, err, "context deadline exceeded")
|
||||
|
||||
resetTestTomb(&testTomb)
|
||||
resetTestTomb(&testTomb, &pw)
|
||||
testTomb = tomb.Tomb{}
|
||||
pw.Start(&testTomb)
|
||||
|
||||
|
@ -73,7 +73,7 @@ func TestPluginWatcherInterval(t *testing.T) {
|
|||
defer cancel()
|
||||
err = listenChannelWithTimeout(ct, pw.PluginEvents)
|
||||
assert.NilError(t, err)
|
||||
resetTestTomb(&testTomb)
|
||||
resetTestTomb(&testTomb, &pw)
|
||||
// This is to avoid the int complaining
|
||||
}
|
||||
|
||||
|
@ -113,5 +113,5 @@ func TestPluginAlertCountWatcher(t *testing.T) {
|
|||
defer cancel()
|
||||
err = listenChannelWithTimeout(ct, pw.PluginEvents)
|
||||
assert.NilError(t, err)
|
||||
resetTestTomb(&testTomb)
|
||||
resetTestTomb(&testTomb, &pw)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue