X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fcaptcha_test.exs;h=393c8219e54050b937b138b0bf87029a61539a30;hb=4f004ab92e6d824140e1f87155c3f91a6eedcb09;hp=7ca9a460701287cc1df15381d4b1838b07100d5c;hpb=4258dd8633407587ca1f3dfe275afa6a91be9197;p=akkoma
diff --git a/test/captcha_test.exs b/test/captcha_test.exs
index 7ca9a4607..393c8219e 100644
--- a/test/captcha_test.exs
+++ b/test/captcha_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.CaptchaTest do
@@ -8,6 +8,7 @@ defmodule Pleroma.CaptchaTest do
import Tesla.Mock
alias Pleroma.Captcha.Kocaptcha
+ alias Pleroma.Captcha.Native
@ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}]
@@ -43,4 +44,21 @@ defmodule Pleroma.CaptchaTest do
) == :ok
end
end
+
+ describe "Native" do
+ test "new and validate" do
+ new = Native.new()
+
+ assert %{
+ answer_data: answer,
+ token: token,
+ type: :native,
+ url: "data:image/png;base64," <> _
+ } = new
+
+ assert is_binary(answer)
+ assert :ok = Native.validate(token, answer, answer)
+ assert {:error, "Invalid CAPTCHA"} == Native.validate(token, answer, answer <> "foobar")
+ end
+ end
end