Make captcha (kocaptcha) stateless

Also rename seconds_retained to seconds_valid since that's how it is
now. Put it down from 180 to 20 seconds. The answer data is now
stored in an encrypted text transfered to the client and back, so no
ETS is needed
This commit is contained in:
Ekaterina Vaartis 2018-12-21 00:32:37 +03:00
commit 336e37d98f
8 changed files with 82 additions and 92 deletions

View file

@ -25,16 +25,18 @@ defmodule Pleroma.CaptchaTest do
end
test "new and validate" do
assert Kocaptcha.new() == %{
type: :kocaptcha,
token: "afa1815e14e29355e6c8f6b143a39fa2",
url: "https://captcha.kotobank.ch/captchas/afa1815e14e29355e6c8f6b143a39fa2.png"
}
new = Kocaptcha.new()
assert new[:type] == :kocaptcha
assert new[:token] == "afa1815e14e29355e6c8f6b143a39fa2"
assert new[:url] ==
"https://captcha.kotobank.ch/captchas/afa1815e14e29355e6c8f6b143a39fa2.png"
assert Kocaptcha.validate(
"afa1815e14e29355e6c8f6b143a39fa2",
"7oEy8c"
)
new[:token],
"7oEy8c",
new[:answer_data]
) == :ok
end
end
end