summaryrefslogtreecommitdiff
path: root/test/web/ostatus
diff options
context:
space:
mode:
Diffstat (limited to 'test/web/ostatus')
-rw-r--r--test/web/ostatus/incoming_documents/delete_handling_test.exs7
-rw-r--r--test/web/ostatus/ostatus_controller_test.exs88
-rw-r--r--test/web/ostatus/ostatus_test.exs18
3 files changed, 69 insertions, 44 deletions
diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs
index c8fbff6cc..d97cd79f4 100644
--- a/test/web/ostatus/incoming_documents/delete_handling_test.exs
+++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs
@@ -2,9 +2,16 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
use Pleroma.DataCase
import Pleroma.Factory
+ import Tesla.Mock
+
alias Pleroma.{Repo, Activity, Object}
alias Pleroma.Web.OStatus
+ setup do
+ mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
+ :ok
+ end
+
describe "deletions" do
test "it removes the mentioned activity" do
note = insert(:note_activity)
diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs
index 954abf5fe..3145ca9a1 100644
--- a/test/web/ostatus/ostatus_controller_test.exs
+++ b/test/web/ostatus/ostatus_controller_test.exs
@@ -14,49 +14,51 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
:ok
end
- test "decodes a salmon", %{conn: conn} do
- user = insert(:user)
- salmon = File.read!("test/fixtures/salmon.xml")
-
- conn =
- conn
- |> put_req_header("content-type", "application/atom+xml")
- |> post("/users/#{user.nickname}/salmon", salmon)
-
- assert response(conn, 200)
- end
-
- test "decodes a salmon with a changed magic key", %{conn: conn} do
- user = insert(:user)
- salmon = File.read!("test/fixtures/salmon.xml")
-
- conn =
- conn
- |> put_req_header("content-type", "application/atom+xml")
- |> post("/users/#{user.nickname}/salmon", salmon)
-
- assert response(conn, 200)
-
- # Set a wrong magic-key for a user so it has to refetch
- salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
- # Wrong key
- info_cng =
- User.Info.remote_user_creation(salmon_user.info, %{
- magic_key:
- "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwrong1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB"
- })
-
- salmon_user
- |> Ecto.Changeset.change()
- |> Ecto.Changeset.put_embed(:info, info_cng)
- |> Repo.update()
-
- conn =
- build_conn()
- |> put_req_header("content-type", "application/atom+xml")
- |> post("/users/#{user.nickname}/salmon", salmon)
-
- assert response(conn, 200)
+ describe "salmon_incoming" do
+ test "decodes a salmon", %{conn: conn} do
+ user = insert(:user)
+ salmon = File.read!("test/fixtures/salmon.xml")
+
+ conn =
+ conn
+ |> put_req_header("content-type", "application/atom+xml")
+ |> post("/users/#{user.nickname}/salmon", salmon)
+
+ assert response(conn, 200)
+ end
+
+ test "decodes a salmon with a changed magic key", %{conn: conn} do
+ user = insert(:user)
+ salmon = File.read!("test/fixtures/salmon.xml")
+
+ conn =
+ conn
+ |> put_req_header("content-type", "application/atom+xml")
+ |> post("/users/#{user.nickname}/salmon", salmon)
+
+ assert response(conn, 200)
+
+ # Set a wrong magic-key for a user so it has to refetch
+ salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
+ # Wrong key
+ info_cng =
+ User.Info.remote_user_creation(salmon_user.info, %{
+ magic_key:
+ "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwrong1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB"
+ })
+
+ salmon_user
+ |> Ecto.Changeset.change()
+ |> Ecto.Changeset.put_embed(:info, info_cng)
+ |> Repo.update()
+
+ conn =
+ build_conn()
+ |> put_req_header("content-type", "application/atom+xml")
+ |> post("/users/#{user.nickname}/salmon", salmon)
+
+ assert response(conn, 200)
+ end
end
test "gets a feed", %{conn: conn} do
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index 403cc7095..0c63dd84d 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -6,7 +6,7 @@ defmodule Pleroma.Web.OStatusTest do
use Pleroma.DataCase
alias Pleroma.Web.OStatus
alias Pleroma.Web.XML
- alias Pleroma.{Object, Repo, User, Activity}
+ alias Pleroma.{Object, Repo, User, Activity, Instances}
import Pleroma.Factory
import ExUnit.CaptureLog
@@ -311,6 +311,22 @@ defmodule Pleroma.Web.OStatusTest do
refute User.following?(follower, followed)
end
+ test "it clears `unreachable` federation status of the sender" do
+ incoming_reaction_xml = File.read!("test/fixtures/share-gs.xml")
+ doc = XML.parse_document(incoming_reaction_xml)
+ actor_uri = XML.string_from_xpath("//author/uri[1]", doc)
+ reacted_to_author_uri = XML.string_from_xpath("//author/uri[2]", doc)
+
+ Instances.set_consistently_unreachable(actor_uri)
+ Instances.set_consistently_unreachable(reacted_to_author_uri)
+ refute Instances.reachable?(actor_uri)
+ refute Instances.reachable?(reacted_to_author_uri)
+
+ {:ok, _} = OStatus.handle_incoming(incoming_reaction_xml)
+ assert Instances.reachable?(actor_uri)
+ refute Instances.reachable?(reacted_to_author_uri)
+ end
+
describe "new remote user creation" do
test "returns local users" do
local_user = insert(:user)