Add a captcha mock for tests
authorEkaterina Vaartis <vaartis@cock.li>
Sat, 15 Dec 2018 19:38:39 +0000 (22:38 +0300)
committerEkaterina Vaartis <vaartis@cock.li>
Sat, 15 Dec 2018 19:38:39 +0000 (22:38 +0300)
config/test.exs
test/support/captcha_mock.ex [new file with mode: 0644]

index 5c6acfead9b7bf1ed6ba96e0d5b1ef3d3c6a3ec0..f5348bd46436b7bb5b6e56f213659d21d08b276a 100644 (file)
@@ -6,6 +6,11 @@ config :pleroma, Pleroma.Web.Endpoint,
   http: [port: 4001],
   server: false
 
+# Disable captha for tests
+config :pleroma, Pleroma.Captcha,
+  enabled: true,
+  method: Pleroma.Captcha.Mock # A fake captcha service for tests
+
 # Print only warnings and errors during test
 config :logger, level: :warn
 
diff --git a/test/support/captcha_mock.ex b/test/support/captcha_mock.ex
new file mode 100644 (file)
index 0000000..9d79f2e
--- /dev/null
@@ -0,0 +1,10 @@
+defmodule Pleroma.Captcha.Mock do
+  alias Pleroma.Captcha.Service
+  @behaviour Service
+
+  @impl Service
+  def new(), do: %{type: :mock}
+
+  @impl Service
+  def validate(_token, _captcha), do: true
+end