test(aa-log): add & update some variabe parsing test

This commit is contained in:
Alexandre Pujol 2023-09-25 00:13:18 +01:00
parent 73109bb09c
commit 422418e0e2
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC

View File

@ -76,6 +76,15 @@ func TestAppArmorProfile_ParseVariables(t *testing.T) {
}, },
}, },
}, },
{
name: "snapd",
content: `@{lib_dirs} = @{lib}/ /snap/snapd/@{int}@{lib}
@{exec_path} = @{lib_dirs}/snapd/snapd`,
want: []Variable{
{"lib_dirs", []string{"@{lib}/", "/snap/snapd/@{int}@{lib}"}},
{"exec_path", []string{"@{lib_dirs}/snapd/snapd"}},
},
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
@ -132,9 +141,9 @@ func TestAppArmorProfile_ResolveAttachments(t *testing.T) {
{ {
name: "chromium", name: "chromium",
variables: []Variable{ variables: []Variable{
{"chromium_name", []string{"chromium"}}, {"name", []string{"chromium"}},
{"chromium_lib_dirs", []string{"/{usr/,}lib/@{chromium_name}"}}, {"lib_dirs", []string{"/{usr/,}lib/@{name}"}},
{"exec_path", []string{"@{chromium_lib_dirs}/@{chromium_name}"}}, {"exec_path", []string{"@{lib_dirs}/@{name}"}},
}, },
want: []string{ want: []string{
"/{usr/,}lib/chromium/chromium", "/{usr/,}lib/chromium/chromium",
@ -155,9 +164,9 @@ func TestAppArmorProfile_ResolveAttachments(t *testing.T) {
name: "opera", name: "opera",
variables: []Variable{ variables: []Variable{
{"multiarch", []string{"*-linux-gnu*"}}, {"multiarch", []string{"*-linux-gnu*"}},
{"chromium_name", []string{"opera{,-beta,-developer}"}}, {"name", []string{"opera{,-beta,-developer}"}},
{"chromium_lib_dirs", []string{"/{usr/,}lib/@{multiarch}/@{chromium_name}"}}, {"lib_dirs", []string{"/{usr/,}lib/@{multiarch}/@{name}"}},
{"exec_path", []string{"@{chromium_lib_dirs}/@{chromium_name}"}}, {"exec_path", []string{"@{lib_dirs}/@{name}"}},
}, },
want: []string{ want: []string{
"/{usr/,}lib/*-linux-gnu*/opera{,-beta,-developer}/opera{,-beta,-developer}", "/{usr/,}lib/*-linux-gnu*/opera{,-beta,-developer}/opera{,-beta,-developer}",