From 95c322d62ac17af77959fa82161d561d7b9953cb Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sat, 30 Sep 2023 13:55:56 +0100 Subject: [PATCH] test: add more profile sorting test. --- pkg/aa/data_test.go | 7 +++++++ pkg/aa/profile_test.go | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/aa/data_test.go b/pkg/aa/data_test.go index 8e6ad857a..1ed851949 100644 --- a/pkg/aa/data_test.go +++ b/pkg/aa/data_test.go @@ -5,6 +5,13 @@ package aa var ( + // Include + includeLocal1 = &Include{ + IfExists: true, + IsMagic: true, + Path: "local/foo", + } + // Capability capability1Log = map[string]string{ "apparmor": "ALLOWED", diff --git a/pkg/aa/profile_test.go b/pkg/aa/profile_test.go index 60e652a27..de3469a34 100644 --- a/pkg/aa/profile_test.go +++ b/pkg/aa/profile_test.go @@ -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, + }, }, }, },