mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
refractor(aa): move some test resource to the testdata dir.
This commit is contained in:
parent
89abbae6bd
commit
4282fb336e
@ -5,9 +5,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
testdata = "../../tests/testdata/logs"
|
||||||
|
)
|
||||||
|
|
||||||
func Test_app(t *testing.T) {
|
func Test_app(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -20,7 +25,7 @@ func Test_app(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test audit.log",
|
name: "Test audit.log",
|
||||||
logger: "auditd",
|
logger: "auditd",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
profile: "",
|
profile: "",
|
||||||
rules: false,
|
rules: false,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@ -28,7 +33,7 @@ func Test_app(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test audit.log to rules",
|
name: "Test audit.log to rules",
|
||||||
logger: "auditd",
|
logger: "auditd",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
profile: "",
|
profile: "",
|
||||||
rules: true,
|
rules: true,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@ -36,7 +41,7 @@ func Test_app(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test Dbus Session",
|
name: "Test Dbus Session",
|
||||||
logger: "systemd",
|
logger: "systemd",
|
||||||
path: "../../tests/systemd.log",
|
path: filepath.Join(testdata, "systemd.log"),
|
||||||
profile: "",
|
profile: "",
|
||||||
rules: false,
|
rules: false,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@ -44,7 +49,7 @@ func Test_app(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "No logfile",
|
name: "No logfile",
|
||||||
logger: "auditd",
|
logger: "auditd",
|
||||||
path: "../../tests/log",
|
path: filepath.Join(testdata, "log"),
|
||||||
profile: "",
|
profile: "",
|
||||||
rules: false,
|
rules: false,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
@ -52,7 +57,7 @@ func Test_app(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Logger not supported",
|
name: "Logger not supported",
|
||||||
logger: "raw",
|
logger: "raw",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
profile: "",
|
profile: "",
|
||||||
rules: false,
|
rules: false,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
@ -20,7 +20,7 @@ func chdirGitRoot() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
root := string(out)[0 : len(out)-1]
|
root := string(out[0 : len(out)-1])
|
||||||
if err := os.Chdir(root); err != nil {
|
if err := os.Chdir(root); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testData = paths.New("../../").Join("tests")
|
testData = paths.New("../../tests/testdata/")
|
||||||
intData = paths.New("../../").Join("apparmor.d")
|
intData = paths.New("../../apparmor.d")
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAppArmorProfileFile_String(t *testing.T) {
|
func TestAppArmorProfileFile_String(t *testing.T) {
|
||||||
|
@ -5,10 +5,15 @@
|
|||||||
package logs
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
testdata = "../../tests/testdata/logs"
|
||||||
|
)
|
||||||
|
|
||||||
func TestGetJournalctlLogs(t *testing.T) {
|
func TestGetJournalctlLogs(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -19,7 +24,7 @@ func TestGetJournalctlLogs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "gsd-xsettings",
|
name: "gsd-xsettings",
|
||||||
useFile: true,
|
useFile: true,
|
||||||
path: "../../tests/systemd.log",
|
path: filepath.Join(testdata, "systemd.log"),
|
||||||
want: AppArmorLogs{
|
want: AppArmorLogs{
|
||||||
{
|
{
|
||||||
"apparmor": "ALLOWED",
|
"apparmor": "ALLOWED",
|
||||||
@ -60,8 +65,8 @@ func TestSelectLogFile(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Get audit.log",
|
name: "Get audit.log",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
want: "../../tests/audit.log",
|
want: filepath.Join(testdata, "audit.log"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Get /var/log/audit/audit.log.1",
|
name: "Get /var/log/audit/audit.log.1",
|
||||||
|
@ -188,7 +188,7 @@ func TestNewApparmorLogs(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "dnsmasq",
|
name: "dnsmasq",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
want: AppArmorLogs{
|
want: AppArmorLogs{
|
||||||
{
|
{
|
||||||
"apparmor": "DENIED",
|
"apparmor": "DENIED",
|
||||||
@ -233,17 +233,17 @@ func TestNewApparmorLogs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "kmod",
|
name: "kmod",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
want: refKmod,
|
want: refKmod,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "man",
|
name: "man",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
want: refMan,
|
want: refMan,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "power-profiles-daemon",
|
name: "power-profiles-daemon",
|
||||||
path: "../../tests/audit.log",
|
path: filepath.Join(testdata, "audit.log"),
|
||||||
want: refPowerProfiles,
|
want: refPowerProfiles,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user