MCPcopy Index your code
hub / github.com/crowdsecurity/crowdsec / TestExtractQueryParamExpr

Function TestExtractQueryParamExpr

pkg/exprhelpers/exprlib_test.go:163–191  ·  view source on GitHub ↗

just to verify that the function is available, real tests are in TestExtractQueryParam

(t *testing.T)

Source from the content-addressed store, hash-verified

161
162// just to verify that the function is available, real tests are in TestExtractQueryParam
163func TestExtractQueryParamExpr(t *testing.T) {
164 err := Init(nil)
165 require.NoError(t, err)
166
167 tests := []struct {
168 name string
169 env map[string]any
170 code string
171 result []string
172 err string
173 }{
174 {
175 name: "ExtractQueryParam() test: basic test",
176 env: map[string]any{
177 "query": "/foo?a=1&b=2",
178 },
179 code: "ExtractQueryParam(query, 'a')",
180 result: []string{"1"},
181 },
182 }
183 for _, test := range tests {
184 program, err := expr.Compile(test.code, GetExprOptions(test.env)...)
185 require.NoError(t, err)
186 output, err := expr.Run(program, test.env)
187 require.NoError(t, err)
188 require.Equal(t, test.result, output)
189 log.Printf("test '%s' : OK", test.name)
190 }
191}
192
193// just to verify that the function is available, real tests are in TestParseQuery
194func TestParseQueryInExpr(t *testing.T) {

Callers

nothing calls this directly

Calls 4

InitFunction · 0.85
GetExprOptionsFunction · 0.85
RunMethod · 0.65
CompileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…