Skip to content

Commit

Permalink
Rework entry leader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwolf committed Jan 18, 2024
1 parent 910aba2 commit 0cbb970
Show file tree
Hide file tree
Showing 2 changed files with 886 additions and 995 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,97 +18,13 @@ import (
var logger = logp.NewLogger("processdb")
var reader = procfs.NewMockReader()

Check failure on line 19 in x-pack/auditbeat/processors/add_session_metadata/processdb/db_test.go

View workflow job for this annotation

GitHub Actions / lint (linux)

var `reader` is unused (unused)

// glue function to fit the return type required by these tests
func newDBIntf(reader procfs.Reader) *DB {
ret := NewDB(reader, *logger)
_ = ret.ScrapeProcfs()
return ret
}


func TestGetTtyType(t *testing.T) {
assert.Equal(t, TtyConsole, getTtyType(4, 0))
assert.Equal(t, Pts, getTtyType(136, 0))
assert.Equal(t, Tty, getTtyType(4, 64))
assert.Equal(t, TtyUnknown, getTtyType(1000, 1000))
}

func TestSingleProcessSessionLeaderEntryTypeTerminal(t *testing.T) {
testSingleProcessSessionLeaderEntryTypeTerminal(newDBIntf)(t)
}

func TestSingleProcessSessionLeaderLoginProcess(t *testing.T) {
testSingleProcessSessionLeaderLoginProcess(newDBIntf)(t)
}

func TestSingleProcessSessionLeaderChildOfInit(t *testing.T) {
testSingleProcessSessionLeaderChildOfInit(newDBIntf)(t)
}

func TestSingleProcessSessionLeaderChildOfSsmSessionWorker(t *testing.T) {
testSingleProcessSessionLeaderChildOfSsmSessionWorker(newDBIntf)(t)
}

func TestSingleProcessSessionLeaderChildOfSshd(t *testing.T) {
testSingleProcessSessionLeaderChildOfSshd(newDBIntf)(t)
}

func TestSingleProcessSessionLeaderChildOfContainerdShim(t *testing.T) {
testSingleProcessSessionLeaderChildOfContainerdShim(newDBIntf)(t)
}

func TestSingleProcessSessionLeaderOfRunc(t *testing.T) {
testSingleProcessSessionLeaderChildOfRunc(newDBIntf)(t)
}

func TestSingleProcessEmptyProcess(t *testing.T) {
testSingleProcessEmptyProcess(newDBIntf)(t)
}

func TestSingleProcessOverwriteOldEntryLeader(t *testing.T) {
testSingleProcessOverwriteOldEntryLeader(newDBIntf)(t)
}

func TestInitSshdBashLs(t *testing.T) {
testInitSshdBashLs(newDBIntf)(t)
}

func TestInitSshdSshdBashLs(t *testing.T) {
testInitSshdSshdBashLs(newDBIntf)(t)
}

func TestInitSshdSshdSshdBashLs(t *testing.T) {
testInitSshdSshdSshdBashLs(newDBIntf)(t)
}

func TestInitContainerdContainerdShim(t *testing.T) {
testInitContainerdContainerdShim(newDBIntf)(t)
}

func TestInitContainerdShimBashContainerdShimIsReparentedToInit(t *testing.T) {
testInitContainerdShimBashContainerdShimIsReparentedToInit(newDBIntf)(t)
}

func TestInitContainerdShimPauseContainerdShimIsReparentedToInit(t *testing.T) {
testInitContainerdShimPauseContainerdShimIsReparentedToInit(newDBIntf)(t)
}

func TestInitSshdBashLsAndGrepGrepOnlyHasGroupLeader(t *testing.T) {
testInitSshdBashLsAndGrepGrepOnlyHasGroupLeader(newDBIntf)(t)
}

func TestInitSshdBashLsAndGrepGrepOnlyHasSessionLeader(t *testing.T) {
testInitSshdBashLsAndGrepGrepOnlyHasSessionLeader(newDBIntf)(t)
}

func TestGrepInIsolation(t *testing.T) {
testGrepInIsolation(newDBIntf)(t)
}

func TestKernelThreads(t *testing.T) {
testKernelThreads(newDBIntf)(t)
}

func TestCapsFromU64ToECS(t *testing.T) {
expected := []string{"CAP_CHOWN"}
assert.Equal(t, expected, ecsCapsFromU64(uint64(1<<unix.CAP_CHOWN)))
Expand Down
Loading

0 comments on commit 0cbb970

Please sign in to comment.