Merge branch 'feature/incoming_ostatus' of ssh.gitgud.io:lambadalambda/pleroma into...
[akkoma] / test / web / websub / websub_test.exs
index 334ba03fc28bea529635d8758b07ef7921323e2b..7b77e696b60ce4bada517659d2d263a2b5311343 100644 (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