(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func TestNewOperatorSimple(t *testing.T) { |
| 71 | t.Log("Test NewOperator() simple") |
| 72 | var list []Operator |
| 73 | |
| 74 | opSimple, err := NewOperator(Simple, false, OpTrue, "", list) |
| 75 | if err != nil { |
| 76 | t.Error("NewOperator simple.err should be nil: ", err) |
| 77 | t.Fail() |
| 78 | } |
| 79 | if err = opSimple.Compile(); err != nil { |
| 80 | t.Fail() |
| 81 | } |
| 82 | if opSimple.Match(nil, false) == false { |
| 83 | t.Error("Test NewOperator() simple.case-insensitive doesn't match") |
| 84 | t.Fail() |
| 85 | } |
| 86 | |
| 87 | t.Run("Operator Simple proc.id", func(t *testing.T) { |
| 88 | // proc.id not sensitive |
| 89 | opSimple, err = NewOperator(Simple, false, OpProcessID, "12345", list) |
| 90 | if err != nil { |
| 91 | t.Error("NewOperator simple.case-insensitive.proc.id err should be nil: ", err) |
| 92 | t.Fail() |
| 93 | } |
| 94 | if err = opSimple.Compile(); err != nil { |
| 95 | t.Error("NewOperator simple.case-insensitive.proc.id Compile() err:", err) |
| 96 | t.Fail() |
| 97 | } |
| 98 | if opSimple.Match(conn, false) == false { |
| 99 | t.Error("Test NewOperator() simple proc.id doesn't match") |
| 100 | t.Fail() |
| 101 | } |
| 102 | }) |
| 103 | |
| 104 | opSimple, err = NewOperator(Simple, false, OpProcessPath, defaultProcPath, list) |
| 105 | t.Run("Operator Simple proc.path case-insensitive", func(t *testing.T) { |
| 106 | // proc path not sensitive |
| 107 | if err != nil { |
| 108 | t.Error("NewOperator simple proc.path err should be nil: ", err) |
| 109 | t.Fail() |
| 110 | } |
| 111 | if err = opSimple.Compile(); err != nil { |
| 112 | t.Error("NewOperator simple.case-insensitive.proc.path Compile() err:", err) |
| 113 | t.Fail() |
| 114 | } |
| 115 | if opSimple.Match(conn, false) == false { |
| 116 | t.Error("Test NewOperator() simple proc.path doesn't match") |
| 117 | t.Fail() |
| 118 | } |
| 119 | }) |
| 120 | |
| 121 | t.Run("Operator Simple proc.path sensitive", func(t *testing.T) { |
| 122 | // proc path sensitive |
| 123 | opSimple.Sensitive = true |
| 124 | conn.Process.Path = "/usr/bin/OpenSnitchd" |
| 125 | if opSimple.Match(conn, false) == true { |
| 126 | t.Error("Test NewOperator() simple proc.path sensitive match") |
| 127 | t.Fail() |
nothing calls this directly
no test coverage detected