tests consistency
[akkoma] / test / support / captcha / mock.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Captcha.Mock do
6 alias Pleroma.Captcha.Service
7 @behaviour Service
8
9 @solution "63615261b77f5354fb8c4e4986477555"
10
11 def solution, do: @solution
12
13 @impl Service
14 def new,
15 do: %{
16 type: :mock,
17 token: "afa1815e14e29355e6c8f6b143a39fa2",
18 answer_data: @solution,
19 url: "https://example.org/captcha.png",
20 seconds_valid: 300
21 }
22
23 @impl Service
24 def validate(_token, captcha, captcha) when not is_nil(captcha), do: :ok
25
26 def validate(_token, captcha, answer),
27 do: {:error, "Invalid CAPTCHA captcha: #{inspect(captcha)} ; answer: #{inspect(answer)}"}
28 end