33 lines
898 B
Go
33 lines
898 B
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package events
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestRuleCatalogCoversEveryPortedRule(t *testing.T) {
|
|
records := RuleCatalog(DefaultExecRuleEngine())
|
|
if len(records) != 21 {
|
|
t.Fatalf("got %d rules, want 21", len(records))
|
|
}
|
|
sids := make([]int, 0, len(records))
|
|
for _, record := range records {
|
|
sids = append(sids, record["sid"].(int))
|
|
}
|
|
want := []int{
|
|
100001, 100002, 100003, 100004,
|
|
100060, 100061, 100062, 100063, 100064, 100065, 100066,
|
|
100067, 100068, 100069, 100070, 100071, 100072, 100073,
|
|
100076, 100077, 100078,
|
|
}
|
|
if !reflect.DeepEqual(sids, want) {
|
|
t.Fatalf("unexpected catalog SIDs: %#v", sids)
|
|
}
|
|
capability := FindRule(records, 100077)
|
|
conditions := capability["conditions"].(map[string]any)
|
|
if _, ok := conditions["capabilities_any"]; !ok {
|
|
t.Fatalf("capability conditions missing: %#v", capability)
|
|
}
|
|
}
|