diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-04-20 17:47:33 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-04-20 17:47:33 +0200 |
commit | 1b9cc721a0d49d786b4864c2b8aceaf49b9ff088 (patch) | |
tree | 679fe5735558078aec07082884587aaf1a20a4a9 /test | |
parent | 5e7ceeba94c179b5ffe98d1bb1115a2e0af196e2 (diff) | |
download | pleroma-1b9cc721a0d49d786b4864c2b8aceaf49b9ff088.tar.gz |
Websub controller beginnings.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/ostatus/feed_representer_test.exs | 2 | ||||
-rw-r--r-- | test/web/websub/websub_controller_test.exs | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/test/web/ostatus/feed_representer_test.exs b/test/web/ostatus/feed_representer_test.exs index dddc63ebf..3d8eaac6e 100644 --- a/test/web/ostatus/feed_representer_test.exs +++ b/test/web/ostatus/feed_representer_test.exs @@ -26,7 +26,7 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do <id>#{OStatus.feed_path(user)}</id> <title>#{user.nickname}'s timeline</title> <updated>#{most_recent_update}</updated> - <link rel="hub" href="#{OStatus.pubsub_path}" /> + <link rel="hub" href="#{OStatus.pubsub_path(user)}" /> <author> #{user_xml} </author> diff --git a/test/web/websub/websub_controller_test.exs b/test/web/websub/websub_controller_test.exs new file mode 100644 index 000000000..4eff598d6 --- /dev/null +++ b/test/web/websub/websub_controller_test.exs @@ -0,0 +1,30 @@ +defmodule Pleroma.Web.Websub.WebsubControllerTest do + use Pleroma.Web.ConnCase + import Pleroma.Factory + alias Pleroma.Repo + alias Pleroma.Web.Websub.WebsubServerSubscription + + test "websub subscription request", %{conn: conn} do + user = insert(:user) + + path = Pleroma.Web.OStatus.pubsub_path(user) + + data = %{ + "hub.callback": "http://example.org/sub", + "hub.mode": "subscription", + "hub.topic": Pleroma.Web.OStatus.feed_path(user), + "hub.secret": "a random secret", + "hub.lease_seconds": 100 + } + + conn = conn + |> post(path, data) + + assert response(conn, 202) == "Accepted" + subscription = Repo.one!(WebsubServerSubscription) + assert subscription.topic == Pleroma.Web.OStatus.feed_path(user) + assert subscription.state == "requested" + assert subscription.secret == "a random secret" + assert subscription.valid_until == NaiveDateTime.add(subscription.inserted_at, 100) + end +end |