forked from 0xrawsec/whids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysinfo_test.go
48 lines (39 loc) · 912 Bytes
/
sysinfo_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package sysinfo
import (
"reflect"
"testing"
"github.com/0xrawsec/toast"
"github.com/0xrawsec/whids/utils"
)
func TestSystemInfo(t *testing.T) {
t.Parallel()
var h string
var err error
tt := toast.FromT(t)
ei := &EdrInfo{
Version: "major.minor.patch",
Commit: "somerandomcommitid",
}
info := NewSystemInfo()
tt.Assert(edrInfo == nil)
tt.Assert(info.Edr == nil)
// we register edr information
RegisterEdrInfo(ei)
tt.Assert(edrInfo != nil)
tt.Assert(reflect.DeepEqual(edrInfo, ei))
info = NewSystemInfo()
tt.Assert(reflect.DeepEqual(info.Edr, ei))
if h, err = utils.Sha256Interface(info); err != nil {
t.Error(err)
}
t.Log(utils.PrettyJsonOrPanic(info))
t.Logf("Structure hash: %s", h)
for i := 0; i < 1000; i++ {
if n, err := utils.Sha256Interface(info); err != nil {
t.Error(err)
t.FailNow()
} else if n != h {
t.Error("hash function is not stable")
}
}
}