Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1111 xml body #1639

Merged
merged 14 commits into from
Mar 30, 2023
2 changes: 1 addition & 1 deletion apps/reaper/lib/reaper/data_extract/extract_step.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion apps/reaper/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions apps/reaper/test/unit/reaper/data_extract/extract_step_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down