1 defmodule Pleroma.Web.WebsubTest do
3 alias Pleroma.Web.Websub
6 test "a verification of a request that is accepted" do
7 sub = insert(:websub_subscription)
10 getter = fn (_path, _headers, options) ->
12 "hub.challenge": challenge,
13 "hub.lease_seconds": seconds,
15 "hub.mode": "subscribe"
16 } = Keyword.get(options, :params)
18 assert String.to_integer(seconds) > 0
20 {:ok, %HTTPoison.Response{
26 {:ok, sub} = Websub.verify(sub, getter)
27 assert sub.state == "active"
30 test "a verification of a request that doesn't return 200" do
31 sub = insert(:websub_subscription)
34 getter = fn (_path, _headers, _options) ->
35 {:ok, %HTTPoison.Response{
41 {:error, sub} = Websub.verify(sub, getter)
42 assert sub.state == "rejected"