Rename captcha_test.ex to exs
[akkoma] / test / captcha_test.exs
1 defmodule Pleroma.CaptchaTest do
2 use ExUnit.Case
3
4 import Tesla.Mock
5
6 @ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}]
7
8 describe "Kocaptcha" do
9 setup do
10 ets_name = Pleroma.Captcha.Kocaptcha.Ets
11 ^ets_name = :ets.new(ets_name, @ets_options)
12
13 mock(fn
14 %{method: :get, url: "http://localhost:9093/new"} ->
15 json(%{
16 md5: "63615261b77f5354fb8c4e4986477555",
17 token: "afa1815e14e29355e6c8f6b143a39fa2",
18 url: "/captchas/afa1815e14e29355e6c8f6b143a39fa2.png"
19 })
20 end)
21
22 :ok
23 end
24
25 test "new and validate" do
26 assert Pleroma.Captcha.Kocaptcha.new() == %{
27 type: :kocaptcha,
28 token: "afa1815e14e29355e6c8f6b143a39fa2",
29 url: "http://localhost:9093/captchas/afa1815e14e29355e6c8f6b143a39fa2.png"
30 }
31
32 assert Pleroma.Captcha.Kocaptcha.validate(
33 "afa1815e14e29355e6c8f6b143a39fa2",
34 "7oEy8c"
35 )
36 end
37 end
38 end