Merge branch 'develop' into proxy-error
This commit is contained in:
commit
31a59d6f23
15 changed files with 262 additions and 87 deletions
|
|
@ -217,5 +217,36 @@ defmodule Pleroma.UserSearchTest do
|
|||
refute Enum.member?(account_ids, blocked_user2.id)
|
||||
assert length(account_ids) == 3
|
||||
end
|
||||
|
||||
test "local user has the same search_rank as for users with the same nickname, but another domain" do
|
||||
user = insert(:user)
|
||||
insert(:user, nickname: "lain@mastodon.social")
|
||||
insert(:user, nickname: "lain")
|
||||
insert(:user, nickname: "lain@pleroma.social")
|
||||
|
||||
assert User.search("lain@localhost", resolve: true, for_user: user)
|
||||
|> Enum.each(fn u -> u.search_rank == 0.5 end)
|
||||
end
|
||||
|
||||
test "localhost is the part of the domain" do
|
||||
user = insert(:user)
|
||||
insert(:user, nickname: "another@somedomain")
|
||||
insert(:user, nickname: "lain")
|
||||
insert(:user, nickname: "lain@examplelocalhost")
|
||||
|
||||
result = User.search("lain@examplelocalhost", resolve: true, for_user: user)
|
||||
assert Enum.each(result, fn u -> u.search_rank == 0.5 end)
|
||||
assert length(result) == 2
|
||||
end
|
||||
|
||||
test "local user search with users" do
|
||||
user = insert(:user)
|
||||
local_user = insert(:user, nickname: "lain")
|
||||
insert(:user, nickname: "another@localhost.com")
|
||||
insert(:user, nickname: "localhost@localhost.com")
|
||||
|
||||
[result] = User.search("lain@localhost", resolve: true, for_user: user)
|
||||
assert Map.put(result, :search_rank, nil) |> Map.put(:search_type, nil) == local_user
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.OStatus
|
||||
alias Pleroma.Web.Websub.WebsubClientSubscription
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
import ExUnit.CaptureLog
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
@ -46,12 +47,10 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
data["object"]
|
||||
|> Map.put("inReplyTo", "https://shitposter.club/notice/2827873")
|
||||
|
||||
data =
|
||||
data
|
||||
|> Map.put("object", object)
|
||||
|
||||
data = Map.put(data, "object", object)
|
||||
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
|
||||
returned_object = Object.normalize(returned_activity.data["object"])
|
||||
|
||||
returned_object = Object.normalize(returned_activity.data["object"], false)
|
||||
|
||||
assert activity =
|
||||
Activity.get_create_by_object_ap_id(
|
||||
|
|
@ -61,6 +60,32 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
||||
end
|
||||
|
||||
test "it does not fetch replied-to activities beyond max_replies_depth" do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|> Poison.decode!()
|
||||
|
||||
object =
|
||||
data["object"]
|
||||
|> Map.put("inReplyTo", "https://shitposter.club/notice/2827873")
|
||||
|
||||
data = Map.put(data, "object", object)
|
||||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
allowed_incoming_reply_depth?: fn _ -> false end do
|
||||
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
returned_object = Object.normalize(returned_activity.data["object"], false)
|
||||
|
||||
refute Activity.get_create_by_object_ap_id(
|
||||
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||
)
|
||||
|
||||
assert returned_object.data["inReplyToAtomUri"] ==
|
||||
"https://shitposter.club/notice/2827873"
|
||||
end
|
||||
end
|
||||
|
||||
test "it does not crash if the object in inReplyTo can't be fetched" do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|
|
|
|||
|
|
@ -444,4 +444,39 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
assert Enum.at(result[:options], 2)[:votes_count] == 1
|
||||
end
|
||||
end
|
||||
|
||||
test "embeds a relationship in the account" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "drink more water"
|
||||
})
|
||||
|
||||
result = StatusView.render("status.json", %{activity: activity, for: other_user})
|
||||
|
||||
assert result[:account][:pleroma][:relationship] ==
|
||||
AccountView.render("relationship.json", %{user: other_user, target: user})
|
||||
end
|
||||
|
||||
test "embeds a relationship in the account in reposts" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "˙˙ɐʎns"
|
||||
})
|
||||
|
||||
{:ok, activity, _object} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
result = StatusView.render("status.json", %{activity: activity, for: user})
|
||||
|
||||
assert result[:account][:pleroma][:relationship] ==
|
||||
AccountView.render("relationship.json", %{user: user, target: other_user})
|
||||
|
||||
assert result[:reblog][:account][:pleroma][:relationship] ==
|
||||
AccountView.render("relationship.json", %{user: user, target: user})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
alias Pleroma.User
|
||||
alias Pleroma.Web.OStatus
|
||||
alias Pleroma.Web.XML
|
||||
import Pleroma.Factory
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
@ -266,10 +268,13 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert favorited_activity.local
|
||||
end
|
||||
|
||||
test "handle incoming replies" do
|
||||
test_with_mock "handle incoming replies, fetching replied-to activities if we don't have them",
|
||||
OStatus,
|
||||
[:passthrough],
|
||||
[] do
|
||||
incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
object = Object.normalize(activity.data["object"])
|
||||
object = Object.normalize(activity.data["object"], false)
|
||||
|
||||
assert activity.data["type"] == "Create"
|
||||
assert object.data["type"] == "Note"
|
||||
|
|
@ -282,6 +287,23 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert object.data["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
|
||||
|
||||
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
||||
|
||||
assert called(OStatus.fetch_activity_from_url(object.data["inReplyTo"], :_))
|
||||
end
|
||||
|
||||
test_with_mock "handle incoming replies, not fetching replied-to activities beyond max_replies_depth",
|
||||
OStatus,
|
||||
[:passthrough],
|
||||
[] do
|
||||
incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
|
||||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
allowed_incoming_reply_depth?: fn _ -> false end do
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
object = Object.normalize(activity.data["object"], false)
|
||||
|
||||
refute called(OStatus.fetch_activity_from_url(object.data["inReplyTo"], :_))
|
||||
end
|
||||
end
|
||||
|
||||
test "handle incoming follows" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue