diff --git a/internal/prober/multihttp/script.go b/internal/prober/multihttp/script.go index 4a62b70f..f891ebdc 100644 --- a/internal/prober/multihttp/script.go +++ b/internal/prober/multihttp/script.go @@ -3,7 +3,6 @@ package multihttp import ( "bytes" "embed" - "encoding/base64" "fmt" "regexp" "strings" @@ -96,11 +95,8 @@ func buildBody(body *sm.HttpRequestBody) string { default: var buf strings.Builder - - buf.WriteString(`encoding.b64decode("`) - buf.WriteString(base64.RawStdEncoding.EncodeToString(body.Payload)) - buf.WriteString(`", 'rawstd', "b")`) - + bodyString := string(body.Payload) + buf.WriteString(performVariableExpansion(bodyString)) return buf.String() } } diff --git a/internal/prober/multihttp/script_test.go b/internal/prober/multihttp/script_test.go index cd8944f5..3f423cf4 100644 --- a/internal/prober/multihttp/script_test.go +++ b/internal/prober/multihttp/script_test.go @@ -320,9 +320,17 @@ func TestBuildBody(t *testing.T) { input input expected string }{ + "variable in body is interpolated correctly": { + input: input{body: &sm.HttpRequestBody{Payload: []byte("test ${testVar} works")}}, + expected: "'test '+vars['testVar']+' works'", // 'test '+vars['testVar']+' works' + }, + "body starting with variable is interpolated correctly": { + input: input{body: &sm.HttpRequestBody{Payload: []byte("${testVar} test")}}, + expected: "vars['testVar']+' test'", // vars['testVar']+' test' + }, "not empty": { input: input{body: &sm.HttpRequestBody{Payload: []byte("test")}}, - expected: `encoding.b64decode("dGVzdA", 'rawstd', "b")`, + expected: "'test'", // 'test' }, "nil": { input: input{body: nil},