MCPcopy
hub / github.com/evilsocket/opensnitch / TestNewOperatorRegexp

Function TestNewOperatorRegexp

daemon/rule/operator_test.go:261–279  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

259}
260
261func TestNewOperatorRegexp(t *testing.T) {
262 t.Log("Test NewOperator() regexp")
263 var dummyList []Operator
264
265 opRE, err := NewOperator(Regexp, false, OpProto, "^TCP$", dummyList)
266 if err != nil {
267 t.Error("NewOperator regexp.err should be nil: ", err)
268 t.Fail()
269 }
270 if err = opRE.Compile(); err != nil {
271 t.Fail()
272 }
273 if opRE.Match(conn, false) == false {
274 t.Error("Test NewOperator() regexp doesn't match")
275 t.Fail()
276 }
277
278 restoreConnection()
279}
280
281func TestNewOperatorInvalidRegexp(t *testing.T) {
282 t.Log("Test NewOperator() invalid regexp")

Callers

nothing calls this directly

Calls 5

CompileMethod · 0.95
MatchMethod · 0.95
restoreConnectionFunction · 0.85
NewOperatorFunction · 0.70
LogMethod · 0.65

Tested by

no test coverage detected