| 1 | package filterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.18 testing/" |
| 6 | |
| 7 | "github.com/ffuf/ffuf/v2/pkg/ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/" |
| 8 | ) |
| 9 | |
| 10 | func TestNewRegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TestNewRegexpFilter().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 11 | f, _ := NewRegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/NewRegexpFilter().("s([a-z]+)arch") |
| 12 | statusRepr := f.Reprscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/FilterProvider#Repr.() |
| 13 | if !stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Containsscip-go gomod github.com/golang/go/src go1.18 strings/Contains().(statusRepr, "s([a-z]+)arch") { |
| 14 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("Status filter was expected to have a regexp value") |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | func TestNewRegexpFilterErrorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TestNewRegexpFilterError().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 19 | _, err := NewRegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/NewRegexpFilter().("r((") |
| 20 | if err == nil { |
| 21 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("Was expecting an error from errenous input data") |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | func TestRegexpFilteringscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TestRegexpFiltering().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 26 | f, _ := NewRegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/NewRegexpFilter().("s([a-z]+)arch") |
| 27 | for i, test := range []struct { |
| 28 | input string |
| 29 | output bool |
| 30 | }{ |
| 31 | {"search", true}, |
| 32 | {"text and search", true}, |
| 33 | {"sbarch in beginning", true}, |
| 34 | {"midd scarch le", true}, |
| 35 | {"s1arch", false}, |
| 36 | {"invalid", false}, |
| 37 | } { |
| 38 | inp := make(map[string][]byte) |
| 39 | resp := ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Responsescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#{ |
| 40 | Datascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Data.: []byte(test.input), |
| 41 | Requestscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Request.: &ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Requestscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Request#{ |
| 42 | Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Request#Input.: inp, |
| 43 | }, |
| 44 | } |
| 45 | filterReturn, _ := f.Filterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/FilterProvider#Filter.(&resp) |
| 46 | if filterReturn != test.output { |
| 47 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("Filter test %d: Was expecing filter return value of %t but got %t", i, test.output, filterReturn) |
| 48 | } |
| 49 | } |
| 50 | } |