feat(aa-log): fallback to syslog if audit.log is not present.

This commit is contained in:
Alexandre Pujol 2023-03-12 16:54:54 +00:00
parent 1042728ca6
commit 5e5b10d5a7
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
2 changed files with 65 additions and 11 deletions

View file

@ -306,6 +306,37 @@ func TestAppArmorLogs_String(t *testing.T) {
}
}
func Test_getLogFile(t *testing.T) {
tests := []struct {
name string
path string
want string
}{
{
name: "Get audit.log",
path: "../../tests/audit.log",
want: "../../tests/audit.log",
},
{
name: "Get /var/log/audit/audit.log.1",
path: "1",
want: "/var/log/audit/audit.log.1",
},
{
name: "Get default log file",
path: "",
want: "/var/log/audit/audit.log",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := getLogFile(tt.path); got != tt.want {
t.Errorf("getLogFile() = %v, want %v", got, tt.want)
}
})
}
}
func Test_app(t *testing.T) {
tests := []struct {
name string