Merge branch 'develop' into issue/1276
This commit is contained in:
commit
dbcfac11b4
153 changed files with 4880 additions and 1693 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicyTest do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do
|
||||
|
|
@ -110,6 +110,15 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do
|
|||
end
|
||||
|
||||
describe "with unknown actors" do
|
||||
setup do
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: :get, url: "http://invalid.actor"} ->
|
||||
%Tesla.Env{status: 500, body: ""}
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
test "it rejects posts without links" do
|
||||
message =
|
||||
@linkless_message
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrependedTest do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicyTest do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkupTest do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublicTest do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
||||
|
|
|
|||
|
|
@ -89,6 +89,11 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
}
|
||||
)
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: :get, url: "http://mastodon.example.org/eee/99541947525187367"} ->
|
||||
%Tesla.Env{status: 500, body: ""}
|
||||
end)
|
||||
|
||||
assert capture_log(fn ->
|
||||
assert Relay.publish(activity) == {:error, nil}
|
||||
end) =~ "[error] error: nil"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
alias Pleroma.UserInviteToken
|
||||
alias Pleroma.Web.ActivityPub.Relay
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.MastodonAPI.StatusView
|
||||
alias Pleroma.Web.MediaProxy
|
||||
|
||||
setup_all do
|
||||
|
|
@ -1586,208 +1585,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/grouped_reports" do
|
||||
setup do
|
||||
[reporter, target_user] = insert_pair(:user)
|
||||
|
||||
date1 = (DateTime.to_unix(DateTime.utc_now()) + 1000) |> DateTime.from_unix!()
|
||||
date2 = (DateTime.to_unix(DateTime.utc_now()) + 2000) |> DateTime.from_unix!()
|
||||
date3 = (DateTime.to_unix(DateTime.utc_now()) + 3000) |> DateTime.from_unix!()
|
||||
|
||||
first_status =
|
||||
insert(:note_activity, user: target_user, data_attrs: %{"published" => date1})
|
||||
|
||||
second_status =
|
||||
insert(:note_activity, user: target_user, data_attrs: %{"published" => date2})
|
||||
|
||||
third_status =
|
||||
insert(:note_activity, user: target_user, data_attrs: %{"published" => date3})
|
||||
|
||||
{:ok, first_report} =
|
||||
CommonAPI.report(reporter, %{
|
||||
"account_id" => target_user.id,
|
||||
"status_ids" => [first_status.id, second_status.id, third_status.id]
|
||||
})
|
||||
|
||||
{:ok, second_report} =
|
||||
CommonAPI.report(reporter, %{
|
||||
"account_id" => target_user.id,
|
||||
"status_ids" => [first_status.id, second_status.id]
|
||||
})
|
||||
|
||||
{:ok, third_report} =
|
||||
CommonAPI.report(reporter, %{
|
||||
"account_id" => target_user.id,
|
||||
"status_ids" => [first_status.id]
|
||||
})
|
||||
|
||||
%{
|
||||
first_status: Activity.get_by_ap_id_with_object(first_status.data["id"]),
|
||||
second_status: Activity.get_by_ap_id_with_object(second_status.data["id"]),
|
||||
third_status: Activity.get_by_ap_id_with_object(third_status.data["id"]),
|
||||
first_report: first_report,
|
||||
first_status_reports: [first_report, second_report, third_report],
|
||||
second_status_reports: [first_report, second_report],
|
||||
third_status_reports: [first_report],
|
||||
target_user: target_user,
|
||||
reporter: reporter
|
||||
}
|
||||
end
|
||||
|
||||
test "returns reports grouped by status", %{
|
||||
conn: conn,
|
||||
first_status: first_status,
|
||||
second_status: second_status,
|
||||
third_status: third_status,
|
||||
first_status_reports: first_status_reports,
|
||||
second_status_reports: second_status_reports,
|
||||
third_status_reports: third_status_reports,
|
||||
target_user: target_user,
|
||||
reporter: reporter
|
||||
} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert length(response["reports"]) == 3
|
||||
|
||||
first_group = Enum.find(response["reports"], &(&1["status"]["id"] == first_status.id))
|
||||
|
||||
second_group = Enum.find(response["reports"], &(&1["status"]["id"] == second_status.id))
|
||||
|
||||
third_group = Enum.find(response["reports"], &(&1["status"]["id"] == third_status.id))
|
||||
|
||||
assert length(first_group["reports"]) == 3
|
||||
assert length(second_group["reports"]) == 2
|
||||
assert length(third_group["reports"]) == 1
|
||||
|
||||
assert first_group["date"] ==
|
||||
Enum.max_by(first_status_reports, fn act ->
|
||||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert first_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: first_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
|
||||
assert(first_group["account"]["id"] == target_user.id)
|
||||
|
||||
assert length(first_group["actors"]) == 1
|
||||
assert hd(first_group["actors"])["id"] == reporter.id
|
||||
|
||||
assert Enum.map(first_group["reports"], & &1["id"]) --
|
||||
Enum.map(first_status_reports, & &1.id) == []
|
||||
|
||||
assert second_group["date"] ==
|
||||
Enum.max_by(second_status_reports, fn act ->
|
||||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert second_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: second_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
|
||||
assert second_group["account"]["id"] == target_user.id
|
||||
|
||||
assert length(second_group["actors"]) == 1
|
||||
assert hd(second_group["actors"])["id"] == reporter.id
|
||||
|
||||
assert Enum.map(second_group["reports"], & &1["id"]) --
|
||||
Enum.map(second_status_reports, & &1.id) == []
|
||||
|
||||
assert third_group["date"] ==
|
||||
Enum.max_by(third_status_reports, fn act ->
|
||||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert third_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: third_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
|
||||
assert third_group["account"]["id"] == target_user.id
|
||||
|
||||
assert length(third_group["actors"]) == 1
|
||||
assert hd(third_group["actors"])["id"] == reporter.id
|
||||
|
||||
assert Enum.map(third_group["reports"], & &1["id"]) --
|
||||
Enum.map(third_status_reports, & &1.id) == []
|
||||
end
|
||||
|
||||
test "reopened report renders status data", %{
|
||||
conn: conn,
|
||||
first_report: first_report,
|
||||
first_status: first_status
|
||||
} do
|
||||
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
first_group = Enum.find(response["reports"], &(&1["status"]["id"] == first_status.id))
|
||||
|
||||
assert first_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: first_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
test "reopened report does not render status data if status has been deleted", %{
|
||||
conn: conn,
|
||||
first_report: first_report,
|
||||
first_status: first_status,
|
||||
target_user: target_user
|
||||
} do
|
||||
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||
{:ok, _} = CommonAPI.delete(first_status.id, target_user)
|
||||
|
||||
refute Activity.get_by_ap_id(first_status.id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["status"][
|
||||
"deleted"
|
||||
] == true
|
||||
|
||||
assert length(Enum.filter(response["reports"], &(&1["status"]["deleted"] == false))) == 2
|
||||
end
|
||||
|
||||
test "account not empty if status was deleted", %{
|
||||
conn: conn,
|
||||
first_report: first_report,
|
||||
first_status: first_status,
|
||||
target_user: target_user
|
||||
} do
|
||||
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||
{:ok, _} = CommonAPI.delete(first_status.id, target_user)
|
||||
|
||||
refute Activity.get_by_ap_id(first_status.id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["account"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /api/pleroma/admin/statuses/:id" do
|
||||
setup do
|
||||
activity = insert(:note_activity)
|
||||
|
|
@ -2572,9 +2369,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
test "common config example", %{conn: conn} do
|
||||
adapter = Application.get_env(:tesla, :adapter)
|
||||
on_exit(fn -> Application.put_env(:tesla, :adapter, adapter) end)
|
||||
|
||||
conn =
|
||||
post(conn, "/api/pleroma/admin/config", %{
|
||||
configs: [
|
||||
|
|
@ -2587,23 +2381,16 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
%{"tuple" => [":seconds_valid", 60]},
|
||||
%{"tuple" => [":path", ""]},
|
||||
%{"tuple" => [":key1", nil]},
|
||||
%{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]},
|
||||
%{"tuple" => [":regex1", "~r/https:\/\/example.com/"]},
|
||||
%{"tuple" => [":regex2", "~r/https:\/\/example.com/u"]},
|
||||
%{"tuple" => [":regex3", "~r/https:\/\/example.com/i"]},
|
||||
%{"tuple" => [":regex4", "~r/https:\/\/example.com/s"]},
|
||||
%{"tuple" => [":name", "Pleroma"]}
|
||||
]
|
||||
},
|
||||
%{
|
||||
"group" => ":tesla",
|
||||
"key" => ":adapter",
|
||||
"value" => "Tesla.Adapter.Httpc"
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
assert Application.get_env(:tesla, :adapter) == Tesla.Adapter.Httpc
|
||||
assert Config.get([Pleroma.Captcha.NotReal, :name]) == "Pleroma"
|
||||
|
||||
assert json_response(conn, 200) == %{
|
||||
|
|
@ -2617,7 +2404,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
%{"tuple" => [":seconds_valid", 60]},
|
||||
%{"tuple" => [":path", ""]},
|
||||
%{"tuple" => [":key1", nil]},
|
||||
%{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]},
|
||||
%{"tuple" => [":regex1", "~r/https:\\/\\/example.com/"]},
|
||||
%{"tuple" => [":regex2", "~r/https:\\/\\/example.com/u"]},
|
||||
%{"tuple" => [":regex3", "~r/https:\\/\\/example.com/i"]},
|
||||
|
|
@ -2630,19 +2416,12 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
":seconds_valid",
|
||||
":path",
|
||||
":key1",
|
||||
":partial_chain",
|
||||
":regex1",
|
||||
":regex2",
|
||||
":regex3",
|
||||
":regex4",
|
||||
":name"
|
||||
]
|
||||
},
|
||||
%{
|
||||
"group" => ":tesla",
|
||||
"key" => ":adapter",
|
||||
"value" => "Tesla.Adapter.Httpc",
|
||||
"db" => [":adapter"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -472,6 +472,13 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
activity = insert(:note_activity, user: user, note: object)
|
||||
Pleroma.Repo.delete(object)
|
||||
|
||||
obj_url = activity.data["object"]
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: :get, url: ^obj_url} ->
|
||||
%Tesla.Env{status: 404, body: ""}
|
||||
end)
|
||||
|
||||
assert Utils.maybe_notify_mentioned_recipients(["test-test"], activity) == [
|
||||
"test-test"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -452,11 +452,24 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
assert length(json_response(conn, 200)) == 1
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "see move notifications" do
|
||||
old_user = insert(:user)
|
||||
new_user = insert(:user, also_known_as: [old_user.ap_id])
|
||||
%{user: follower, conn: conn} = oauth_access(["read:notifications"])
|
||||
|
||||
old_user_url = old_user.ap_id
|
||||
|
||||
body =
|
||||
File.read!("test/fixtures/users_mock/localhost.json")
|
||||
|> String.replace("{{nickname}}", old_user.nickname)
|
||||
|> Jason.encode!()
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: :get, url: ^old_user_url} ->
|
||||
%Tesla.Env{status: 200, body: body}
|
||||
end)
|
||||
|
||||
User.follow(follower, old_user)
|
||||
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
|
||||
Pleroma.Tests.ObanHelpers.perform_all()
|
||||
|
|
|
|||
|
|
@ -5,13 +5,19 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserRelationship
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.MastodonAPI.AccountView
|
||||
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "Represent a user account" do
|
||||
source_data = %{
|
||||
"tag" => [
|
||||
|
|
@ -164,6 +170,17 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert expected == AccountView.render("show.json", %{user: user})
|
||||
end
|
||||
|
||||
test "Represent a Funkwhale channel" do
|
||||
{:ok, user} =
|
||||
User.get_or_fetch_by_ap_id(
|
||||
"https://channels.tests.funkwhale.audio/federation/actors/compositions"
|
||||
)
|
||||
|
||||
assert represented = AccountView.render("show.json", %{user: user})
|
||||
assert represented.acct == "compositions@channels.tests.funkwhale.audio"
|
||||
assert represented.url == "https://channels.tests.funkwhale.audio/channels/compositions"
|
||||
end
|
||||
|
||||
test "Represent a deactivated user for an admin" do
|
||||
admin = insert(:user, is_admin: true)
|
||||
deactivated_user = insert(:user, deactivated: true)
|
||||
|
|
|
|||
|
|
@ -112,11 +112,24 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
test_notifications_rendering([notification], followed, [])
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "Move notification" do
|
||||
old_user = insert(:user)
|
||||
new_user = insert(:user, also_known_as: [old_user.ap_id])
|
||||
follower = insert(:user)
|
||||
|
||||
old_user_url = old_user.ap_id
|
||||
|
||||
body =
|
||||
File.read!("test/fixtures/users_mock/localhost.json")
|
||||
|> String.replace("{{nickname}}", old_user.nickname)
|
||||
|> Jason.encode!()
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{method: :get, url: ^old_user_url} ->
|
||||
%Tesla.Env{status: 200, body: body}
|
||||
end)
|
||||
|
||||
User.follow(follower, old_user)
|
||||
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
|
||||
Pleroma.Tests.ObanHelpers.perform_all()
|
||||
|
|
|
|||
|
|
@ -94,6 +94,23 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
||||
finger_url =
|
||||
"https://localhost/.well-known/webfinger?resource=acct:#{user.nickname}@localhost"
|
||||
|
||||
Tesla.Mock.mock_global(fn
|
||||
%{method: :get, url: "http://localhost/.well-known/host-meta"} ->
|
||||
%Tesla.Env{status: 404, body: ""}
|
||||
|
||||
%{method: :get, url: "https://localhost/.well-known/host-meta"} ->
|
||||
%Tesla.Env{status: 404, body: ""}
|
||||
|
||||
%{
|
||||
method: :get,
|
||||
url: ^finger_url
|
||||
} ->
|
||||
%Tesla.Env{status: 404, body: ""}
|
||||
end)
|
||||
|
||||
%{account: ms_user} = StatusView.render("show.json", activity: activity)
|
||||
|
||||
assert ms_user.acct == "erroruser@example.com"
|
||||
|
|
@ -431,6 +448,22 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
assert length(represented[:media_attachments]) == 1
|
||||
end
|
||||
|
||||
test "funkwhale audio" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, object} =
|
||||
Pleroma.Object.Fetcher.fetch_object_from_id(
|
||||
"https://channels.tests.funkwhale.audio/federation/music/uploads/42342395-0208-4fee-a38d-259a6dae0871"
|
||||
)
|
||||
|
||||
%Activity{} = activity = Activity.get_create_by_object_ap_id(object.data["id"])
|
||||
|
||||
represented = StatusView.render("show.json", %{for: user, activity: activity})
|
||||
|
||||
assert represented[:id] == to_string(activity.id)
|
||||
assert length(represented[:media_attachments]) == 1
|
||||
end
|
||||
|
||||
test "a Mobilizon event" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
|
|||
25
test/web/metadata/metadata_test.exs
Normal file
25
test/web/metadata/metadata_test.exs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.MetadataTest do
|
||||
use Pleroma.DataCase, async: true
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
describe "restrict indexing remote users" do
|
||||
test "for remote user" do
|
||||
user = insert(:user, local: false)
|
||||
|
||||
assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||
end
|
||||
|
||||
test "for local user" do
|
||||
user = insert(:user)
|
||||
|
||||
refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||
end
|
||||
end
|
||||
end
|
||||
21
test/web/metadata/restrict_indexing_test.exs
Normal file
21
test/web/metadata/restrict_indexing_test.exs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Metadata.Providers.RestrictIndexingTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
describe "build_tags/1" do
|
||||
test "for remote user" do
|
||||
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||
user: %Pleroma.User{local: false}
|
||||
}) == [{:meta, [name: "robots", content: "noindex, noarchive"], []}]
|
||||
end
|
||||
|
||||
test "for local user" do
|
||||
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||
user: %Pleroma.User{local: true}
|
||||
}) == []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -575,7 +575,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
|||
# In case scope param is missing, expecting _all_ app-supported scopes to be granted
|
||||
for user <- [non_admin, admin],
|
||||
{requested_scopes, expected_scopes} <-
|
||||
%{scopes_subset => scopes_subset, nil => app_scopes} do
|
||||
%{scopes_subset => scopes_subset, nil: app_scopes} do
|
||||
conn =
|
||||
post(
|
||||
build_conn(),
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
user = insert(:user, nickname: "Bob")
|
||||
other_user = insert(:user)
|
||||
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
|
||||
object = Object.normalize(activity)
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has followed you"
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,18 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "it sends follow activities to the 'user:notification' stream", %{
|
||||
user: user
|
||||
} do
|
||||
user_url = user.ap_id
|
||||
|
||||
body =
|
||||
File.read!("test/fixtures/users_mock/localhost.json")
|
||||
|> String.replace("{{nickname}}", user.nickname)
|
||||
|> Jason.encode!()
|
||||
|
||||
Tesla.Mock.mock_global(fn
|
||||
%{method: :get, url: ^user_url} ->
|
||||
%Tesla.Env{status: 200, body: body}
|
||||
end)
|
||||
|
||||
user2 = insert(:user)
|
||||
task = Task.async(fn -> assert_receive {:text, _}, @streamer_timeout end)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue