Refactor, add beginnings of websub client subscriptions.

This commit is contained in:
Roger Braun 2017-04-26 18:33:10 +02:00
commit c5fa682c31
6 changed files with 93 additions and 7 deletions

View file

@ -58,7 +58,6 @@ defmodule Pleroma.Web.WebsubTest do
"hub.lease_seconds" => "100"
}
{:ok, subscription } = Websub.incoming_subscription_request(user, data)
assert subscription.topic == Pleroma.Web.OStatus.feed_path(user)
assert subscription.state == "requested"
@ -87,4 +86,15 @@ defmodule Pleroma.Web.WebsubTest do
assert length(Repo.all(WebsubServerSubscription)) == 1
assert subscription.id == sub.id
end
test "initiate a subscription for a given user and topic" do
user = insert(:user)
topic = "http://example.org/some-topic.atom"
{:ok, websub} = Websub.subscribe(user, topic)
assert websub.subscribers == [user.ap_id]
assert websub.topic == topic
assert is_binary(websub.secret)
assert websub.state == "accepted"
end
end