Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mftoure committed Dec 19, 2024
1 parent 7485988 commit b50b544
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pkg/security/tests/connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ func TestConnectEvent(t *testing.T) {
}

t.Run("connect-af-inet-any-tcp-success", func(t *testing.T) {

done := make(chan error)
defer close(done)
go func() {
bindAndAcceptConnection("tcp", ":4242", done)
}()
Expand All @@ -60,7 +58,9 @@ func TestConnectEvent(t *testing.T) {
if err := runSyscallTesterFunc(context.Background(), t, syscallTester, "connect", "AF_INET", "any", "tcp"); err != nil {
return err
}
return <-done
err := <-done
close(done)
return err
}, func(event *model.Event, _ *rules.Rule) {
assert.Equal(t, "connect", event.GetType(), "wrong event type")
assert.Equal(t, uint16(unix.AF_INET), event.Connect.AddrFamily, "wrong address family")
Expand All @@ -75,7 +75,6 @@ func TestConnectEvent(t *testing.T) {
t.Run("connect-af-inet-any-udp-success", func(t *testing.T) {

done := make(chan error)
defer close(done)
go func() {
bindAndAcceptConnection("udp", ":4242", done)
}()
Expand All @@ -84,7 +83,9 @@ func TestConnectEvent(t *testing.T) {
if err := runSyscallTesterFunc(context.Background(), t, syscallTester, "connect", "AF_INET", "any", "udp"); err != nil {
return err
}
return <-done
err := <-done
close(done)
return err
}, func(event *model.Event, _ *rules.Rule) {
assert.Equal(t, "connect", event.GetType(), "wrong event type")
assert.Equal(t, uint16(unix.AF_INET), event.Connect.AddrFamily, "wrong address family")
Expand All @@ -102,7 +103,6 @@ func TestConnectEvent(t *testing.T) {
}

done := make(chan error)
defer close(done)
go func() {
bindAndAcceptConnection("tcp", ":4242", done)
}()
Expand All @@ -111,7 +111,9 @@ func TestConnectEvent(t *testing.T) {
if err := runSyscallTesterFunc(context.Background(), t, syscallTester, "connect", "AF_INET6", "any", "tcp"); err != nil {
return err
}
return <-done
err := <-done
close(done)
return err
}, func(event *model.Event, _ *rules.Rule) {
assert.Equal(t, "connect", event.GetType(), "wrong event type")
assert.Equal(t, uint16(unix.AF_INET6), event.Connect.AddrFamily, "wrong address family")
Expand All @@ -129,7 +131,6 @@ func TestConnectEvent(t *testing.T) {
}

done := make(chan error)
defer close(done)
go func() {
bindAndAcceptConnection("udp", ":4242", done)
}()
Expand All @@ -138,7 +139,9 @@ func TestConnectEvent(t *testing.T) {
if err := runSyscallTesterFunc(context.Background(), t, syscallTester, "connect", "AF_INET6", "any", "udp"); err != nil {
return err
}
return <-done
err := <-done
close(done)
return err
}, func(event *model.Event, _ *rules.Rule) {
assert.Equal(t, "connect", event.GetType(), "wrong event type")
assert.Equal(t, uint16(unix.AF_INET6), event.Connect.AddrFamily, "wrong address family")
Expand Down

0 comments on commit b50b544

Please sign in to comment.