diff options
Diffstat (limited to 'lib/recaptcha/http/mock_http_client.ex')
-rw-r--r-- | lib/recaptcha/http/mock_http_client.ex | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/recaptcha/http/mock_http_client.ex b/lib/recaptcha/http/mock_http_client.ex new file mode 100644 index 0000000..2355dd3 --- /dev/null +++ b/lib/recaptcha/http/mock_http_client.ex @@ -0,0 +1,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 |