diff --git a/apps/reaper/lib/reaper/data_extract/extract_step.ex b/apps/reaper/lib/reaper/data_extract/extract_step.ex index e2896021d..df8bfc247 100644 --- a/apps/reaper/lib/reaper/data_extract/extract_step.ex +++ b/apps/reaper/lib/reaper/data_extract/extract_step.ex @@ -97,7 +97,7 @@ defmodule Reaper.DataExtract.ExtractStep do {body, headers} end - defp process_body(body, _assigns) when body in ["", nil, %{}], do: "" + defp process_body(body, _assigns) when body in ["", nil, %{}, []], do: "" defp process_body(body, assigns) do body |> UrlBuilder.safe_evaluate_body(assigns) diff --git a/apps/reaper/mix.exs b/apps/reaper/mix.exs index 544b22eeb..e3aa41e61 100644 --- a/apps/reaper/mix.exs +++ b/apps/reaper/mix.exs @@ -4,7 +4,7 @@ defmodule Reaper.MixProject do def project do [ app: :reaper, - version: "2.0.26", + version: "2.0.27", elixir: "~> 1.10", build_path: "../../_build", config_path: "../../config/config.exs", diff --git a/apps/reaper/test/unit/reaper/data_extract/extract_step_test.exs b/apps/reaper/test/unit/reaper/data_extract/extract_step_test.exs index 13d7e5dd1..d4aa2c8a8 100644 --- a/apps/reaper/test/unit/reaper/data_extract/extract_step_test.exs +++ b/apps/reaper/test/unit/reaper/data_extract/extract_step_test.exs @@ -263,6 +263,39 @@ defmodule Reaper.DataExtract.ExtractStepTest do assert assigns == %{key: "super secret two", token: "auth_token2"} end + test "Can use empty list for body", %{bypass: bypass, ingestion: ingestion} do + Bypass.stub(bypass, "POST", "/", fn conn -> + {:ok, body, conn} = Plug.Conn.read_body(conn) + + case body do + "" -> Plug.Conn.resp(conn, 200, %{sub: %{path: "auth_token2"}} |> Jason.encode!()) + _ -> Plug.Conn.resp(conn, 403, "No dice") + end + end) + + steps = [ + %{ + type: "auth", + context: %{ + path: ["sub", "path"], + destination: "token", + url: "http://localhost:#{bypass.port}", + encodeMethod: "json", + body: [], + headers: %{}, + cacheTtl: nil + }, + assigns: %{ + key: "super secret two" + } + } + ] + + assigns = ExtractStep.execute_extract_steps(ingestion, steps) + + assert assigns == %{key: "super secret two", token: "auth_token2"} + end + test "Can use assigns block for headers", %{bypass: bypass, ingestion: ingestion} do Bypass.stub(bypass, "POST", "/headers", fn conn -> if Enum.any?(conn.req_headers, fn header -> header == {"header", "super secret"} end) do