Merge remote-tracking branch 'origin/develop' into improved-reachability
This commit is contained in:
commit
e58ecd3234
62 changed files with 778 additions and 127 deletions
|
|
@ -58,7 +58,7 @@ defmodule Pleroma.Emoji.PackTest do
|
|||
test "skips existing emojis when adding from zip file", %{pack: pack} do
|
||||
# First, let's create a test pack with a "bear" emoji
|
||||
test_pack_path = Path.join(@emoji_path, "test_bear_pack")
|
||||
File.mkdir_p(test_pack_path)
|
||||
Pleroma.Backports.mkdir_p(test_pack_path)
|
||||
|
||||
# Create a pack.json file
|
||||
File.write!(Path.join(test_pack_path, "pack.json"), """
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.FrontendTest do
|
|||
@dir "test/frontend_static_test"
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(@dir)
|
||||
Pleroma.Backports.mkdir_p!(@dir)
|
||||
clear_config([:instance, :static_dir], @dir)
|
||||
|
||||
on_exit(fn ->
|
||||
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.FrontendTest do
|
|||
|
||||
folder = Path.join([@dir, "frontends", "pleroma", "fantasy"])
|
||||
previously_existing = Path.join([folder, "temp"])
|
||||
File.mkdir_p!(folder)
|
||||
Pleroma.Backports.mkdir_p!(folder)
|
||||
File.write!(previously_existing, "yey")
|
||||
assert File.exists?(previously_existing)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
defmodule Pleroma.Instances.InstanceTest do
|
||||
alias Pleroma.Instances.Instance
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
use Pleroma.DataCase
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
|
|
@ -214,32 +213,14 @@ defmodule Pleroma.Instances.InstanceTest do
|
|||
end
|
||||
end
|
||||
|
||||
test "delete_users_and_activities/1 deletes remote instance users and activities" do
|
||||
[mario, luigi, _peach, wario] =
|
||||
users = [
|
||||
insert(:user, nickname: "mario@mushroom.kingdom", name: "Mario"),
|
||||
insert(:user, nickname: "luigi@mushroom.kingdom", name: "Luigi"),
|
||||
insert(:user, nickname: "peach@mushroom.kingdom", name: "Peach"),
|
||||
insert(:user, nickname: "wario@greedville.biz", name: "Wario")
|
||||
]
|
||||
test "delete_users_and_activities/1 schedules a job to delete the instance and users" do
|
||||
insert(:user, nickname: "mario@mushroom.kingdom", name: "Mario")
|
||||
|
||||
{:ok, post1} = CommonAPI.post(mario, %{status: "letsa go!"})
|
||||
{:ok, post2} = CommonAPI.post(luigi, %{status: "itsa me... luigi"})
|
||||
{:ok, post3} = CommonAPI.post(wario, %{status: "WHA-HA-HA!"})
|
||||
{:ok, _job} = Instance.delete_users_and_activities("mushroom.kingdom")
|
||||
|
||||
{:ok, job} = Instance.delete_users_and_activities("mushroom.kingdom")
|
||||
:ok = ObanHelpers.perform(job)
|
||||
|
||||
[mario, luigi, peach, wario] = Repo.reload(users)
|
||||
|
||||
refute mario.is_active
|
||||
refute luigi.is_active
|
||||
refute peach.is_active
|
||||
refute peach.name == "Peach"
|
||||
|
||||
assert wario.is_active
|
||||
assert wario.name == "Wario"
|
||||
|
||||
assert [nil, nil, %{}] = Repo.reload([post1, post2, post3])
|
||||
assert_enqueued(
|
||||
worker: Pleroma.Workers.DeleteWorker,
|
||||
args: %{"op" => "delete_instance", "host" => "mushroom.kingdom"}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ defmodule Pleroma.ObjectTest do
|
|||
|
||||
uploads_dir = Pleroma.Config.get!([Pleroma.Uploaders.Local, :uploads])
|
||||
|
||||
File.mkdir_p!(uploads_dir)
|
||||
Pleroma.Backports.mkdir_p!(uploads_dir)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpeg",
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ defmodule Pleroma.SafeZipTest do
|
|||
|
||||
setup do
|
||||
# Ensure tmp directory exists
|
||||
File.mkdir_p!(@tmp_dir)
|
||||
Pleroma.Backports.mkdir_p!(@tmp_dir)
|
||||
|
||||
on_exit(fn ->
|
||||
# Clean up any files created during tests
|
||||
File.rm_rf!(@tmp_dir)
|
||||
File.mkdir_p!(@tmp_dir)
|
||||
Pleroma.Backports.mkdir_p!(@tmp_dir)
|
||||
end)
|
||||
|
||||
:ok
|
||||
|
|
@ -89,7 +89,7 @@ defmodule Pleroma.SafeZipTest do
|
|||
# For this test, we'll manually check if the file exists in the archive
|
||||
# by extracting it and verifying it exists
|
||||
extract_dir = Path.join(@tmp_dir, "extract_check")
|
||||
File.mkdir_p!(extract_dir)
|
||||
Pleroma.Backports.mkdir_p!(extract_dir)
|
||||
{:ok, files} = SafeZip.unzip_file(zip_path, extract_dir)
|
||||
|
||||
# Verify the root file was extracted
|
||||
|
|
@ -145,7 +145,7 @@ defmodule Pleroma.SafeZipTest do
|
|||
test "can create zip with directories" do
|
||||
# Create a directory structure
|
||||
dir_path = Path.join(@tmp_dir, "test_dir")
|
||||
File.mkdir_p!(dir_path)
|
||||
Pleroma.Backports.mkdir_p!(dir_path)
|
||||
|
||||
file_in_dir_path = Path.join(dir_path, "file_in_dir.txt")
|
||||
File.write!(file_in_dir_path, "file in directory")
|
||||
|
|
@ -428,7 +428,7 @@ defmodule Pleroma.SafeZipTest do
|
|||
|
||||
# Create a directory and a file in it
|
||||
dir_path = Path.join(@tmp_dir, "file_in_dir")
|
||||
File.mkdir_p!(dir_path)
|
||||
Pleroma.Backports.mkdir_p!(dir_path)
|
||||
|
||||
file_in_dir_path = Path.join(dir_path, "test_file.txt")
|
||||
File.write!(file_in_dir_path, "file in directory content")
|
||||
|
|
|
|||
|
|
@ -2792,6 +2792,15 @@ defmodule Pleroma.UserTest do
|
|||
assert user_updated.also_known_as |> length() == 1
|
||||
assert user2.ap_id in user_updated.also_known_as
|
||||
end
|
||||
|
||||
test "should tolerate non-http(s) aliases" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
also_known_as: ["at://did:plc:xgvzy7ni6ig6ievcbls5jaxe"]
|
||||
})
|
||||
|
||||
assert "at://did:plc:xgvzy7ni6ig6ievcbls5jaxe" in user.also_known_as
|
||||
end
|
||||
end
|
||||
|
||||
describe "alias_users/1" do
|
||||
|
|
|
|||
139
test/pleroma/web/activity_pub/mrf/quiet_reply_test.exs
Normal file
139
test/pleroma/web/activity_pub/mrf/quiet_reply_test.exs
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.QuietReplyTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
|
||||
require Pleroma.Constants
|
||||
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Web.ActivityPub.MRF.QuietReply
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
test "replying to public post is forced to be quiet" do
|
||||
batman = insert(:user, nickname: "batman")
|
||||
robin = insert(:user, nickname: "robin")
|
||||
|
||||
{:ok, post} = CommonAPI.post(batman, %{status: "To the Batmobile!"})
|
||||
|
||||
reply = %{
|
||||
"type" => "Create",
|
||||
"actor" => robin.ap_id,
|
||||
"to" => [
|
||||
batman.ap_id,
|
||||
Pleroma.Constants.as_public()
|
||||
],
|
||||
"cc" => [robin.follower_address],
|
||||
"object" => %{
|
||||
"type" => "Note",
|
||||
"actor" => robin.ap_id,
|
||||
"content" => "@batman Wait up, I forgot my spandex!",
|
||||
"to" => [
|
||||
batman.ap_id,
|
||||
Pleroma.Constants.as_public()
|
||||
],
|
||||
"cc" => [robin.follower_address],
|
||||
"inReplyTo" => Object.normalize(post).data["id"]
|
||||
}
|
||||
}
|
||||
|
||||
assert {:ok, filtered} = QuietReply.filter(reply)
|
||||
|
||||
assert batman.ap_id in filtered["to"]
|
||||
assert batman.ap_id in filtered["object"]["to"]
|
||||
assert robin.follower_address in filtered["to"]
|
||||
assert robin.follower_address in filtered["object"]["to"]
|
||||
assert Pleroma.Constants.as_public() in filtered["cc"]
|
||||
assert Pleroma.Constants.as_public() in filtered["object"]["cc"]
|
||||
end
|
||||
|
||||
test "replying to unlisted post is unmodified" do
|
||||
batman = insert(:user, nickname: "batman")
|
||||
robin = insert(:user, nickname: "robin")
|
||||
|
||||
{:ok, post} = CommonAPI.post(batman, %{status: "To the Batmobile!", visibility: "private"})
|
||||
|
||||
reply = %{
|
||||
"type" => "Create",
|
||||
"actor" => robin.ap_id,
|
||||
"to" => [batman.ap_id],
|
||||
"cc" => [],
|
||||
"object" => %{
|
||||
"type" => "Note",
|
||||
"actor" => robin.ap_id,
|
||||
"content" => "@batman Wait up, I forgot my spandex!",
|
||||
"to" => [batman.ap_id],
|
||||
"cc" => [],
|
||||
"inReplyTo" => Object.normalize(post).data["id"]
|
||||
}
|
||||
}
|
||||
|
||||
assert {:ok, filtered} = QuietReply.filter(reply)
|
||||
|
||||
assert match?(^filtered, reply)
|
||||
end
|
||||
|
||||
test "replying direct is unmodified" do
|
||||
batman = insert(:user, nickname: "batman")
|
||||
robin = insert(:user, nickname: "robin")
|
||||
|
||||
{:ok, post} = CommonAPI.post(batman, %{status: "To the Batmobile!"})
|
||||
|
||||
reply = %{
|
||||
"type" => "Create",
|
||||
"actor" => robin.ap_id,
|
||||
"to" => [batman.ap_id],
|
||||
"cc" => [],
|
||||
"object" => %{
|
||||
"type" => "Note",
|
||||
"actor" => robin.ap_id,
|
||||
"content" => "@batman Wait up, I forgot my spandex!",
|
||||
"to" => [batman.ap_id],
|
||||
"cc" => [],
|
||||
"inReplyTo" => Object.normalize(post).data["id"]
|
||||
}
|
||||
}
|
||||
|
||||
assert {:ok, filtered} = QuietReply.filter(reply)
|
||||
|
||||
assert match?(^filtered, reply)
|
||||
end
|
||||
|
||||
test "replying followers-only is unmodified" do
|
||||
batman = insert(:user, nickname: "batman")
|
||||
robin = insert(:user, nickname: "robin")
|
||||
|
||||
{:ok, post} = CommonAPI.post(batman, %{status: "To the Batmobile!"})
|
||||
|
||||
reply = %{
|
||||
"type" => "Create",
|
||||
"actor" => robin.ap_id,
|
||||
"to" => [batman.ap_id, robin.follower_address],
|
||||
"cc" => [],
|
||||
"object" => %{
|
||||
"type" => "Note",
|
||||
"actor" => robin.ap_id,
|
||||
"content" => "@batman Wait up, I forgot my spandex!",
|
||||
"to" => [batman.ap_id, robin.follower_address],
|
||||
"cc" => [],
|
||||
"inReplyTo" => Object.normalize(post).data["id"]
|
||||
}
|
||||
}
|
||||
|
||||
assert {:ok, filtered} = QuietReply.filter(reply)
|
||||
|
||||
assert match?(^filtered, reply)
|
||||
end
|
||||
|
||||
test "non-reply posts are unmodified" do
|
||||
batman = insert(:user, nickname: "batman")
|
||||
|
||||
{:ok, post} = CommonAPI.post(batman, %{status: "To the Batmobile!"})
|
||||
|
||||
assert {:ok, filtered} = QuietReply.filter(post)
|
||||
|
||||
assert match?(^filtered, post)
|
||||
end
|
||||
end
|
||||
|
|
@ -409,4 +409,105 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
|
||||
assert decoded["cc"] == []
|
||||
end
|
||||
|
||||
test "unlisted activities retain public address in cc" do
|
||||
user = insert(:user)
|
||||
|
||||
# simulate unlistd activity by only having
|
||||
# public address in cc
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
user: user,
|
||||
data_attrs: %{
|
||||
"cc" => [@as_public],
|
||||
"to" => [user.follower_address]
|
||||
}
|
||||
)
|
||||
|
||||
assert @as_public in activity.data["cc"]
|
||||
|
||||
prepared =
|
||||
Publisher.prepare_one(%{
|
||||
inbox: "https://remote.instance/users/someone/inbox",
|
||||
activity_id: activity.id
|
||||
})
|
||||
|
||||
{:ok, decoded} = Jason.decode(prepared.json)
|
||||
|
||||
assert @as_public in decoded["cc"]
|
||||
|
||||
# maybe we also have another inbox in cc
|
||||
# during Publishing
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
user: user,
|
||||
data_attrs: %{
|
||||
"cc" => [@as_public],
|
||||
"to" => [user.follower_address]
|
||||
}
|
||||
)
|
||||
|
||||
prepared =
|
||||
Publisher.prepare_one(%{
|
||||
inbox: "https://remote.instance/users/someone/inbox",
|
||||
activity_id: activity.id,
|
||||
cc: ["https://remote.instance/users/someone_else/inbox"]
|
||||
})
|
||||
|
||||
{:ok, decoded} = Jason.decode(prepared.json)
|
||||
|
||||
assert decoded["cc"] == [@as_public, "https://remote.instance/users/someone_else/inbox"]
|
||||
end
|
||||
|
||||
test "public address in cc parameter is preserved" do
|
||||
user = insert(:user)
|
||||
|
||||
cc_with_public = [@as_public, "https://example.org/users/other"]
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
user: user,
|
||||
data_attrs: %{
|
||||
"cc" => cc_with_public,
|
||||
"to" => [user.follower_address]
|
||||
}
|
||||
)
|
||||
|
||||
assert @as_public in activity.data["cc"]
|
||||
|
||||
prepared =
|
||||
Publisher.prepare_one(%{
|
||||
inbox: "https://remote.instance/users/someone/inbox",
|
||||
activity_id: activity.id,
|
||||
cc: cc_with_public
|
||||
})
|
||||
|
||||
{:ok, decoded} = Jason.decode(prepared.json)
|
||||
|
||||
assert cc_with_public == decoded["cc"]
|
||||
end
|
||||
|
||||
test "cc parameter is preserved" do
|
||||
user = insert(:user)
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
user: user,
|
||||
data_attrs: %{
|
||||
"cc" => ["https://example.com/specific/user"],
|
||||
"to" => [user.follower_address]
|
||||
}
|
||||
)
|
||||
|
||||
prepared =
|
||||
Publisher.prepare_one(%{
|
||||
inbox: "https://remote.instance/users/someone/inbox",
|
||||
activity_id: activity.id,
|
||||
cc: ["https://example.com/specific/user"]
|
||||
})
|
||||
|
||||
{:ok, decoded} = Jason.decode(prepared.json)
|
||||
|
||||
assert decoded["cc"] == ["https://example.com/specific/user"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -143,4 +143,40 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
|
|||
assert {:ok, activity} = Transmogrifier.handle_incoming(data)
|
||||
assert activity.data["type"] == "Like"
|
||||
end
|
||||
|
||||
test "it changes incoming dislikes into emoji reactions" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/friendica-dislike.json")
|
||||
|> Jason.decode!()
|
||||
|> Map.put("object", activity.data["object"])
|
||||
|
||||
_actor = insert(:user, ap_id: data["actor"], local: false)
|
||||
|
||||
{:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
refute Enum.empty?(activity.recipients)
|
||||
|
||||
assert data["actor"] == "https://my-place.social/profile/vaartis"
|
||||
assert data["type"] == "EmojiReact"
|
||||
assert data["content"] == "👎"
|
||||
assert data["id"] == "https://my-place.social/objects/e599373b-1368-4b20-cd24-837166957182"
|
||||
assert data["object"] == activity.data["object"]
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/friendica-dislike-undo.json")
|
||||
|> Jason.decode!()
|
||||
|> put_in(["object", "object"], activity.data["object"])
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["actor"] == "https://my-place.social/profile/vaartis"
|
||||
assert data["type"] == "Undo"
|
||||
|
||||
assert data["object"] ==
|
||||
"https://my-place.social/objects/e599373b-1368-4b20-cd24-837166957182"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
|
|||
|
||||
setup do
|
||||
clear_config([:instance, :static_dir], @dir)
|
||||
File.mkdir_p!(Pleroma.Frontend.dir())
|
||||
Pleroma.Backports.mkdir_p!(Pleroma.Frontend.dir())
|
||||
|
||||
on_exit(fn ->
|
||||
File.rm_rf(@dir)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ defmodule Pleroma.Web.AdminAPI.InstanceControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
setup_all do
|
||||
|
|
@ -69,19 +67,19 @@ defmodule Pleroma.Web.AdminAPI.InstanceControllerTest do
|
|||
|
||||
test "DELETE /instances/:instance", %{conn: conn} do
|
||||
clear_config([:instance, :admin_privileges], [:instances_delete])
|
||||
user = insert(:user, nickname: "lain@lain.com")
|
||||
post = insert(:note_activity, user: user)
|
||||
insert(:user, nickname: "lain@lain.com")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/instances/lain.com")
|
||||
|> json_response(200)
|
||||
|
||||
[:ok] = ObanHelpers.perform_all()
|
||||
|
||||
assert response == "lain.com"
|
||||
refute Repo.reload(user).is_active
|
||||
refute Repo.reload(post)
|
||||
|
||||
assert_enqueued(
|
||||
worker: Pleroma.Workers.DeleteWorker,
|
||||
args: %{"op" => "delete_instance", "host" => "lain.com"}
|
||||
)
|
||||
|
||||
clear_config([:instance, :admin_privileges], [])
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ defmodule Pleroma.Web.AdminAPI.InstanceDocumentControllerTest do
|
|||
@default_instance_panel ~s(<p>Welcome to <a href="https://pleroma.social" target="_blank">Pleroma!</a></p>)
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(@dir)
|
||||
Pleroma.Backports.mkdir_p!(@dir)
|
||||
on_exit(fn -> File.rm_rf(@dir) end)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,33 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
"artist" => "lain",
|
||||
"album" => "lain radio",
|
||||
"length" => "180000",
|
||||
"externalLink" => "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
|
||||
"external_link" => "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
|
||||
})
|
||||
|
||||
assert %{"title" => "lain radio episode 1"} = json_response_and_validate_schema(conn, 200)
|
||||
assert %{
|
||||
"title" => "lain radio episode 1",
|
||||
"external_link" => "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
|
||||
} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "external_link fallback" do
|
||||
%{conn: conn} = oauth_access(["write"])
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/pleroma/scrobble", %{
|
||||
"title" => "lain radio episode 2",
|
||||
"artist" => "lain",
|
||||
"album" => "lain radio",
|
||||
"length" => "180000",
|
||||
"externalLink" => "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
|
||||
})
|
||||
|
||||
assert %{
|
||||
"title" => "lain radio episode 2",
|
||||
"external_link" => "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
|
||||
} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -35,7 +58,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
title: "lain radio episode 1",
|
||||
artist: "lain",
|
||||
album: "lain radio",
|
||||
externalLink: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
|
||||
external_link: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
|
||||
})
|
||||
|
||||
{:ok, _activity} =
|
||||
|
|
@ -43,7 +66,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
title: "lain radio episode 2",
|
||||
artist: "lain",
|
||||
album: "lain radio",
|
||||
externalLink: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
|
||||
external_link: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
|
||||
})
|
||||
|
||||
{:ok, _activity} =
|
||||
|
|
@ -51,7 +74,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
title: "lain radio episode 3",
|
||||
artist: "lain",
|
||||
album: "lain radio",
|
||||
externalLink: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+3"
|
||||
external_link: "https://www.last.fm/music/lain/lain+radio/lain+radio+episode+3"
|
||||
})
|
||||
|
||||
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
|||
@dir "test/tmp/instance_static"
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(@dir)
|
||||
Pleroma.Backports.mkdir_p!(@dir)
|
||||
on_exit(fn -> File.rm_rf(@dir) end)
|
||||
end
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
|||
clear_config([:frontends, :primary], %{"name" => name, "ref" => ref})
|
||||
path = "#{@dir}/frontends/#{name}/#{ref}"
|
||||
|
||||
File.mkdir_p!(path)
|
||||
Pleroma.Backports.mkdir_p!(path)
|
||||
File.write!("#{path}/index.html", "from frontend plug")
|
||||
|
||||
index = get(conn, "/")
|
||||
|
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
|||
clear_config([:frontends, :admin], %{"name" => name, "ref" => ref})
|
||||
path = "#{@dir}/frontends/#{name}/#{ref}"
|
||||
|
||||
File.mkdir_p!(path)
|
||||
Pleroma.Backports.mkdir_p!(path)
|
||||
File.write!("#{path}/index.html", "from frontend plug")
|
||||
|
||||
index = get(conn, "/pleroma/admin/")
|
||||
|
|
@ -67,7 +67,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
|||
clear_config([:frontends, :primary], %{"name" => name, "ref" => ref})
|
||||
path = "#{@dir}/frontends/#{name}/#{ref}"
|
||||
|
||||
File.mkdir_p!("#{path}/proxy/rr/ss")
|
||||
Pleroma.Backports.mkdir_p!("#{path}/proxy/rr/ss")
|
||||
File.write!("#{path}/proxy/rr/ss/Ek7w8WPVcAApOvN.jpg:large", "FB image")
|
||||
|
||||
ConfigMock
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Plugs.InstanceStaticTest do
|
|||
@dir "test/tmp/instance_static"
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(@dir)
|
||||
Pleroma.Backports.mkdir_p!(@dir)
|
||||
on_exit(fn -> File.rm_rf(@dir) end)
|
||||
end
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ defmodule Pleroma.Web.Plugs.InstanceStaticTest do
|
|||
refute html_response(bundled_index, 200) == "from frontend plug"
|
||||
|
||||
path = "#{@dir}/frontends/#{name}/#{ref}"
|
||||
File.mkdir_p!(path)
|
||||
Pleroma.Backports.mkdir_p!(path)
|
||||
File.write!("#{path}/index.html", "from frontend plug")
|
||||
|
||||
index = get(conn, "/")
|
||||
|
|
|
|||
39
test/pleroma/workers/delete_worker_test.exs
Normal file
39
test/pleroma/workers/delete_worker_test.exs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Workers.DeleteWorkerTest do
|
||||
use Pleroma.DataCase, async: true
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Instances.Instance
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.Workers.DeleteWorker
|
||||
|
||||
describe "instance deletion" do
|
||||
test "creates individual Oban jobs for each user when deleting an instance" do
|
||||
user1 = insert(:user, nickname: "alice@example.com", name: "Alice")
|
||||
user2 = insert(:user, nickname: "bob@example.com", name: "Bob")
|
||||
|
||||
{:ok, job} = Instance.delete_users_and_activities("example.com")
|
||||
|
||||
assert_enqueued(
|
||||
worker: DeleteWorker,
|
||||
args: %{"op" => "delete_instance", "host" => "example.com"}
|
||||
)
|
||||
|
||||
{:ok, :ok} = ObanHelpers.perform(job)
|
||||
|
||||
delete_user_jobs = all_enqueued(worker: DeleteWorker, args: %{"op" => "delete_user"})
|
||||
|
||||
assert length(delete_user_jobs) == 2
|
||||
|
||||
user_ids = [user1.id, user2.id]
|
||||
job_user_ids = Enum.map(delete_user_jobs, fn job -> job.args["user_id"] end)
|
||||
|
||||
assert Enum.sort(user_ids) == Enum.sort(job_user_ids)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue