test(aa-log): add some unit tests.
This commit is contained in:
parent
4798b2d04a
commit
68be85b5c2
1 changed files with 73 additions and 1 deletions
|
|
@ -87,6 +87,42 @@ func TestRule_Less(t *testing.T) {
|
||||||
other ApparmorRule
|
other ApparmorRule
|
||||||
want bool
|
want bool
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
name: "include1",
|
||||||
|
rule: include1,
|
||||||
|
other: includeLocal1,
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "include2",
|
||||||
|
rule: include1,
|
||||||
|
other: include2,
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "include3",
|
||||||
|
rule: include1,
|
||||||
|
other: include3,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "rlimit",
|
||||||
|
rule: rlimit1,
|
||||||
|
other: rlimit2,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "rlimit2",
|
||||||
|
rule: rlimit2,
|
||||||
|
other: rlimit2,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "rlimit3",
|
||||||
|
rule: rlimit1,
|
||||||
|
other: rlimit3,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "capability",
|
name: "capability",
|
||||||
rule: capability1,
|
rule: capability1,
|
||||||
|
|
@ -105,6 +141,18 @@ func TestRule_Less(t *testing.T) {
|
||||||
other: mount2,
|
other: mount2,
|
||||||
want: false,
|
want: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "change_profile1",
|
||||||
|
rule: changeprofile1,
|
||||||
|
other: changeprofile2,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "change_profile2",
|
||||||
|
rule: changeprofile1,
|
||||||
|
other: changeprofile3,
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "signal",
|
name: "signal",
|
||||||
rule: signal1,
|
rule: signal1,
|
||||||
|
|
@ -135,6 +183,12 @@ func TestRule_Less(t *testing.T) {
|
||||||
other: dbus1,
|
other: dbus1,
|
||||||
want: false,
|
want: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "dbus2",
|
||||||
|
rule: dbus2,
|
||||||
|
other: dbus3,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "file",
|
name: "file",
|
||||||
rule: file1,
|
rule: file1,
|
||||||
|
|
@ -157,7 +211,7 @@ func TestRule_Less(t *testing.T) {
|
||||||
name: "file/owner",
|
name: "file/owner",
|
||||||
rule: &File{Path: "/usr/share/poppler/cMap/Identity-H", Qualifier: Qualifier{Owner: true}},
|
rule: &File{Path: "/usr/share/poppler/cMap/Identity-H", Qualifier: Qualifier{Owner: true}},
|
||||||
other: &File{Path: "/usr/share/poppler/cMap/Identity-H"},
|
other: &File{Path: "/usr/share/poppler/cMap/Identity-H"},
|
||||||
want: true,
|
want: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "file/access",
|
name: "file/access",
|
||||||
|
|
@ -189,6 +243,18 @@ func TestRule_Equals(t *testing.T) {
|
||||||
other ApparmorRule
|
other ApparmorRule
|
||||||
want bool
|
want bool
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
name: "include1",
|
||||||
|
rule: include1,
|
||||||
|
other: includeLocal1,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "rlimit",
|
||||||
|
rule: rlimit1,
|
||||||
|
other: rlimit1,
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "capability/equal",
|
name: "capability/equal",
|
||||||
rule: capability1,
|
rule: capability1,
|
||||||
|
|
@ -207,6 +273,12 @@ func TestRule_Equals(t *testing.T) {
|
||||||
other: mount1,
|
other: mount1,
|
||||||
want: true,
|
want: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "change_profile",
|
||||||
|
rule: changeprofile1,
|
||||||
|
other: changeprofile2,
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "signal1/equal",
|
name: "signal1/equal",
|
||||||
rule: signal1,
|
rule: signal1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue