test: add more profile sorting test.

This commit is contained in:
Alexandre Pujol 2023-09-30 13:55:56 +01:00
parent c0bc903101
commit 95c322d62a
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
2 changed files with 16 additions and 7 deletions

View File

@ -5,6 +5,13 @@
package aa
var (
// Include
includeLocal1 = &Include{
IfExists: true,
IsMagic: true,
Path: "local/foo",
}
// Capability
capability1Log = map[string]string{
"apparmor": "ALLOWED",

View File

@ -155,11 +155,7 @@ func TestAppArmorProfile_String(t *testing.T) {
Path: "@{sys}/devices/pci[0-9]*/**/class",
Access: "r",
},
&Include{
IfExists: true,
IsMagic: true,
Path: "local/foo",
},
includeLocal1,
},
},
},
@ -276,12 +272,18 @@ func TestAppArmorProfile_Sort(t *testing.T) {
name: "all",
origin: &AppArmorProfile{
Profile: Profile{
Rules: []ApparmorRule{file2, network1, dbus2, signal1, ptrace1, capability2, file1, dbus1, unix2, signal2, mount2},
Rules: []ApparmorRule{
file2, network1, includeLocal1, dbus2, signal1, ptrace1,
capability2, file1, dbus1, unix2, signal2, mount2,
},
},
},
want: &AppArmorProfile{
Profile: Profile{
Rules: []ApparmorRule{capability2, network1, mount2, signal1, signal2, ptrace1, unix2, dbus2, dbus1, file2, file1},
Rules: []ApparmorRule{
capability2, network1, mount2, signal1, signal2, ptrace1,
unix2, dbus2, dbus1, file1, file2, includeLocal1,
},
},
},
},