mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-02-07 02:35:06 +01:00
tests(aa): improve aa unit tests.
This commit is contained in:
parent
5f64bb4e0c
commit
0f382a4d5d
2 changed files with 17 additions and 4 deletions
|
@ -123,16 +123,22 @@ func TestAppArmorProfileFile_Sort(t *testing.T) {
|
||||||
origin: &AppArmorProfileFile{
|
origin: &AppArmorProfileFile{
|
||||||
Profiles: []*Profile{{
|
Profiles: []*Profile{{
|
||||||
Rules: []Rule{
|
Rules: []Rule{
|
||||||
file2, network1, includeLocal1, dbus2, signal1, ptrace1,
|
file2, network1, userns1, include1, dbus2, signal1,
|
||||||
capability2, file1, dbus1, unix2, signal2, mount2,
|
ptrace1, includeLocal1, rlimit3, capability1, network2,
|
||||||
|
mqueue2, iouring2, dbus1, link2, capability2, file1,
|
||||||
|
unix2, signal2, mount2, all1, umount2, mount1, remount2,
|
||||||
|
pivotroot1, changeprofile2,
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
want: &AppArmorProfileFile{
|
want: &AppArmorProfileFile{
|
||||||
Profiles: []*Profile{{
|
Profiles: []*Profile{{
|
||||||
Rules: []Rule{
|
Rules: []Rule{
|
||||||
capability2, network1, mount2, signal1, signal2, ptrace1,
|
include1, all1, rlimit3, userns1, capability1, capability2,
|
||||||
unix2, dbus2, dbus1, file1, file2, includeLocal1,
|
network2, network1, mount2, mount1, remount2, umount2,
|
||||||
|
pivotroot1, changeprofile2, mqueue2, iouring2, signal2,
|
||||||
|
signal1, ptrace1, unix2, dbus2, dbus1, file1, file2,
|
||||||
|
link2, includeLocal1,
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -232,6 +238,10 @@ func TestAppArmorProfileFile_Integration(t *testing.T) {
|
||||||
tt.f.Sort()
|
tt.f.Sort()
|
||||||
tt.f.MergeRules()
|
tt.f.MergeRules()
|
||||||
tt.f.Format()
|
tt.f.Format()
|
||||||
|
err := tt.f.Validate()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("AppArmorProfile.Validate() = %v", err)
|
||||||
|
}
|
||||||
if got := tt.f.String(); got != tt.want {
|
if got := tt.f.String(); got != tt.want {
|
||||||
t.Errorf("AppArmorProfile = |%v|, want |%v|", got, tt.want)
|
t.Errorf("AppArmorProfile = |%v|, want |%v|", got, tt.want)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ var (
|
||||||
tok = map[Kind]string{
|
tok = map[Kind]string{
|
||||||
COMMENT: "#",
|
COMMENT: "#",
|
||||||
VARIABLE: "@{",
|
VARIABLE: "@{",
|
||||||
|
HAT: "^",
|
||||||
}
|
}
|
||||||
openBlocks = []rune{tokOPENPAREN, tokOPENBRACE, tokOPENBRACKET}
|
openBlocks = []rune{tokOPENPAREN, tokOPENBRACE, tokOPENBRACKET}
|
||||||
closeBlocks = []rune{tokCLOSEPAREN, tokCLOSEBRACE, tokCLOSEBRACKET}
|
closeBlocks = []rune{tokCLOSEPAREN, tokCLOSEBRACE, tokCLOSEBRACKET}
|
||||||
|
@ -222,6 +223,8 @@ done:
|
||||||
case strings.HasPrefix(tmp, PROFILE.Tok()):
|
case strings.HasPrefix(tmp, PROFILE.Tok()):
|
||||||
rawHeader = tmp
|
rawHeader = tmp
|
||||||
break done
|
break done
|
||||||
|
case strings.HasPrefix(tmp, HAT.String()), strings.HasPrefix(tmp, HAT.Tok()):
|
||||||
|
break done
|
||||||
default:
|
default:
|
||||||
rawPreamble = append(rawPreamble, tmp)
|
rawPreamble = append(rawPreamble, tmp)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue