584db0a1957fae45852958a0ab619980f8e1074b
[akkoma] / test / web / websub / websub_controller_test.exs
1 defmodule Pleroma.Web.Websub.WebsubControllerTest do
2 use Pleroma.Web.ConnCase
3 import Pleroma.Factory
4 alias Pleroma.Repo
5 alias Pleroma.Web.Websub.WebsubServerSubscription
6
7 test "websub subscription request", %{conn: conn} do
8 user = insert(:user)
9
10 path = Pleroma.Web.OStatus.pubsub_path(user)
11
12 data = %{
13 "hub.callback": "http://example.org/sub",
14 "hub.mode": "subscription",
15 "hub.topic": Pleroma.Web.OStatus.feed_path(user),
16 "hub.secret": "a random secret",
17 "hub.lease_seconds": "100"
18 }
19
20 conn = conn
21 |> post(path, data)
22
23 assert response(conn, 202) == "Accepted"
24 subscription = Repo.one!(WebsubServerSubscription)
25 assert subscription.topic == Pleroma.Web.OStatus.feed_path(user)
26 assert subscription.state == "requested"
27 assert subscription.secret == "a random secret"
28 assert subscription.callback == "http://example.org/sub"
29 assert subscription.valid_until == NaiveDateTime.add(subscription.inserted_at, 100)
30 end
31 end