diff options
author | lain <lain@soykaf.club> | 2019-02-01 10:21:17 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-02-01 10:21:17 +0100 |
commit | 01d483f9c76456ed03010f5a0f5e08e118db27a8 (patch) | |
tree | f3d0ca4e15c951d38e44e85befd366f1a8eca0f9 /test/web/websub/websub_controller_test.exs | |
parent | b19b4f85376f6bad33bb37b1624f45dbd502bfda (diff) | |
parent | b3b0855456a92351667a50c8ea77f328bded76ca (diff) | |
download | pleroma-01d483f9c76456ed03010f5a0f5e08e118db27a8.tar.gz pleroma-01d483f9c76456ed03010f5a0f5e08e118db27a8.zip |
Merge remote-tracking branch 'origin/develop' into fix-rich-media-toggle
Diffstat (limited to 'test/web/websub/websub_controller_test.exs')
-rw-r--r-- | test/web/websub/websub_controller_test.exs | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/test/web/websub/websub_controller_test.exs b/test/web/websub/websub_controller_test.exs index 9cbcda063..6492df2a0 100644 --- a/test/web/websub/websub_controller_test.exs +++ b/test/web/websub/websub_controller_test.exs @@ -50,35 +50,37 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do assert_in_delta NaiveDateTime.diff(websub.valid_until, NaiveDateTime.utc_now()), 100, 5 end - test "handles incoming feed updates", %{conn: conn} do - websub = insert(:websub_client_subscription) - doc = "some stuff" - signature = Websub.sign(websub.secret, doc) - - conn = - conn - |> put_req_header("x-hub-signature", "sha1=" <> signature) - |> put_req_header("content-type", "application/atom+xml") - |> post("/push/subscriptions/#{websub.id}", doc) - - assert response(conn, 200) == "OK" - - assert length(Repo.all(Activity)) == 1 - end - - test "rejects incoming feed updates with the wrong signature", %{conn: conn} do - websub = insert(:websub_client_subscription) - doc = "some stuff" - signature = Websub.sign("wrong secret", doc) - - conn = - conn - |> put_req_header("x-hub-signature", "sha1=" <> signature) - |> put_req_header("content-type", "application/atom+xml") - |> post("/push/subscriptions/#{websub.id}", doc) - - assert response(conn, 500) == "Error" - - assert length(Repo.all(Activity)) == 0 + describe "websub_incoming" do + test "handles incoming feed updates", %{conn: conn} do + websub = insert(:websub_client_subscription) + doc = "some stuff" + signature = Websub.sign(websub.secret, doc) + + conn = + conn + |> put_req_header("x-hub-signature", "sha1=" <> signature) + |> put_req_header("content-type", "application/atom+xml") + |> post("/push/subscriptions/#{websub.id}", doc) + + assert response(conn, 200) == "OK" + + assert length(Repo.all(Activity)) == 1 + end + + test "rejects incoming feed updates with the wrong signature", %{conn: conn} do + websub = insert(:websub_client_subscription) + doc = "some stuff" + signature = Websub.sign("wrong secret", doc) + + conn = + conn + |> put_req_header("x-hub-signature", "sha1=" <> signature) + |> put_req_header("content-type", "application/atom+xml") + |> post("/push/subscriptions/#{websub.id}", doc) + + assert response(conn, 500) == "Error" + + assert length(Repo.all(Activity)) == 0 + end end end |