aboutsummaryrefslogtreecommitdiff
path: root/lib/recaptcha/http/mock_http_client.ex
blob: 2355dd33f976dee398effa8041daa4fe4c8d8bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
defmodule Recaptcha.Http.MockClient do
  @moduledoc """
    A mock HTTP client used for testing.
  """

  def request_verification(body, options \\ [])

  def request_verification("response=valid_response&secret=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe" = body, options) do
    send self(), {:request_verification, body, options}
    {:ok, %{"success" => true, "challenge_ts" => "timestamp", "hostname" => "localhost"}}
  end

  # every other match is a pass through to the real client
  def request_verification(body, options) do
    send self(), {:request_verification, body, options}
    Recaptcha.Http.request_verification(body, options)
  end
end