diff --git a/test/hcaptcha/template_test.exs b/test/hcaptcha/template_test.exs index d36c35c..39ac7f2 100644 --- a/test/hcaptcha/template_test.exs +++ b/test/hcaptcha/template_test.exs @@ -29,7 +29,7 @@ defmodule HcaptchaTemplateTest do test "supplying a hl in options to display/1 overrides it in the script tag" do template_string = Hcaptcha.Template.display(hl: "en") - assert template_string =~ "https://www.google.com/hcaptcha/api.js?hl=en" + assert template_string =~ "https://js.hcaptcha.com/1/api.js?hl=en" end test "supplying a onload in options to display/1 adds it to the script tag" do @@ -37,18 +37,18 @@ defmodule HcaptchaTemplateTest do template_string2 = Hcaptcha.Template.display(onload: "onLoad", hl: "en") assert template_string1 =~ - "https://www.google.com/hcaptcha/api.js?onload=onLoad&hl" + "https://js.hcaptcha.com/1/api.js?onload=onLoad&hl" assert template_string2 =~ - "https://www.google.com/hcaptcha/api.js?onload=onLoad&hl=en" + "https://js.hcaptcha.com/1/api.js?onload=onLoad&hl=en" end test "supplying a invisible hcaptcha on option size equal invisible" do template_string = Hcaptcha.Template.display(size: "invisible") - assert template_string =~ "ghcaptcha.execute()" + assert template_string =~ "window.hcaptcha.execute()" template_string = Hcaptcha.Template.display(size: "compact") - refute template_string =~ "ghcaptcha.execute()" + refute template_string =~ "window.hcaptcha.execute()" end test "supplying an option to change the callback even if you are using invisible hcaptcha" do diff --git a/test/hcaptcha_test.exs b/test/hcaptcha_test.exs index b6eadb7..c0f97a4 100644 --- a/test/hcaptcha_test.exs +++ b/test/hcaptcha_test.exs @@ -1,21 +1,23 @@ defmodule HcaptchaTest do use ExUnit.Case, async: true - # see https://developers.google.com/hcaptcha/docs/faq#id-like-to-run-automated-tests-with-hcaptcha-v2-what-should-i-do + # see https://docs.hcaptcha.com/#integration-testing-test-keys @hCaptcha_test_secret "0x0000000000000000000000000000000000000000" - test "When the supplied hcaptcha-response is invalid, multiple errors are returned" do + test "When the supplied hcaptcha-response is invalid, errors are returned" do assert {:error, messages} = Hcaptcha.verify("not_valid") - assert messages == [:invalid_input_response, :invalid_input_secret] + assert messages == [:invalid_input_response] end test "When a valid response is supplied, a success response is returned" do assert {:ok, %{challenge_ts: _, hostname: _}} = - Hcaptcha.verify("valid_response", secret: @hCaptcha_test_secret) + Hcaptcha.verify("10000000-aaaa-bbbb-cccc-000000000001", + secret: @hCaptcha_test_secret + ) end - test "When a valid response is supplied, an error response is returned" do - assert {:error, [:"invalid-input-response"]} = + test "When an invalid response is supplied, an error response is returned" do + assert {:error, [:invalid_input_response]} = Hcaptcha.verify("invalid_response", secret: @hCaptcha_test_secret) end