Merge branch 'develop' into issue/1383
This commit is contained in:
commit
6813c0302c
79 changed files with 1053 additions and 374 deletions
|
|
@ -877,7 +877,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert reaction_activity
|
||||
|
||||
assert reaction_activity.data["actor"] == reactor.ap_id
|
||||
assert reaction_activity.data["type"] == "EmojiReaction"
|
||||
assert reaction_activity.data["type"] == "EmojiReact"
|
||||
assert reaction_activity.data["content"] == "🔥"
|
||||
assert reaction_activity.data["object"] == object.data["id"]
|
||||
assert reaction_activity.data["to"] == [User.ap_followers(reactor), activity.data["actor"]]
|
||||
|
|
@ -1174,6 +1174,23 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert embedded_object["object"] == followed.ap_id
|
||||
assert embedded_object["id"] == follow_activity.data["id"]
|
||||
end
|
||||
|
||||
test "creates an undo activity for a pending follow request" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, %{locked: true})
|
||||
|
||||
{:ok, follow_activity} = ActivityPub.follow(follower, followed)
|
||||
{:ok, activity} = ActivityPub.unfollow(follower, followed)
|
||||
|
||||
assert activity.data["type"] == "Undo"
|
||||
assert activity.data["actor"] == follower.ap_id
|
||||
|
||||
embedded_object = activity.data["object"]
|
||||
assert is_map(embedded_object)
|
||||
assert embedded_object["type"] == "Follow"
|
||||
assert embedded_object["object"] == followed.ap_id
|
||||
assert embedded_object["id"] == follow_activity.data["id"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "blocking / unblocking" do
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["object"] == activity.data["object"]
|
||||
end
|
||||
|
||||
test "it works for incoming misskey likes, turning them into EmojiReactions" do
|
||||
test "it works for incoming misskey likes, turning them into EmojiReacts" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
|
||||
|
|
@ -352,13 +352,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["actor"] == data["actor"]
|
||||
assert data["type"] == "EmojiReaction"
|
||||
assert data["type"] == "EmojiReact"
|
||||
assert data["id"] == data["id"]
|
||||
assert data["object"] == activity.data["object"]
|
||||
assert data["content"] == "🍮"
|
||||
end
|
||||
|
||||
test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReactions" do
|
||||
test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReacts" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["actor"] == data["actor"]
|
||||
assert data["type"] == "EmojiReaction"
|
||||
assert data["type"] == "EmojiReact"
|
||||
assert data["id"] == data["id"]
|
||||
assert data["object"] == activity.data["object"]
|
||||
assert data["content"] == "⭐"
|
||||
|
|
@ -389,7 +389,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||
assert data["type"] == "EmojiReaction"
|
||||
assert data["type"] == "EmojiReact"
|
||||
assert data["id"] == "http://mastodon.example.org/users/admin#reactions/2"
|
||||
assert data["object"] == activity.data["object"]
|
||||
assert data["content"] == "👌"
|
||||
|
|
|
|||
|
|
@ -1899,13 +1899,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"To use this endpoint you need to enable configuration from database."
|
||||
end
|
||||
|
||||
test "without any settings in db", %{conn: conn} do
|
||||
conn = get(conn, "/api/pleroma/admin/config")
|
||||
|
||||
assert json_response(conn, 400) ==
|
||||
"To use configuration from database migrate your settings to database."
|
||||
end
|
||||
|
||||
test "with settings only in db", %{conn: conn} do
|
||||
config1 = insert(:config)
|
||||
config2 = insert(:config)
|
||||
|
|
@ -2043,7 +2036,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
Application.delete_env(:pleroma, Pleroma.Captcha.NotReal)
|
||||
Application.put_env(:pleroma, :http, http)
|
||||
Application.put_env(:tesla, :adapter, Tesla.Mock)
|
||||
:ok = File.rm("config/test.exported_from_db.secret.exs")
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -2170,7 +2162,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
assert Application.get_env(:idna, :key5) == {"string", Pleroma.Captcha.NotReal, []}
|
||||
end
|
||||
|
||||
test "save config setting without key", %{conn: conn} do
|
||||
test "save configs setting without explicit key", %{conn: conn} do
|
||||
level = Application.get_env(:quack, :level)
|
||||
meta = Application.get_env(:quack, :meta)
|
||||
webhook_url = Application.get_env(:quack, :webhook_url)
|
||||
|
|
@ -2256,6 +2248,34 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
}
|
||||
end
|
||||
|
||||
test "saving config which need pleroma reboot", %{conn: conn} do
|
||||
chat = Pleroma.Config.get(:chat)
|
||||
on_exit(fn -> Pleroma.Config.put(:chat, chat) end)
|
||||
|
||||
conn =
|
||||
post(
|
||||
conn,
|
||||
"/api/pleroma/admin/config",
|
||||
%{
|
||||
configs: [
|
||||
%{group: ":pleroma", key: ":chat", value: [%{"tuple" => [":enabled", true]}]}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
assert json_response(conn, 200) == %{
|
||||
"configs" => [
|
||||
%{
|
||||
"db" => [":enabled"],
|
||||
"group" => ":pleroma",
|
||||
"key" => ":chat",
|
||||
"value" => [%{"tuple" => [":enabled", true]}]
|
||||
}
|
||||
],
|
||||
"need_reboot" => true
|
||||
}
|
||||
end
|
||||
|
||||
test "saving config with nested merge", %{conn: conn} do
|
||||
config =
|
||||
insert(:config, key: ":key1", value: :erlang.term_to_binary(key1: 1, key2: [k1: 1, k2: 2]))
|
||||
|
|
@ -2957,47 +2977,15 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "config mix tasks run" do
|
||||
setup do
|
||||
Mix.shell(Mix.Shell.Quiet)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(Mix.Shell.IO)
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/restart" do
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
clear_config([:feed, :post_title]) do
|
||||
Pleroma.Config.put([:feed, :post_title], %{max_length: 100, omission: "…"})
|
||||
end
|
||||
|
||||
test "transfer settings to DB and to file", %{conn: conn} do
|
||||
assert Repo.all(Pleroma.ConfigDB) == []
|
||||
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
||||
assert Repo.aggregate(Pleroma.ConfigDB, :count, :id) > 0
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
assert json_response(conn, 200) == %{}
|
||||
assert Repo.all(Pleroma.ConfigDB) == []
|
||||
end
|
||||
|
||||
test "returns error if configuration from database is off", %{conn: conn} do
|
||||
initial = Pleroma.Config.get(:configurable_from_database)
|
||||
on_exit(fn -> Pleroma.Config.put(:configurable_from_database, initial) end)
|
||||
Pleroma.Config.put(:configurable_from_database, false)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
assert json_response(conn, 400) ==
|
||||
"To use this endpoint you need to enable configuration from database."
|
||||
|
||||
assert Repo.all(Pleroma.ConfigDB) == []
|
||||
test "pleroma restarts", %{conn: conn} do
|
||||
ExUnit.CaptureLog.capture_log(fn ->
|
||||
assert conn |> get("/api/pleroma/admin/restart") |> json_response(200) == %{}
|
||||
end) =~ "pleroma restarted"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -324,6 +324,21 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert %User{pinned_activities: [^id]} = user
|
||||
end
|
||||
|
||||
test "pin poll", %{user: user} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "How is fediverse today?",
|
||||
"poll" => %{"options" => ["Absolutely outstanding", "Not good"], "expires_in" => 20}
|
||||
})
|
||||
|
||||
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||
|
||||
id = activity.id
|
||||
user = refresh_record(user)
|
||||
|
||||
assert %User{pinned_activities: [^id]} = user
|
||||
end
|
||||
|
||||
test "unlisted statuses can be pinned", %{user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"})
|
||||
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||
|
|
@ -536,6 +551,50 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
refute User.subscribed_to?(follower, followed)
|
||||
end
|
||||
|
||||
test "cancels a pending follow for a local user" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
|
||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
||||
assert User.get_follow_state(follower, followed) == "pending"
|
||||
assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
assert User.get_follow_state(follower, followed) == nil
|
||||
|
||||
assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
|
||||
Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
|
||||
|
||||
assert %{
|
||||
data: %{
|
||||
"type" => "Undo",
|
||||
"object" => %{"type" => "Follow", "state" => "cancelled"}
|
||||
}
|
||||
} = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
|
||||
end
|
||||
|
||||
test "cancels a pending follow for a remote user" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true, local: false, ap_enabled: true)
|
||||
|
||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
||||
assert User.get_follow_state(follower, followed) == "pending"
|
||||
assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
assert User.get_follow_state(follower, followed) == nil
|
||||
|
||||
assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
|
||||
Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
|
||||
|
||||
assert %{
|
||||
data: %{
|
||||
"type" => "Undo",
|
||||
"object" => %{"type" => "Follow", "state" => "cancelled"}
|
||||
}
|
||||
} = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
|
||||
end
|
||||
end
|
||||
|
||||
describe "accept_follow_request/2" do
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
|> json_response(200)
|
||||
|
||||
assert account_data["fields"] == [
|
||||
%{"name" => "foo", "value" => "bar"},
|
||||
%{"name" => "<a href=\"http://google.com\">foo</a>", "value" => "bar"},
|
||||
%{"name" => "link", "value" => ~S(<a href="http://cofe.io" rel="ugc">cofe.io</a>)}
|
||||
]
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
|> json_response(200)
|
||||
|
||||
assert account["fields"] == [
|
||||
%{"name" => "foo", "value" => "bar"},
|
||||
%{"name" => "<a href=\"http://google.com\">foo</a>", "value" => "bar"},
|
||||
%{"name" => "link", "value" => ~S(<a href="http://cofe.io" rel="ugc">cofe.io</a>)}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -457,6 +457,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert id == to_string(other_user.id)
|
||||
end
|
||||
|
||||
test "cancelling follow request", %{conn: conn} do
|
||||
%{id: other_user_id} = insert(:user, %{locked: true})
|
||||
|
||||
assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
|
||||
conn |> post("/api/v1/accounts/#{other_user_id}/follow") |> json_response(:ok)
|
||||
|
||||
assert %{"id" => ^other_user_id, "following" => false, "requested" => false} =
|
||||
conn |> post("/api/v1/accounts/#{other_user_id}/unfollow") |> json_response(:ok)
|
||||
end
|
||||
|
||||
test "following without reblogs" do
|
||||
%{conn: conn} = oauth_access(["follow", "read:statuses"])
|
||||
followed = insert(:user)
|
||||
|
|
|
|||
|
|
@ -370,6 +370,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
assert NaiveDateTime.diff(NaiveDateTime.from_iso8601!(response["poll"]["expires_at"]), time) in 420..430
|
||||
refute response["poll"]["expred"]
|
||||
|
||||
question = Object.get_by_id(response["poll"]["id"])
|
||||
|
||||
# closed contains utc timezone
|
||||
assert question.data["closed"] =~ "Z"
|
||||
end
|
||||
|
||||
test "option limit is enforced", %{conn: conn} do
|
||||
|
|
|
|||
|
|
@ -368,10 +368,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert result.pleroma[:settings_store] == nil
|
||||
end
|
||||
|
||||
test "sanitizes display names" do
|
||||
test "doesn't sanitize display names" do
|
||||
user = insert(:user, name: "<marquee> username </marquee>")
|
||||
result = AccountView.render("show.json", %{user: user})
|
||||
refute result.display_name == "<marquee> username </marquee>"
|
||||
assert result.display_name == "<marquee> username </marquee>"
|
||||
end
|
||||
|
||||
test "never display nil user follow counts" do
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
NotificationView.render("index.json", %{notifications: [notification], for: follower})
|
||||
end
|
||||
|
||||
test "EmojiReaction notification" do
|
||||
test "EmojiReact notification" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue