Your account at #{instance_name()} is being reviewed by staff. You will receive another email once your account is approved.
+ """
+
+ new()
+ |> to(recipient(user))
+ |> from(sender())
+ |> subject("Your account is awaiting approval")
+ |> html_body(html_body)
+ end
+
@doc """
Email used in digest email notifications
Includes Mentions and New Followers data
@@ -106,7 +119,7 @@ def digest_email(user) do
notifications
|> Enum.filter(&(&1.activity.data["type"] == "Create"))
|> Enum.map(fn notification ->
- object = Pleroma.Object.normalize(notification.activity)
+ object = Pleroma.Object.normalize(notification.activity, fetch: false)
if not is_nil(object) do
object = update_in(object.data["content"], &format_links/1)
@@ -129,7 +142,7 @@ def digest_email(user) do
if not is_nil(from) do
%{
data: notification,
- object: Pleroma.Object.normalize(notification.activity),
+ object: Pleroma.Object.normalize(notification.activity, fetch: false),
from: User.get_by_ap_id(notification.activity.actor)
}
end
@@ -151,7 +164,7 @@ def digest_email(user) do
logo_path =
if is_nil(logo) do
- Path.join(:code.priv_dir(:pleroma), "static/static/logo.png")
+ Path.join(:code.priv_dir(:pleroma), "static/static/logo.svg")
else
Path.join(Config.get([:instance, :static_dir]), logo)
end
@@ -162,7 +175,7 @@ def digest_email(user) do
|> subject("Your digest from #{instance_name()}")
|> put_layout(false)
|> render_body("digest.html", html_data)
- |> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.png", type: :inline))
+ |> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.svg", type: :inline))
end
end
diff --git a/lib/pleroma/emoji/formatter.ex b/lib/pleroma/emoji/formatter.ex
index dc45b8a38..992b20e12 100644
--- a/lib/pleroma/emoji/formatter.ex
+++ b/lib/pleroma/emoji/formatter.ex
@@ -5,6 +5,7 @@
defmodule Pleroma.Emoji.Formatter do
alias Pleroma.Emoji
alias Pleroma.HTML
+ alias Pleroma.Web
alias Pleroma.Web.MediaProxy
def emojify(text) do
@@ -43,7 +44,7 @@ def get_emoji_map(text) when is_binary(text) do
Emoji.get_all()
|> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
- Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}")
+ Map.put(acc, name, to_string(URI.merge(Web.base_url(), file)))
end)
end
diff --git a/lib/pleroma/emoji/pack.ex b/lib/pleroma/emoji/pack.ex
index ca58e5432..ec97aa652 100644
--- a/lib/pleroma/emoji/pack.ex
+++ b/lib/pleroma/emoji/pack.ex
@@ -20,16 +20,18 @@ defmodule Pleroma.Emoji.Pack do
name: String.t()
}
+ @cachex Pleroma.Config.get([:cachex, :provider], Cachex)
+
alias Pleroma.Emoji
alias Pleroma.Emoji.Pack
+ alias Pleroma.Utils
@spec create(String.t()) :: {:ok, t()} | {:error, File.posix()} | {:error, :empty_values}
def create(name) do
with :ok <- validate_not_empty([name]),
dir <- Path.join(emoji_path(), name),
:ok <- File.mkdir(dir) do
- %__MODULE__{pack_file: Path.join(dir, "pack.json")}
- |> save_pack()
+ save_pack(%__MODULE__{pack_file: Path.join(dir, "pack.json")})
end
end
@@ -62,10 +64,9 @@ def show(opts) do
@spec delete(String.t()) ::
{:ok, [binary()]} | {:error, File.posix(), binary()} | {:error, :empty_values}
def delete(name) do
- with :ok <- validate_not_empty([name]) do
- emoji_path()
- |> Path.join(name)
- |> File.rm_rf()
+ with :ok <- validate_not_empty([name]),
+ pack_path <- Path.join(emoji_path(), name) do
+ File.rm_rf(pack_path)
end
end
@@ -94,7 +95,7 @@ defp unpack_zip_emojies(zip_files) do
def add_file(%Pack{} = pack, _, _, %Plug.Upload{content_type: "application/zip"} = file) do
with {:ok, zip_files} <- :zip.table(to_charlist(file.path)),
[_ | _] = emojies <- unpack_zip_emojies(zip_files),
- {:ok, tmp_dir} <- Pleroma.Utils.tmp_dir("emoji") do
+ {:ok, tmp_dir} <- Utils.tmp_dir("emoji") do
try do
{:ok, _emoji_files} =
:zip.unzip(
@@ -282,18 +283,21 @@ def update_metadata(name, data) do
end
end
- @spec load_pack(String.t()) :: {:ok, t()} | {:error, :not_found}
+ @spec load_pack(String.t()) :: {:ok, t()} | {:error, :file.posix()}
def load_pack(name) do
pack_file = Path.join([emoji_path(), name, "pack.json"])
- if File.exists?(pack_file) do
+ with {:ok, _} <- File.stat(pack_file),
+ {:ok, pack_data} <- File.read(pack_file) do
pack =
- pack_file
- |> File.read!()
- |> from_json()
- |> Map.put(:pack_file, pack_file)
- |> Map.put(:path, Path.dirname(pack_file))
- |> Map.put(:name, name)
+ from_json(
+ pack_data,
+ %{
+ pack_file: pack_file,
+ path: Path.dirname(pack_file),
+ name: name
+ }
+ )
files_count =
pack.files
@@ -301,8 +305,6 @@ def load_pack(name) do
|> length()
{:ok, Map.put(pack, :files_count, files_count)}
- else
- {:error, :not_found}
end
end
@@ -415,7 +417,7 @@ defp create_archive_and_cache(pack, hash) do
ttl_per_file = Pleroma.Config.get!([:emoji, :shared_pack_cache_seconds_per_file])
overall_ttl = :timer.seconds(ttl_per_file * Enum.count(files))
- Cachex.put!(
+ @cachex.put(
:emoji_packs_cache,
pack.name,
# if pack.json MD5 changes, the cache is not valid anymore
@@ -434,10 +436,17 @@ defp save_pack(pack) do
end
end
- defp from_json(json) do
+ defp from_json(json, attrs) do
map = Jason.decode!(json)
- struct(__MODULE__, %{files: map["files"], pack: map["pack"]})
+ pack_attrs =
+ attrs
+ |> Map.merge(%{
+ files: map["files"],
+ pack: map["pack"]
+ })
+
+ struct(__MODULE__, pack_attrs)
end
defp validate_shareable_packs_available(uri) do
@@ -491,10 +500,10 @@ defp rename_file(pack, filename, new_filename) do
end
defp create_subdirs(file_path) do
- if String.contains?(file_path, "/") do
- file_path
- |> Path.dirname()
- |> File.mkdir_p!()
+ with true <- String.contains?(file_path, "/"),
+ path <- Path.dirname(file_path),
+ false <- File.exists?(path) do
+ File.mkdir_p!(path)
end
end
@@ -518,10 +527,15 @@ defp remove_dir_if_empty(emoji, filename) do
defp get_filename(pack, shortcode) do
with %{^shortcode => filename} when is_binary(filename) <- pack.files,
- true <- pack.path |> Path.join(filename) |> File.exists?() do
+ file_path <- Path.join(pack.path, filename),
+ {:ok, _} <- File.stat(file_path) do
{:ok, filename}
else
- _ -> {:error, :doesnt_exist}
+ {:error, _} = error ->
+ error
+
+ _ ->
+ {:error, :doesnt_exist}
end
end
@@ -606,7 +620,7 @@ defp download_archive(url, sha) do
defp fetch_archive(pack) do
hash = :crypto.hash(:md5, File.read!(pack.pack_file))
- case Cachex.get!(:emoji_packs_cache, pack.name) do
+ case @cachex.get!(:emoji_packs_cache, pack.name) do
%{hash: ^hash, pack_data: archive} -> archive
_ -> create_archive_and_cache(pack, hash)
end
diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex
index e9f54c4c0..8ac8d18c1 100644
--- a/lib/pleroma/gopher/server.ex
+++ b/lib/pleroma/gopher/server.ex
@@ -76,7 +76,7 @@ def render_activities(activities) do
|> Enum.map(fn activity ->
user = User.get_cached_by_ap_id(activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
like_count = object.data["like_count"] || 0
announcement_count = object.data["announcement_count"] || 0
diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex
index 43e9145be..c5ece7350 100644
--- a/lib/pleroma/html.ex
+++ b/lib/pleroma/html.ex
@@ -6,6 +6,8 @@ defmodule Pleroma.HTML do
# Scrubbers are compiled on boot so they can be configured in OTP releases
# @on_load :compile_scrubbers
+ @cachex Pleroma.Config.get([:cachex, :provider], Cachex)
+
def compile_scrubbers do
dir = Path.join(:code.priv_dir(:pleroma), "scrubbers")
@@ -56,8 +58,8 @@ def get_cached_scrubbed_html_for_activity(
) do
key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}"
- Cachex.fetch!(:scrubber_cache, key, fn _key ->
- object = Pleroma.Object.normalize(activity)
+ @cachex.fetch!(:scrubber_cache, key, fn _key ->
+ object = Pleroma.Object.normalize(activity, fetch: false)
ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback)
end)
end
@@ -105,7 +107,7 @@ def extract_first_external_url_from_object(%{data: %{"content" => content}} = ob
unless object.data["fake"] do
key = "URL|#{object.id}"
- Cachex.fetch!(:scrubber_cache, key, fn _key ->
+ @cachex.fetch!(:scrubber_cache, key, fn _key ->
{:commit, {:ok, extract_first_external_url(content)}}
end)
else
diff --git a/lib/jason_types.ex b/lib/pleroma/logging.ex
similarity index 59%
rename from lib/jason_types.ex
rename to lib/pleroma/logging.ex
index f1fdc96f4..37b201c29 100644
--- a/lib/jason_types.ex
+++ b/lib/pleroma/logging.ex
@@ -2,8 +2,6 @@
# Copyright © 2017-2020 Pleroma Authors
![Image Image](cid:logo.png)
diff --git a/lib/pleroma/web/twitter_api/controller.ex b/lib/pleroma/web/twitter_api/controller.ex
index f42dba442..16f43863c 100644
--- a/lib/pleroma/web/twitter_api/controller.ex
+++ b/lib/pleroma/web/twitter_api/controller.ex
@@ -31,10 +31,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def confirm_email(conn, %{"user_id" => uid, "token" => token}) do
with %User{} = user <- User.get_cached_by_id(uid),
true <- user.local and user.confirmation_pending and user.confirmation_token == token,
- {:ok, _} <-
- user
- |> User.confirmation_changeset(need_confirmation: false)
- |> User.update_and_set_cache() do
+ {:ok, _} <- User.confirm(user) do
redirect(conn, to: "/")
end
end
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index 5d7948507..8e20b0d55 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -45,7 +45,6 @@ defp create_user(params, opts) do
case User.register(changeset) do
{:ok, user} ->
- maybe_notify_admins(user)
{:ok, user}
{:error, changeset} ->
@@ -58,18 +57,6 @@ defp create_user(params, opts) do
end
end
- defp maybe_notify_admins(%User{} = account) do
- if Pleroma.Config.get([:instance, :account_approval_required]) do
- User.all_superusers()
- |> Enum.filter(fn user -> not is_nil(user.email) end)
- |> Enum.each(fn superuser ->
- superuser
- |> Pleroma.Emails.AdminEmail.new_unapproved_registration(account)
- |> Pleroma.Emails.Mailer.deliver_async()
- end)
- end
- end
-
def password_reset(nickname_or_email) do
with true <- is_binary(nickname_or_email),
%User{local: true, email: email, deactivated: false} = user when is_binary(email) <-
diff --git a/lib/pleroma/web/web_finger.ex b/lib/pleroma/web/web_finger.ex
index 6629f5356..a109e1acc 100644
--- a/lib/pleroma/web/web_finger.ex
+++ b/lib/pleroma/web/web_finger.ex
@@ -58,12 +58,16 @@ defp gather_links(%User{} = user) do
] ++ Publisher.gather_webfinger_links(user)
end
+ defp gather_aliases(%User{} = user) do
+ [user.ap_id | user.also_known_as]
+ end
+
def represent_user(user, "JSON") do
{:ok, user} = User.ensure_keys_present(user)
%{
"subject" => "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}",
- "aliases" => [user.ap_id],
+ "aliases" => gather_aliases(user),
"links" => gather_links(user)
}
end
@@ -71,6 +75,11 @@ def represent_user(user, "JSON") do
def represent_user(user, "XML") do
{:ok, user} = User.ensure_keys_present(user)
+ aliases =
+ user
+ |> gather_aliases()
+ |> Enum.map(&{:Alias, &1})
+
links =
gather_links(user)
|> Enum.map(fn link -> {:Link, link} end)
@@ -79,9 +88,8 @@ def represent_user(user, "XML") do
:XRD,
%{xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0"},
[
- {:Subject, "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}"},
- {:Alias, user.ap_id}
- ] ++ links
+ {:Subject, "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}"}
+ ] ++ aliases ++ links
}
|> XmlBuilder.to_doc()
end
@@ -116,6 +124,9 @@ defp webfinger_from_json(doc) do
{"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", "self"} ->
Map.put(data, "ap_id", link["href"])
+ {nil, "http://ostatus.org/schema/1.0/subscribe"} ->
+ Map.put(data, "subscribe_address", link["template"])
+
_ ->
Logger.debug("Unhandled type: #{inspect(link["type"])}")
data
diff --git a/mix.exs b/mix.exs
index c948b0b02..f26a5391a 100644
--- a/mix.exs
+++ b/mix.exs
@@ -22,7 +22,7 @@ def project do
docs: [
source_url_pattern:
"https://git.pleroma.social/pleroma/pleroma/blob/develop/%{path}#L%{line}",
- logo: "priv/static/static/logo.png",
+ logo: "priv/static/images/logo.png",
extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
groups_for_extras: [
"Installation manuals": Path.wildcard("docs/installation/*.md"),
@@ -147,8 +147,8 @@ defp deps do
{:earmark, "1.4.3"},
{:bbcode_pleroma, "~> 0.2.0"},
{:crypt,
- git: "https://github.com/msantos/crypt.git",
- ref: "f63a705f92c26955977ee62a313012e309a4d77a"},
+ git: "https://git.pleroma.social/pleroma/elixir-libraries/crypt.git",
+ ref: "cf2aa3f11632e8b0634810a15b3e612c7526f6a3"},
{:cors_plug, "~> 2.0"},
{:web_push_encryption, "~> 0.3"},
{:swoosh, "~> 1.0"},
@@ -158,7 +158,7 @@ defp deps do
{:floki, "~> 0.27"},
{:timex, "~> 3.6"},
{:ueberauth, "~> 0.4"},
- {:linkify, "~> 0.4.0"},
+ {:linkify, "~> 0.4.1"},
{:http_signatures, "~> 0.1.0"},
{:telemetry, "~> 0.3"},
{:poolboy, "~> 1.5"},
@@ -211,7 +211,7 @@ defp deps do
git: "https://git.pleroma.social/pleroma/elixir-libraries/hackney.git",
ref: "7d7119f0651515d6d7669c78393fd90950a3ec6e",
override: true},
- {:mox, "~> 0.5", only: :test},
+ {:mox, "~> 1.0", only: :test},
{:websocket_client, git: "https://github.com/jeremyong/websocket_client.git", only: :test}
] ++ oauth_deps()
end
diff --git a/mix.lock b/mix.lock
index 7db71453f..01caf319e 100644
--- a/mix.lock
+++ b/mix.lock
@@ -22,7 +22,7 @@
"cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"},
"credo": {:hex, :credo, "1.4.1", "16392f1edd2cdb1de9fe4004f5ab0ae612c92e230433968eab00aafd976282fc", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "155f8a2989ad77504de5d8291fa0d41320fdcaa6a1030472e9967f285f8c7692"},
"crontab": {:hex, :crontab, "1.1.8", "2ce0e74777dfcadb28a1debbea707e58b879e6aa0ffbf9c9bb540887bce43617", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
- "crypt": {:git, "https://github.com/msantos/crypt.git", "f63a705f92c26955977ee62a313012e309a4d77a", [ref: "f63a705f92c26955977ee62a313012e309a4d77a"]},
+ "crypt": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/crypt.git", "cf2aa3f11632e8b0634810a15b3e612c7526f6a3", [ref: "cf2aa3f11632e8b0634810a15b3e612c7526f6a3"]},
"custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm", "8df019facc5ec9603e94f7270f1ac73ddf339f56ade76a721eaa57c1493ba463"},
"db_connection": {:hex, :db_connection, "2.2.2", "3bbca41b199e1598245b716248964926303b5d4609ff065125ce98bcd368939e", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "642af240d8a8affb93b4ba5a6fcd2bbcbdc327e1a524b825d383711536f8070c"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
@@ -33,7 +33,7 @@
"ecto_enum": {:hex, :ecto_enum, "1.4.0", "d14b00e04b974afc69c251632d1e49594d899067ee2b376277efd8233027aec8", [:mix], [{:ecto, ">= 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "> 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "8fb55c087181c2b15eee406519dc22578fa60dd82c088be376d0010172764ee4"},
"ecto_sql": {:hex, :ecto_sql, "3.4.5", "30161f81b167d561a9a2df4329c10ae05ff36eca7ccc84628f2c8b9fa1e43323", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "31990c6a3579b36a3c0841d34a94c275e727de8b84f58509da5f1b2032c98ac2"},
"eimp": {:hex, :eimp, "1.0.14", "fc297f0c7e2700457a95a60c7010a5f1dcb768a083b6d53f49cd94ab95a28f22", [:rebar3], [{:p1_utils, "1.0.18", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "501133f3112079b92d9e22da8b88bf4f0e13d4d67ae9c15c42c30bd25ceb83b6"},
- "elixir_make": {:hex, :elixir_make, "0.6.1", "8faa29a5597faba999aeeb72bbb9c91694ef8068f0131192fb199f98d32994ef", [:mix], [], "hexpm", "35d33270680f8d839a4003c3e9f43afb595310a592405a00afc12de4c7f55a18"},
+ "elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"esshd": {:hex, :esshd, "0.1.1", "d4dd4c46698093a40a56afecce8a46e246eb35463c457c246dacba2e056f31b5", [:mix], [], "hexpm", "d73e341e3009d390aa36387dc8862860bf9f874c94d9fd92ade2926376f49981"},
"eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm", "b14f1dc204321429479c569cfbe8fb287541184ed040956c8862cb7a677b8406"},
"ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"},
@@ -65,7 +65,7 @@
"jose": {:hex, :jose, "1.10.1", "16d8e460dae7203c6d1efa3f277e25b5af8b659febfc2f2eb4bacf87f128b80a", [:mix, :rebar3], [], "hexpm", "3c7ddc8a9394b92891db7c2771da94bf819834a1a4c92e30857b7d582e2f8257"},
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
- "linkify": {:hex, :linkify, "0.4.0", "7845b6ac33050a41acaf9318923ce6e7f3854418be9a5f22184de103f7a68ff9", [:mix], [], "hexpm", "a0ceb4c78591fecccf1d99fecc10c13dba75a307c663c80e28af9e2cdd9776ee"},
+ "linkify": {:hex, :linkify, "0.4.1", "f881eb3429ae88010cf736e6fb3eed406c187bcdd544902ec937496636b7c7b3", [:mix], [], "hexpm", "ce98693f54ae9ace59f2f7a8aed3de2ef311381a8ce7794804bd75484c371dda"},
"majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", "4c692e544b28d1f5e543fb8a44be090f8cd96f80", [ref: "4c692e544b28d1f5e543fb8a44be090f8cd96f80"]},
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
@@ -76,7 +76,7 @@
"mochiweb": {:hex, :mochiweb, "2.18.0", "eb55f1db3e6e960fac4e6db4e2db9ec3602cc9f30b86cd1481d56545c3145d2e", [:rebar3], [], "hexpm"},
"mock": {:hex, :mock, "0.3.5", "feb81f52b8dcf0a0d65001d2fec459f6b6a8c22562d94a965862f6cc066b5431", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "6fae404799408300f863550392635d8f7e3da6b71abdd5c393faf41b131c8728"},
"mogrify": {:hex, :mogrify, "0.7.4", "9b2496dde44b1ce12676f85d7dc531900939e6367bc537c7243a1b089435b32d", [:mix], [], "hexpm", "50d79e337fba6bc95bfbef918058c90f50b17eed9537771e61d4619488f099c3"},
- "mox": {:hex, :mox, "0.5.2", "55a0a5ba9ccc671518d068c8dddd20eeb436909ea79d1799e2209df7eaa98b6c", [:mix], [], "hexpm", "df4310628cd628ee181df93f50ddfd07be3e5ecc30232d3b6aadf30bdfe6092b"},
+ "mox": {:hex, :mox, "1.0.0", "4b3c7005173f47ff30641ba044eb0fe67287743eec9bd9545e37f3002b0a9f8b", [:mix], [], "hexpm", "201b0a20b7abdaaab083e9cf97884950f8a30a1350a1da403b3145e213c6f4df"},
"myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "ad0097e2f61d4953bfef20fb6abddf23b87111e6", [ref: "ad0097e2f61d4953bfef20fb6abddf23b87111e6", submodules: true]},
"nimble_parsec": {:hex, :nimble_parsec, "0.6.0", "32111b3bf39137144abd7ba1cce0914533b2d16ef35e8abc5ec8be6122944263", [:mix], [], "hexpm", "27eac315a94909d4dc68bc07a4a83e06c8379237c5ea528a9acff4ca1c873c52"},
"nimble_pool": {:hex, :nimble_pool, "0.1.0", "ffa9d5be27eee2b00b0c634eb649aa27f97b39186fec3c493716c2a33e784ec6", [:mix], [], "hexpm", "343a1eaa620ddcf3430a83f39f2af499fe2370390d4f785cd475b4df5acaf3f9"},
diff --git a/priv/gettext/en/LC_MESSAGES/posix_errors.po b/priv/gettext/en/LC_MESSAGES/posix_errors.po
new file mode 100644
index 000000000..4d8fbf1d3
--- /dev/null
+++ b/priv/gettext/en/LC_MESSAGES/posix_errors.po
@@ -0,0 +1,141 @@
+## This file is a PO Template file.
+msgid "eperm"
+msgstr "Operation not permitted"
+
+msgid "eacces"
+msgstr "Permission denied"
+
+msgid "eagain"
+msgstr "Resource temporarily unavailable"
+
+msgid "ebadf"
+msgstr "Bad file descriptor"
+
+msgid "ebadmsg"
+msgstr "Bad message"
+
+msgid "ebusy"
+msgstr "Device or resource busy"
+
+msgid "edeadlk"
+msgstr "Resource deadlock avoided"
+
+msgid "edeadlock"
+msgstr "Resource deadlock avoided"
+
+msgid "edquot"
+msgstr "Disk quota exceeded"
+
+msgid "eexist"
+msgstr "File exists"
+
+msgid "efault"
+msgstr "Bad address"
+
+msgid "efbig"
+msgstr "File is too large"
+
+msgid "eftype"
+msgstr "Inappropriate file type or format"
+
+msgid "eintr"
+msgstr "Interrupted system call"
+
+msgid "einval"
+msgstr "Invalid argument"
+
+msgid "eio"
+msgstr "Input/output error"
+
+msgid "eisdir"
+msgstr "Illegal operation on a directory"
+
+msgid "eloop"
+msgstr "Too many levels of symbolic links"
+
+msgid "emfile"
+msgstr "Too many open files"
+
+msgid "emlink"
+msgstr "Too many links"
+
+msgid "emultihop"
+msgstr "Multihop attempted"
+
+msgid "enametoolong"
+msgstr "File name is too long"
+
+msgid "enfile"
+msgstr "Too many open files in system"
+
+msgid "enobufs"
+msgstr "No buffer space available"
+
+msgid "enodev"
+msgstr "No such device"
+
+msgid "enolck"
+msgstr "No locks available"
+
+msgid "enolink"
+msgstr "Link has been severed"
+
+msgid "enoent"
+msgstr "No such file or directory"
+
+msgid "enomem"
+msgstr "Cannot allocate memory"
+
+msgid "enospc"
+msgstr "No space left on device"
+
+msgid "enosr"
+msgstr "Out of streams resources"
+
+msgid "enostr"
+msgstr "Device is not a stream"
+
+msgid "enosys"
+msgstr "Function not implemented"
+
+msgid "enotblk"
+msgstr "Block device required"
+
+msgid "enotdir"
+msgstr "Not a directory"
+
+msgid "enotsup"
+msgstr "Operation not supported"
+
+msgid "enxio"
+msgstr "No such device or address"
+
+msgid "eopnotsupp"
+msgstr "Operation not supported"
+
+msgid "eoverflow"
+msgstr "Value too large for defined data type"
+
+msgid "epipe"
+msgstr "Broken pipe"
+
+msgid "erange"
+msgstr "Numerical result out of range"
+
+msgid "erofs"
+msgstr "Read-only file system"
+
+msgid "espipe"
+msgstr "Illegal seek"
+
+msgid "esrch"
+msgstr "No such process"
+
+msgid "estale"
+msgstr "Stale file handle"
+
+msgid "etxtbsy"
+msgstr "Text file busy"
+
+msgid "exdev"
+msgstr "Invalid cross-device link"
diff --git a/priv/gettext/posix_errors.pot b/priv/gettext/posix_errors.pot
new file mode 100644
index 000000000..c9f593944
--- /dev/null
+++ b/priv/gettext/posix_errors.pot
@@ -0,0 +1,149 @@
+## This file is a PO Template file.
+##
+## `msgid`s here are often extracted from source code.
+## Add new translations manually only if they're dynamic
+## translations that can't be statically extracted.
+##
+## Run `mix gettext.extract` to bring this file up to
+## date. Leave `msgstr`s empty as changing them here as no
+## effect: edit them in PO (`.po`) files instead.
+msgid "eperm"
+msgstr ""
+
+msgid "eacces"
+msgstr ""
+
+msgid "eagain"
+msgstr ""
+
+msgid "ebadf"
+msgstr ""
+
+msgid "ebadmsg"
+msgstr ""
+
+msgid "ebusy"
+msgstr ""
+
+msgid "edeadlk"
+msgstr ""
+
+msgid "edeadlock"
+msgstr ""
+
+msgid "edquot"
+msgstr ""
+
+msgid "eexist"
+msgstr ""
+
+msgid "efault"
+msgstr ""
+
+msgid "efbig"
+msgstr ""
+
+msgid "eftype"
+msgstr ""
+
+msgid "eintr"
+msgstr ""
+
+msgid "einval"
+msgstr ""
+
+msgid "eio"
+msgstr ""
+
+msgid "eisdir"
+msgstr ""
+
+msgid "eloop"
+msgstr ""
+
+msgid "emfile"
+msgstr ""
+
+msgid "emlink"
+msgstr ""
+
+msgid "emultihop"
+msgstr ""
+
+msgid "enametoolong"
+msgstr ""
+
+msgid "enfile"
+msgstr ""
+
+msgid "enobufs"
+msgstr ""
+
+msgid "enodev"
+msgstr ""
+
+msgid "enolck"
+msgstr ""
+
+msgid "enolink"
+msgstr ""
+
+msgid "enoent"
+msgstr ""
+
+msgid "enomem"
+msgstr ""
+
+msgid "enospc"
+msgstr ""
+
+msgid "enosr"
+msgstr ""
+
+msgid "enostr"
+msgstr ""
+
+msgid "enosys"
+msgstr ""
+
+msgid "enotblk"
+msgstr ""
+
+msgid "enotdir"
+msgstr ""
+
+msgid "enotsup"
+msgstr ""
+
+msgid "enxio"
+msgstr ""
+
+msgid "eopnotsupp"
+msgstr ""
+
+msgid "eoverflow"
+msgstr ""
+
+msgid "epipe"
+msgstr ""
+
+msgid "erange"
+msgstr ""
+
+msgid "erofs"
+msgstr ""
+
+msgid "espipe"
+msgstr ""
+
+msgid "esrch"
+msgstr ""
+
+msgid "estale"
+msgstr ""
+
+msgid "etxtbsy"
+msgstr ""
+
+msgid "exdev"
+msgstr ""
diff --git a/priv/gettext/zh_Hans/LC_MESSAGES/errors.po b/priv/gettext/zh_Hans/LC_MESSAGES/errors.po
index 8b24d4a86..ecf1dab6b 100644
--- a/priv/gettext/zh_Hans/LC_MESSAGES/errors.po
+++ b/priv/gettext/zh_Hans/LC_MESSAGES/errors.po
@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-20 13:18+0000\n"
-"PO-Revision-Date: 2020-10-22 18:25+0000\n"
+"PO-Revision-Date: 2020-12-14 06:00+0000\n"
"Last-Translator: shironeko
\n"
"Language-Team: Chinese (Simplified) \n"
@@ -146,9 +146,9 @@ msgid "Cannot post an empty status without attachments"
msgstr "无法发送空白且不包含附件的状态"
#: lib/pleroma/web/common_api/utils.ex:511
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Comment must be up to %{max_size} characters"
-msgstr ""
+msgstr "评论最多可使用 %{max_size} 字符"
#: lib/pleroma/config/config_db.ex:191
#, elixir-format
@@ -250,21 +250,21 @@ msgstr "没有该对话"
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:388
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:414 lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:456
-#, elixir-format
+#, elixir-format, fuzzy
msgid "No such permission_group"
-msgstr ""
+msgstr "没有该权限组"
#: lib/pleroma/plugs/uploaded_media.ex:84
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:486 lib/pleroma/web/admin_api/controllers/fallback_controller.ex:11
#: lib/pleroma/web/feed/user_controller.ex:71 lib/pleroma/web/ostatus/ostatus_controller.ex:143
#, elixir-format
msgid "Not found"
-msgstr ""
+msgstr "未找到"
#: lib/pleroma/web/common_api/common_api.ex:331
#, elixir-format
msgid "Poll's author can't vote"
-msgstr ""
+msgstr "投票的发起者不能投票"
#: lib/pleroma/web/mastodon_api/controllers/fallback_controller.ex:20
#: lib/pleroma/web/mastodon_api/controllers/poll_controller.ex:37 lib/pleroma/web/mastodon_api/controllers/poll_controller.ex:49
@@ -272,39 +272,39 @@ msgstr ""
#: lib/pleroma/web/mastodon_api/controllers/subscription_controller.ex:71
#, elixir-format
msgid "Record not found"
-msgstr ""
+msgstr "未找到该记录"
#: lib/pleroma/web/admin_api/controllers/fallback_controller.ex:35
#: lib/pleroma/web/feed/user_controller.ex:77 lib/pleroma/web/mastodon_api/controllers/fallback_controller.ex:36
#: lib/pleroma/web/ostatus/ostatus_controller.ex:149
#, elixir-format
msgid "Something went wrong"
-msgstr ""
+msgstr "发生了一些错误"
#: lib/pleroma/web/common_api/activity_draft.ex:107
#, elixir-format
msgid "The message visibility must be direct"
-msgstr ""
+msgstr "该消息必须为私信"
#: lib/pleroma/web/common_api/utils.ex:573
#, elixir-format
msgid "The status is over the character limit"
-msgstr ""
+msgstr "状态超过了字符数限制"
#: lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex:31
#, elixir-format
msgid "This resource requires authentication."
-msgstr ""
+msgstr "该资源需要认证。"
#: lib/pleroma/plugs/rate_limiter/rate_limiter.ex:206
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Throttled"
-msgstr ""
+msgstr "节流了"
#: lib/pleroma/web/common_api/common_api.ex:356
#, elixir-format
msgid "Too many choices"
-msgstr ""
+msgstr "太多选项"
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:443
#, elixir-format
@@ -314,101 +314,101 @@ msgstr ""
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:485
#, elixir-format
msgid "You can't revoke your own admin status."
-msgstr ""
+msgstr "您不能撤消自己的管理员权限。"
#: lib/pleroma/web/oauth/oauth_controller.ex:221
#: lib/pleroma/web/oauth/oauth_controller.ex:308
#, elixir-format
msgid "Your account is currently disabled"
-msgstr ""
+msgstr "您的账户已被禁用"
#: lib/pleroma/web/oauth/oauth_controller.ex:183
#: lib/pleroma/web/oauth/oauth_controller.ex:331
#, elixir-format
msgid "Your login is missing a confirmed e-mail address"
-msgstr ""
+msgstr "您的账户缺少已认证的 e-mail 地址"
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:390
#, elixir-format
msgid "can't read inbox of %{nickname} as %{as_nickname}"
-msgstr ""
+msgstr "无法以 %{as_nickname} 读取 %{nickname} 的收件箱"
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:473
#, elixir-format
msgid "can't update outbox of %{nickname} as %{as_nickname}"
-msgstr ""
+msgstr "无法以 %{as_nickname} 更新 %{nickname} 的出件箱"
#: lib/pleroma/web/common_api/common_api.ex:471
#, elixir-format
msgid "conversation is already muted"
-msgstr ""
+msgstr "对话已经被静音"
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:314
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:492
#, elixir-format
msgid "error"
-msgstr ""
+msgstr "错误"
#: lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:32
#, elixir-format
msgid "mascots can only be images"
-msgstr ""
+msgstr "吉祥物只能是图片"
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:62
#, elixir-format
msgid "not found"
-msgstr ""
+msgstr "未找到"
#: lib/pleroma/web/oauth/oauth_controller.ex:394
#, elixir-format
msgid "Bad OAuth request."
-msgstr ""
+msgstr "错误的 OAuth 请求。"
#: lib/pleroma/web/twitter_api/twitter_api.ex:115
#, elixir-format
msgid "CAPTCHA already used"
-msgstr ""
+msgstr "验证码已被使用"
#: lib/pleroma/web/twitter_api/twitter_api.ex:112
#, elixir-format
msgid "CAPTCHA expired"
-msgstr ""
+msgstr "验证码已过期"
#: lib/pleroma/plugs/uploaded_media.ex:57
#, elixir-format
msgid "Failed"
-msgstr ""
+msgstr "失败"
#: lib/pleroma/web/oauth/oauth_controller.ex:410
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Failed to authenticate: %{message}."
-msgstr ""
+msgstr "认证失败:%{message}。"
#: lib/pleroma/web/oauth/oauth_controller.ex:441
#, elixir-format
msgid "Failed to set up user account."
-msgstr ""
+msgstr "建立用户帐号失败。"
#: lib/pleroma/plugs/oauth_scopes_plug.ex:38
#, elixir-format
msgid "Insufficient permissions: %{permissions}."
-msgstr ""
+msgstr "权限不足:%{permissions}。"
#: lib/pleroma/plugs/uploaded_media.ex:104
#, elixir-format
msgid "Internal Error"
-msgstr ""
+msgstr "内部错误"
#: lib/pleroma/web/oauth/fallback_controller.ex:22
#: lib/pleroma/web/oauth/fallback_controller.ex:29
#, elixir-format
msgid "Invalid Username/Password"
-msgstr ""
+msgstr "无效的用户名/密码"
#: lib/pleroma/web/twitter_api/twitter_api.ex:118
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Invalid answer data"
-msgstr ""
+msgstr "无效的回答数据"
#: lib/pleroma/web/nodeinfo/nodeinfo_controller.ex:33
#, elixir-format
@@ -418,12 +418,12 @@ msgstr ""
#: lib/pleroma/web/oauth/oauth_controller.ex:172
#, elixir-format
msgid "This action is outside the authorized scopes"
-msgstr ""
+msgstr "此操作在许可范围以外"
#: lib/pleroma/web/oauth/fallback_controller.ex:14
#, elixir-format
msgid "Unknown error, please check the details and try again."
-msgstr ""
+msgstr "未知错误,请检查并重试。"
#: lib/pleroma/web/oauth/oauth_controller.ex:119
#: lib/pleroma/web/oauth/oauth_controller.ex:158
@@ -434,53 +434,53 @@ msgstr ""
#: lib/pleroma/web/oauth/oauth_controller.ex:390
#, elixir-format
msgid "Unsupported OAuth provider: %{provider}."
-msgstr ""
+msgstr "不支持的 OAuth 提供者:%{provider}。"
#: lib/pleroma/uploaders/uploader.ex:72
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Uploader callback timeout"
-msgstr ""
+msgstr "上传回复超时"
#: lib/pleroma/web/uploader_controller.ex:23
#, elixir-format
msgid "bad request"
-msgstr ""
+msgstr "错误的请求"
#: lib/pleroma/web/twitter_api/twitter_api.ex:103
#, elixir-format
msgid "CAPTCHA Error"
-msgstr ""
+msgstr "验证码错误"
#: lib/pleroma/web/common_api/common_api.ex:290
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Could not add reaction emoji"
-msgstr ""
+msgstr "无法添加表情反应"
#: lib/pleroma/web/common_api/common_api.ex:301
#, elixir-format
msgid "Could not remove reaction emoji"
-msgstr ""
+msgstr "无法移除表情反应"
#: lib/pleroma/web/twitter_api/twitter_api.ex:129
#, elixir-format
msgid "Invalid CAPTCHA (Missing parameter: %{name})"
-msgstr ""
+msgstr "无效的验证码(缺少参数:%{name})"
#: lib/pleroma/web/mastodon_api/controllers/list_controller.ex:92
#, elixir-format
msgid "List not found"
-msgstr ""
+msgstr "未找到列表"
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:123
#, elixir-format
msgid "Missing parameter: %{name}"
-msgstr ""
+msgstr "缺少参数:%{name}"
#: lib/pleroma/web/oauth/oauth_controller.ex:210
#: lib/pleroma/web/oauth/oauth_controller.ex:321
#, elixir-format
msgid "Password reset is required"
-msgstr ""
+msgstr "需要重置密码"
#: lib/pleroma/tests/auth_test_controller.ex:9
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:6 lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:6
@@ -520,61 +520,61 @@ msgid "Security violation: OAuth scopes check was neither handled nor explicitly
msgstr ""
#: lib/pleroma/plugs/ensure_authenticated_plug.ex:28
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Two-factor authentication enabled, you must use a access token."
-msgstr ""
+msgstr "已启用两因素验证,您需要使用访问令牌。"
#: lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex:210
#, elixir-format
msgid "Unexpected error occurred while adding file to pack."
-msgstr ""
+msgstr "向表情包添加文件时发生了没有预料到的错误。"
#: lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex:138
#, elixir-format
msgid "Unexpected error occurred while creating pack."
-msgstr ""
+msgstr "创建表情包时发生了没有预料到的错误。"
#: lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex:278
#, elixir-format
msgid "Unexpected error occurred while removing file from pack."
-msgstr ""
+msgstr "从表情包移除文件时发生了没有预料到的错误。"
#: lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex:250
#, elixir-format
msgid "Unexpected error occurred while updating file in pack."
-msgstr ""
+msgstr "更新表情包内的文件时发生了没有预料到的错误。"
#: lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex:179
#, elixir-format
msgid "Unexpected error occurred while updating pack metadata."
-msgstr ""
+msgstr "更新表情包元数据时发生了没有预料到的错误。"
#: lib/pleroma/web/mastodon_api/controllers/subscription_controller.ex:61
-#, elixir-format
+#, elixir-format, fuzzy
msgid "Web push subscription is disabled on this Pleroma instance"
-msgstr ""
+msgstr "此 Pleroma 实例禁用了网页推送订阅"
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:451
#, elixir-format
msgid "You can't revoke your own admin/moderator status."
-msgstr ""
+msgstr "您不能撤消自己的管理员权限。"
#: lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex:126
#, elixir-format
msgid "authorization required for timeline view"
-msgstr ""
+msgstr "浏览时间线需要认证"
#: lib/pleroma/web/mastodon_api/controllers/fallback_controller.ex:24
#, elixir-format
msgid "Access denied"
-msgstr ""
+msgstr "拒绝访问"
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:282
#, elixir-format
msgid "This API requires an authenticated user"
-msgstr ""
+msgstr "此 API 需要已认证的用户"
#: lib/pleroma/plugs/user_is_admin_plug.ex:21
#, elixir-format
msgid "User is not an admin."
-msgstr ""
+msgstr "该用户不是管理员。"
diff --git a/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
new file mode 100644
index 000000000..560cc7447
--- /dev/null
+++ b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
@@ -0,0 +1,13 @@
+defmodule Pleroma.Repo.Migrations.DataMigrationProlongOAuthTokensValidUntil do
+ use Ecto.Migration
+
+ def up do
+ expires_in = Pleroma.Config.get!([:oauth2, :token_expires_in])
+ valid_until = NaiveDateTime.add(NaiveDateTime.utc_now(), expires_in, :second)
+ execute("update oauth_tokens set valid_until = '#{valid_until}'")
+ end
+
+ def down do
+ :noop
+ end
+end
diff --git a/priv/repo/migrations/20201231185546_confirm_logged_in_users.exs b/priv/repo/migrations/20201231185546_confirm_logged_in_users.exs
new file mode 100644
index 000000000..de2f35169
--- /dev/null
+++ b/priv/repo/migrations/20201231185546_confirm_logged_in_users.exs
@@ -0,0 +1,22 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.ConfirmLoggedInUsers do
+ use Ecto.Migration
+ import Ecto.Query
+ alias Pleroma.Repo
+ alias Pleroma.User
+ alias Pleroma.Web.OAuth.Token
+
+ def up do
+ User
+ |> where([u], u.confirmation_pending == true)
+ |> join(:inner, [u], t in Token, on: t.user_id == u.id)
+ |> Repo.update_all(set: [confirmation_pending: false])
+ end
+
+ def down do
+ :noop
+ end
+end
diff --git a/priv/static/emoji/dino walking.gif b/priv/static/emoji/dino walking.gif
new file mode 100644
index 000000000..694a541e7
Binary files /dev/null and b/priv/static/emoji/dino walking.gif differ
diff --git a/priv/static/images/logo.png b/priv/static/images/logo.png
new file mode 100644
index 000000000..7744b1acc
Binary files /dev/null and b/priv/static/images/logo.png differ
diff --git a/priv/templates/sample_config.eex b/priv/templates/sample_config.eex
index cdddc47ea..2f5952ef1 100644
--- a/priv/templates/sample_config.eex
+++ b/priv/templates/sample_config.eex
@@ -32,8 +32,7 @@ config :pleroma, Pleroma.Repo,
username: "<%= dbuser %>",
password: "<%= dbpass %>",
database: "<%= dbname %>",
- hostname: "<%= dbhost %>",
- pool_size: 10
+ hostname: "<%= dbhost %>"
# Configure web push notifications
config :web_push_encryption, :vapid_details,
diff --git a/test/fixtures/guppe-actor.json b/test/fixtures/guppe-actor.json
new file mode 100644
index 000000000..d5829ee1f
--- /dev/null
+++ b/test/fixtures/guppe-actor.json
@@ -0,0 +1,26 @@
+{
+ "@context" : [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1"
+ ],
+ "followers" : "https://gup.pe/u/bernie2020/followers",
+ "following" : "https://gup.pe/u/bernie2020/following",
+ "icon" : {
+ "mediaType" : "image/jpeg",
+ "type" : "Image",
+ "url" : "https://gup.pe/f/guppe.png"
+ },
+ "id" : "https://gup.pe/u/bernie2020",
+ "inbox" : "https://gup.pe/u/bernie2020/inbox",
+ "liked" : "https://gup.pe/u/bernie2020/liked",
+ "name" : "Bernie2020 group",
+ "outbox" : "https://gup.pe/u/bernie2020/outbox",
+ "preferredUsername" : "Bernie2020",
+ "publicKey" : {
+ "id" : "https://gup.pe/u/bernie2020#main-key",
+ "owner" : "https://gup.pe/u/bernie2020",
+ "publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw4J8nSrdWWxFaipgWDhR\nbTFzHUGoFy7Gjdc6gg9ZWGWDm9ZU5Ct0C/4o72dXSWdyLbQGYMbWVHLI1LHWKSiC\nVtwIYoccQBaxfi5bCxsahWhhSNPfK8tVlySHvBy73ir8KUZm93eAYh1iE9x+Dk63\nInmi7wzjsqHSlu1KxPGYcnyxs+xxhlTUSd5LsPfO1b9sHMW+X4rEky7OC90veCdD\nsoHU+nCmf+2zJSlOrU7DAzqB4Axc9oS9Q5RlT3yARJQMeu6JyjJJP9CMbpGFbUNT\n5Gsw0km1Rc1rR4tUoz8pLUYtliEUK+/0EmHi2EHAT1ueEfMoGGbCaX/mCoMmAwYJ\nwIGYXmKn2/ARIJpw2XPmrKWXqa2AndOQdb3l44Sl3ej2rC/JQmimGCn7tbfKEZyC\n6mMkOYTIeBtyW/wXFc1+GzJxtvA3C9HjilE+O/7gLHfCLP6FRIxg/9kOLhEj64Ed\n5HZ3sylvifXXubS/lLZr6sZW6d9ICoYLZpFw9AoF2zaYWpvJqBrWinnCJzvbMCYj\nfq/RAkcQYSxkDOHquiGgbRZHGAMKLnz5fMKJIzBtdQojYCUmB14OArW+ITUE9i2a\nPAJaXEGZ+BHYp/0ScFaXwp5LIgT1S+sPKxWJU//77wQfs25i7NZHSN/jtXVmsFS6\nLFVw49LcWAz3J2Im+A+uSd8CAwEAAQ==\n-----END PUBLIC KEY-----\n"
+ },
+ "summary" : "I'm a group about Bernie2020. Follow me to get all the group posts. Tag me to share with the group. Create other groups by searching for or tagging @yourGroupName@gup.pe",
+ "type" : "Group"
+}
diff --git a/test/mix/tasks/pleroma/count_statuses_test.exs b/test/mix/tasks/pleroma/count_statuses_test.exs
index c5cd16960..8fe3959ea 100644
--- a/test/mix/tasks/pleroma/count_statuses_test.exs
+++ b/test/mix/tasks/pleroma/count_statuses_test.exs
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.CountStatusesTest do
+ # Uses log capture, has to stay synchronous
use Pleroma.DataCase
alias Pleroma.User
diff --git a/test/mix/tasks/pleroma/database_test.exs b/test/mix/tasks/pleroma/database_test.exs
index a4bd41922..eefb12426 100644
--- a/test/mix/tasks/pleroma/database_test.exs
+++ b/test/mix/tasks/pleroma/database_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.DatabaseTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
use Oban.Testing, repo: Pleroma.Repo
alias Pleroma.Activity
@@ -87,7 +87,8 @@ test "following and followers count are updated" do
assert user.follower_count == 3
- assert :ok == Mix.Tasks.Pleroma.Database.run(["update_users_following_followers_counts"])
+ assert {:ok, :ok} ==
+ Mix.Tasks.Pleroma.Database.run(["update_users_following_followers_counts"])
user = User.get_by_id(user.id)
diff --git a/test/mix/tasks/pleroma/ecto/migrate_test.exs b/test/mix/tasks/pleroma/ecto/migrate_test.exs
index 43df176a1..548357508 100644
--- a/test/mix/tasks/pleroma/ecto/migrate_test.exs
+++ b/test/mix/tasks/pleroma/ecto/migrate_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-onl
defmodule Mix.Tasks.Pleroma.Ecto.MigrateTest do
- use Pleroma.DataCase, async: true
+ use Pleroma.DataCase
import ExUnit.CaptureLog
require Logger
diff --git a/test/mix/tasks/pleroma/ecto/rollback_test.exs b/test/mix/tasks/pleroma/ecto/rollback_test.exs
index 0236e35d5..9e39db8fa 100644
--- a/test/mix/tasks/pleroma/ecto/rollback_test.exs
+++ b/test/mix/tasks/pleroma/ecto/rollback_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.Ecto.RollbackTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import ExUnit.CaptureLog
require Logger
diff --git a/test/mix/tasks/pleroma/instance_test.exs b/test/mix/tasks/pleroma/instance_test.exs
index 6580fc932..1d2dde108 100644
--- a/test/mix/tasks/pleroma/instance_test.exs
+++ b/test/mix/tasks/pleroma/instance_test.exs
@@ -3,7 +3,8 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.InstanceTest do
- use ExUnit.Case
+ # Modifies the Application Environment, has to stay synchronous.
+ use Pleroma.DataCase
setup do
File.mkdir_p!(tmp_path())
@@ -15,15 +16,17 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
if File.exists?(static_dir) do
File.rm_rf(Path.join(static_dir, "robots.txt"))
end
-
- Pleroma.Config.put([:instance, :static_dir], static_dir)
end)
+ # Is being modified by the mix task.
+ clear_config([:instance, :static_dir])
+
:ok
end
+ @uuid Ecto.UUID.generate()
defp tmp_path do
- "/tmp/generated_files/"
+ "/tmp/generated_files/#{@uuid}/"
end
test "running gen" do
diff --git a/test/mix/tasks/pleroma/refresh_counter_cache_test.exs b/test/mix/tasks/pleroma/refresh_counter_cache_test.exs
index 6a1a9ac17..e79dc0632 100644
--- a/test/mix/tasks/pleroma/refresh_counter_cache_test.exs
+++ b/test/mix/tasks/pleroma/refresh_counter_cache_test.exs
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.RefreshCounterCacheTest do
+ # Uses log capture, has to stay synchronous
use Pleroma.DataCase
alias Pleroma.Web.CommonAPI
import ExUnit.CaptureIO, only: [capture_io: 1]
diff --git a/test/mix/tasks/pleroma/relay_test.exs b/test/mix/tasks/pleroma/relay_test.exs
index cf48e7dda..b453ed1c6 100644
--- a/test/mix/tasks/pleroma/relay_test.exs
+++ b/test/mix/tasks/pleroma/relay_test.exs
@@ -100,7 +100,7 @@ test "unfollow when relay is dead" do
end)
Pleroma.Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
@@ -137,7 +137,7 @@ test "force unfollow when relay is dead" do
end)
Pleroma.Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance, "--force"])
diff --git a/test/mix/tasks/pleroma/user_test.exs b/test/mix/tasks/pleroma/user_test.exs
index 127771212..9f898d8f3 100644
--- a/test/mix/tasks/pleroma/user_test.exs
+++ b/test/mix/tasks/pleroma/user_test.exs
@@ -114,7 +114,7 @@ test "a remote user's create activity is deleted when the object has been pruned
{:ok, post} = CommonAPI.post(user, %{status: "uguu"})
{:ok, post2} = CommonAPI.post(user2, %{status: "test"})
- obj = Object.normalize(post2)
+ obj = Object.normalize(post2, fetch: false)
{:ok, like_object, meta} = Pleroma.Web.ActivityPub.Builder.like(user, obj)
@@ -130,7 +130,7 @@ test "a remote user's create activity is deleted when the object has been pruned
clear_config([:instance, :federating], true)
- object = Object.normalize(post)
+ object = Object.normalize(post, fetch: false)
Object.prune(object)
with_mock Pleroma.Web.Federator,
@@ -462,24 +462,24 @@ test "it prints an error message when user is not exist" do
end
end
- describe "running toggle_confirmed" do
+ describe "running confirm" do
test "user is confirmed" do
%{id: id, nickname: nickname} = insert(:user, confirmation_pending: false)
- assert :ok = Mix.Tasks.Pleroma.User.run(["toggle_confirmed", nickname])
+ assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
assert_received {:mix_shell, :info, [message]}
- assert message == "#{nickname} needs confirmation."
+ assert message == "#{nickname} doesn't need confirmation."
user = Repo.get(User, id)
- assert user.confirmation_pending
- assert user.confirmation_token
+ refute user.confirmation_pending
+ refute user.confirmation_token
end
test "user is not confirmed" do
%{id: id, nickname: nickname} =
insert(:user, confirmation_pending: true, confirmation_token: "some token")
- assert :ok = Mix.Tasks.Pleroma.User.run(["toggle_confirmed", nickname])
+ assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "#{nickname} doesn't need confirmation."
@@ -489,7 +489,7 @@ test "user is not confirmed" do
end
test "it prints an error message when user is not exist" do
- Mix.Tasks.Pleroma.User.run(["toggle_confirmed", "foo"])
+ Mix.Tasks.Pleroma.User.run(["confirm", "foo"])
assert_received {:mix_shell, :error, [message]}
assert message =~ "No local user"
diff --git a/test/pleroma/activity/ir/topics_test.exs b/test/pleroma/activity/ir/topics_test.exs
index 5e5c2f8da..b464822d9 100644
--- a/test/pleroma/activity/ir/topics_test.exs
+++ b/test/pleroma/activity/ir/topics_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity.Ir.TopicsTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Activity.Ir.Topics
diff --git a/test/pleroma/activity/search_test.exs b/test/pleroma/activity/search_test.exs
index fc910e725..49b7aa292 100644
--- a/test/pleroma/activity/search_test.exs
+++ b/test/pleroma/activity/search_test.exs
@@ -7,7 +7,7 @@ defmodule Pleroma.Activity.SearchTest do
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
test "it finds something" do
user = insert(:user)
diff --git a/test/pleroma/activity_test.exs b/test/pleroma/activity_test.exs
index 105f9f766..acaa9adb4 100644
--- a/test/pleroma/activity_test.exs
+++ b/test/pleroma/activity_test.exs
@@ -25,7 +25,7 @@ test "returns an activity by it's AP id" do
test "returns activities by it's objects AP ids" do
activity = insert(:note_activity)
- object_data = Object.normalize(activity).data
+ object_data = Object.normalize(activity, fetch: false).data
[found_activity] = Activity.get_all_create_by_object_ap_id(object_data["id"])
@@ -34,7 +34,7 @@ test "returns activities by it's objects AP ids" do
test "returns the activity that created an object" do
activity = insert(:note_activity)
- object_data = Object.normalize(activity).data
+ object_data = Object.normalize(activity, fetch: false).data
found_activity = Activity.get_create_by_object_ap_id(object_data["id"])
diff --git a/test/pleroma/application_requirements_test.exs b/test/pleroma/application_requirements_test.exs
index b432dbc37..e3cca5487 100644
--- a/test/pleroma/application_requirements_test.exs
+++ b/test/pleroma/application_requirements_test.exs
@@ -15,6 +15,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
describe "check_repo_pool_size!/1" do
test "raises if the pool size is unexpected" do
clear_config([Pleroma.Repo, :pool_size], 11)
+ clear_config([:dangerzone, :override_repo_pool_size], false)
assert_raise Pleroma.ApplicationRequirements.VerifyError,
"Repo.pool_size different than recommended value.",
diff --git a/test/pleroma/bbs/handler_test.exs b/test/pleroma/bbs/handler_test.exs
index e605c2726..8033828f0 100644
--- a/test/pleroma/bbs/handler_test.exs
+++ b/test/pleroma/bbs/handler_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.BBS.HandlerTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.BBS.Handler
alias Pleroma.Object
@@ -54,7 +54,7 @@ test "posting" do
)
assert activity.actor == user.ap_id
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["content"] == "this is a test post"
end
@@ -63,7 +63,7 @@ test "replying" do
another_user = insert(:user)
{:ok, activity} = CommonAPI.post(another_user, %{status: "this is a test post"})
- activity_object = Object.normalize(activity)
+ activity_object = Object.normalize(activity, fetch: false)
output =
capture_io(fn ->
@@ -82,7 +82,7 @@ test "replying" do
assert reply.actor == user.ap_id
- reply_object_data = Object.normalize(reply).data
+ reply_object_data = Object.normalize(reply, fetch: false).data
assert reply_object_data["content"] == "this is a reply"
assert reply_object_data["inReplyTo"] == activity_object.data["id"]
end
diff --git a/test/pleroma/bookmark_test.exs b/test/pleroma/bookmark_test.exs
index 2726fe7cd..ef090d785 100644
--- a/test/pleroma/bookmark_test.exs
+++ b/test/pleroma/bookmark_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.BookmarkTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Bookmark
alias Pleroma.Web.CommonAPI
diff --git a/test/pleroma/captcha_test.exs b/test/pleroma/captcha_test.exs
index 1b9f4a12f..bde3c72f7 100644
--- a/test/pleroma/captcha_test.exs
+++ b/test/pleroma/captcha_test.exs
@@ -80,7 +80,6 @@ test "validate" do
assert is_binary(answer)
assert :ok = Captcha.validate(token, "63615261b77f5354fb8c4e4986477555", answer)
- Cachex.del(:used_captcha_cache, token)
end
test "doesn't validate invalid answer" do
diff --git a/test/pleroma/chat_test.exs b/test/pleroma/chat_test.exs
index 9e8a9ebf0..1dd04916c 100644
--- a/test/pleroma/chat_test.exs
+++ b/test/pleroma/chat_test.exs
@@ -73,7 +73,8 @@ test "a returning chat will have an updated `update_at` field" do
other_user = insert(:user)
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
- :timer.sleep(1500)
+ {:ok, chat} = time_travel(chat, -2)
+
{:ok, chat_two} = Chat.bump_or_create(user.id, other_user.ap_id)
assert chat.id == chat_two.id
diff --git a/test/pleroma/config_test.exs b/test/pleroma/config_test.exs
index 1556e4237..f524d90dd 100644
--- a/test/pleroma/config_test.exs
+++ b/test/pleroma/config_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ConfigTest do
- use ExUnit.Case
+ use Pleroma.DataCase
test "get/1 with an atom" do
assert Pleroma.Config.get(:instance) == Application.get_env(:pleroma, :instance)
diff --git a/test/pleroma/conversation/participation_test.exs b/test/pleroma/conversation/participation_test.exs
index 5a603dcc1..917fb2b98 100644
--- a/test/pleroma/conversation/participation_test.exs
+++ b/test/pleroma/conversation/participation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Conversation.ParticipationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Conversation
alias Pleroma.Conversation.Participation
@@ -96,12 +96,11 @@ test "it creates a participation for a conversation and a user" do
{:ok, %Participation{} = participation} =
Participation.create_for_user_and_conversation(user, conversation)
+ {:ok, participation} = time_travel(participation, -2)
+
assert participation.user_id == user.id
assert participation.conversation_id == conversation.id
- # Needed because updated_at is accurate down to a second
- :timer.sleep(1000)
-
# Creating again returns the same participation
{:ok, %Participation{} = participation_two} =
Participation.create_for_user_and_conversation(user, conversation)
@@ -176,8 +175,8 @@ test "gets all the participations for a user, ordered by updated at descending"
assert [participation_one, participation_two] = Participation.for_user(user)
- object2 = Pleroma.Object.normalize(activity_two)
- object3 = Pleroma.Object.normalize(activity_three)
+ object2 = Pleroma.Object.normalize(activity_two, fetch: false)
+ object3 = Pleroma.Object.normalize(activity_three, fetch: false)
user = Repo.get(Pleroma.User, user.id)
diff --git a/test/pleroma/conversation_test.exs b/test/pleroma/conversation_test.exs
index 359aa6840..4643140dc 100644
--- a/test/pleroma/conversation_test.exs
+++ b/test/pleroma/conversation_test.exs
@@ -48,7 +48,7 @@ test "public posts don't create conversations" do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "Hey"})
- object = Pleroma.Object.normalize(activity)
+ object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation = Conversation.get_for_ap_id(context)
@@ -64,7 +64,7 @@ test "it creates or updates a conversation and participations for a given DM" do
{:ok, activity} =
CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "direct"})
- object = Pleroma.Object.normalize(activity)
+ object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation =
@@ -86,7 +86,7 @@ test "it creates or updates a conversation and participations for a given DM" do
in_reply_to_status_id: activity.id
})
- object = Pleroma.Object.normalize(activity)
+ object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation_two =
@@ -110,7 +110,7 @@ test "it creates or updates a conversation and participations for a given DM" do
in_reply_to_status_id: activity.id
})
- object = Pleroma.Object.normalize(activity)
+ object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation_three =
diff --git a/test/pleroma/earmark_renderer_test.exs b/test/pleroma/earmark_renderer_test.exs
index 220d97d16..73aaec7f4 100644
--- a/test/pleroma/earmark_renderer_test.exs
+++ b/test/pleroma/earmark_renderer_test.exs
@@ -2,7 +2,7 @@
# Copyright © 2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EarmarkRendererTest do
- use ExUnit.Case
+ use Pleroma.DataCase, async: true
test "Paragraph" do
code = ~s[Hello\n\nWorld!]
diff --git a/test/pleroma/ecto_type/activity_pub/object_validators/date_time_test.exs b/test/pleroma/ecto_type/activity_pub/object_validators/date_time_test.exs
index 812463454..a8471e2e3 100644
--- a/test/pleroma/ecto_type/activity_pub/object_validators/date_time_test.exs
+++ b/test/pleroma/ecto_type/activity_pub/object_validators/date_time_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.DateTimeTest do
alias Pleroma.EctoType.ActivityPub.ObjectValidators.DateTime
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
test "it validates an xsd:Datetime" do
valid_strings = [
diff --git a/test/pleroma/ecto_type/activity_pub/object_validators/object_id_test.exs b/test/pleroma/ecto_type/activity_pub/object_validators/object_id_test.exs
index 732e2365f..3b6006854 100644
--- a/test/pleroma/ecto_type/activity_pub/object_validators/object_id_test.exs
+++ b/test/pleroma/ecto_type/activity_pub/object_validators/object_id_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectIDTest do
alias Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
@uris [
"http://lain.com/users/lain",
diff --git a/test/pleroma/ecto_type/activity_pub/object_validators/recipients_test.exs b/test/pleroma/ecto_type/activity_pub/object_validators/recipients_test.exs
index 2e6a0c83d..b7eb59ab0 100644
--- a/test/pleroma/ecto_type/activity_pub/object_validators/recipients_test.exs
+++ b/test/pleroma/ecto_type/activity_pub/object_validators/recipients_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.RecipientsTest do
alias Pleroma.EctoType.ActivityPub.ObjectValidators.Recipients
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
test "it asserts that all elements of the list are object ids" do
list = ["https://lain.com/users/lain", "invalid"]
diff --git a/test/pleroma/ecto_type/activity_pub/object_validators/safe_text_test.exs b/test/pleroma/ecto_type/activity_pub/object_validators/safe_text_test.exs
index 7eddd2388..154363f68 100644
--- a/test/pleroma/ecto_type/activity_pub/object_validators/safe_text_test.exs
+++ b/test/pleroma/ecto_type/activity_pub/object_validators/safe_text_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.SafeTextTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.EctoType.ActivityPub.ObjectValidators.SafeText
diff --git a/test/pleroma/emails/admin_email_test.exs b/test/pleroma/emails/admin_email_test.exs
index 0da0699cc..9aaf7b04f 100644
--- a/test/pleroma/emails/admin_email_test.exs
+++ b/test/pleroma/emails/admin_email_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.AdminEmailTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Emails.AdminEmail
diff --git a/test/pleroma/emails/user_email_test.exs b/test/pleroma/emails/user_email_test.exs
index a75623bb4..bd21d8dec 100644
--- a/test/pleroma/emails/user_email_test.exs
+++ b/test/pleroma/emails/user_email_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.UserEmailTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Emails.UserEmail
alias Pleroma.Web.Endpoint
@@ -45,4 +45,15 @@ test "build account confirmation email" do
assert email.html_body =~
Router.Helpers.confirm_email_url(Endpoint, :confirm_email, user.id, "conf-token")
end
+
+ test "build approval pending email" do
+ config = Pleroma.Config.get(:instance)
+ user = insert(:user)
+ email = UserEmail.approval_pending_email(user)
+
+ assert email.from == {config[:name], config[:notify_email]}
+ assert email.to == [{user.name, user.email}]
+ assert email.subject == "Your account is awaiting approval"
+ assert email.html_body =~ "Awaiting Approval"
+ end
end
diff --git a/test/pleroma/emoji/formatter_test.exs b/test/pleroma/emoji/formatter_test.exs
index 12af6cd8b..096d23ca6 100644
--- a/test/pleroma/emoji/formatter_test.exs
+++ b/test/pleroma/emoji/formatter_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.Emoji.FormatterTest do
alias Pleroma.Emoji.Formatter
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
describe "emojify" do
test "it adds cool emoji" do
diff --git a/test/pleroma/emoji/pack_test.exs b/test/pleroma/emoji/pack_test.exs
index 70d1eaa1b..158dfee06 100644
--- a/test/pleroma/emoji/pack_test.exs
+++ b/test/pleroma/emoji/pack_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emoji.PackTest do
- use ExUnit.Case, async: true
+ use Pleroma.DataCase
alias Pleroma.Emoji.Pack
@emoji_path Path.join(
diff --git a/test/pleroma/emoji_test.exs b/test/pleroma/emoji_test.exs
index 9cfd7b46b..c99c9ef4c 100644
--- a/test/pleroma/emoji_test.exs
+++ b/test/pleroma/emoji_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EmojiTest do
- use ExUnit.Case
+ use ExUnit.Case, async: true
alias Pleroma.Emoji
describe "is_unicode_emoji?/1" do
diff --git a/test/pleroma/filter_test.exs b/test/pleroma/filter_test.exs
index 0a5c4426a..da9515902 100644
--- a/test/pleroma/filter_test.exs
+++ b/test/pleroma/filter_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FilterTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/following_relationship_test.exs b/test/pleroma/following_relationship_test.exs
index 17a468abb..f0d2c3846 100644
--- a/test/pleroma/following_relationship_test.exs
+++ b/test/pleroma/following_relationship_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FollowingRelationshipTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.FollowingRelationship
alias Pleroma.Web.ActivityPub.InternalFetchActor
diff --git a/test/pleroma/healthcheck_test.exs b/test/pleroma/healthcheck_test.exs
index e341e6983..a1bc25d25 100644
--- a/test/pleroma/healthcheck_test.exs
+++ b/test/pleroma/healthcheck_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HealthcheckTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Healthcheck
test "system_info/0" do
diff --git a/test/pleroma/html_test.exs b/test/pleroma/html_test.exs
index 7d3756884..3a926f077 100644
--- a/test/pleroma/html_test.exs
+++ b/test/pleroma/html_test.exs
@@ -6,7 +6,7 @@ defmodule Pleroma.HTMLTest do
alias Pleroma.HTML
alias Pleroma.Object
alias Pleroma.Web.CommonAPI
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
@@ -175,7 +175,7 @@ test "extracts the url" do
"I think I just found the best github repo https://github.com/komeiji-satori/Dress"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://github.com/komeiji-satori/Dress"
end
@@ -190,7 +190,7 @@ test "skips mentions" do
"@#{other_user.nickname} install misskey! https://github.com/syuilo/misskey/blob/develop/docs/setup.en.md"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://github.com/syuilo/misskey/blob/develop/docs/setup.en.md"
@@ -206,7 +206,7 @@ test "skips hashtags" do
status: "#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
@@ -222,7 +222,7 @@ test "skips microformats hashtags" do
content_type: "text/html"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
@@ -233,7 +233,7 @@ test "does not crash when there is an HTML entity in a link" do
{:ok, activity} = CommonAPI.post(user, %{status: "\"http://cofe.com/?boomer=ok&foo=bar\""})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert {:ok, nil} = HTML.extract_first_external_url_from_object(object)
end
@@ -247,7 +247,7 @@ test "skips attachment links" do
"image.png"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert {:ok, nil} = HTML.extract_first_external_url_from_object(object)
end
diff --git a/test/pleroma/http/adapter_helper/gun_test.exs b/test/pleroma/http/adapter_helper/gun_test.exs
index 80589c73d..487d2e7c1 100644
--- a/test/pleroma/http/adapter_helper/gun_test.exs
+++ b/test/pleroma/http/adapter_helper/gun_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.AdapterHelper.GunTest do
- use ExUnit.Case, async: true
+ use ExUnit.Case
use Pleroma.Tests.Helpers
import Mox
diff --git a/test/pleroma/integration/mastodon_websocket_test.exs b/test/pleroma/integration/mastodon_websocket_test.exs
index bb8e795b7..4a7dbda71 100644
--- a/test/pleroma/integration/mastodon_websocket_test.exs
+++ b/test/pleroma/integration/mastodon_websocket_test.exs
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Integration.MastodonWebsocketTest do
+ # Needs a streamer, needs to stay synchronous
use Pleroma.DataCase
import ExUnit.CaptureLog
diff --git a/test/pleroma/keys_test.exs b/test/pleroma/keys_test.exs
index 9e8528cba..55a7aa1bc 100644
--- a/test/pleroma/keys_test.exs
+++ b/test/pleroma/keys_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.KeysTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Keys
diff --git a/test/pleroma/list_test.exs b/test/pleroma/list_test.exs
index b5572cbae..854e276f1 100644
--- a/test/pleroma/list_test.exs
+++ b/test/pleroma/list_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.ListTest do
alias Pleroma.Repo
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/marker_test.exs b/test/pleroma/marker_test.exs
index 7b3943c7b..3055f1ce2 100644
--- a/test/pleroma/marker_test.exs
+++ b/test/pleroma/marker_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MarkerTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Marker
import Pleroma.Factory
diff --git a/test/pleroma/mfa/backup_codes_test.exs b/test/pleroma/mfa/backup_codes_test.exs
index 41adb1e96..c3eaf40b6 100644
--- a/test/pleroma/mfa/backup_codes_test.exs
+++ b/test/pleroma/mfa/backup_codes_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MFA.BackupCodesTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.MFA.BackupCodes
diff --git a/test/pleroma/mfa/totp_test.exs b/test/pleroma/mfa/totp_test.exs
index 9edb6fd54..8c09bf447 100644
--- a/test/pleroma/mfa/totp_test.exs
+++ b/test/pleroma/mfa/totp_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MFA.TOTPTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.MFA.TOTP
diff --git a/test/pleroma/mfa_test.exs b/test/pleroma/mfa_test.exs
index 8875cefd9..cd1f7d0af 100644
--- a/test/pleroma/mfa_test.exs
+++ b/test/pleroma/mfa_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MFATest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.MFA
diff --git a/test/pleroma/migration_helper/notification_backfill_test.exs b/test/pleroma/migration_helper/notification_backfill_test.exs
index 2a62a2b00..6fe8a11ac 100644
--- a/test/pleroma/migration_helper/notification_backfill_test.exs
+++ b/test/pleroma/migration_helper/notification_backfill_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MigrationHelper.NotificationBackfillTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.MigrationHelper.NotificationBackfill
diff --git a/test/pleroma/moderation_log_test.exs b/test/pleroma/moderation_log_test.exs
index 03b32a060..d1e0e1e6b 100644
--- a/test/pleroma/moderation_log_test.exs
+++ b/test/pleroma/moderation_log_test.exs
@@ -6,7 +6,7 @@ defmodule Pleroma.ModerationLogTest do
alias Pleroma.Activity
alias Pleroma.ModerationLog
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/object_test.exs b/test/pleroma/object_test.exs
index 5d4e6fb84..fe7f37e7c 100644
--- a/test/pleroma/object_test.exs
+++ b/test/pleroma/object_test.exs
@@ -256,23 +256,22 @@ test "With custom base_url" do
end
describe "normalizer" do
- test "fetches unknown objects by default" do
- %Object{} =
- object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367")
-
- assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367"
+ @url "http://mastodon.example.org/@admin/99541947525187367"
+ test "does not fetch unknown objects by default" do
+ assert nil == Object.normalize(@url)
end
- test "fetches unknown objects when fetch_remote is explicitly true" do
- %Object{} =
- object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367", true)
+ test "fetches unknown objects when fetch is explicitly true" do
+ %Object{} = object = Object.normalize(@url, fetch: true)
- assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367"
+ assert object.data["url"] == @url
end
- test "does not fetch unknown objects when fetch_remote is false" do
+ test "does not fetch unknown objects when fetch is false" do
assert is_nil(
- Object.normalize("http://mastodon.example.org/@admin/99541947525187367", false)
+ Object.normalize(@url,
+ fetch: false
+ )
)
end
end
@@ -310,7 +309,10 @@ test "refetches if the time since the last refetch is greater than the interval"
mock_modified: mock_modified
} do
%Object{} =
- object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
+ object =
+ Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
+ fetch: true
+ )
Object.set_cache(object)
@@ -332,7 +334,10 @@ test "refetches if the time since the last refetch is greater than the interval"
test "returns the old object if refetch fails", %{mock_modified: mock_modified} do
%Object{} =
- object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
+ object =
+ Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
+ fetch: true
+ )
Object.set_cache(object)
@@ -355,7 +360,10 @@ test "does not refetch if the time since the last refetch is greater than the in
mock_modified: mock_modified
} do
%Object{} =
- object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
+ object =
+ Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
+ fetch: true
+ )
Object.set_cache(object)
@@ -377,7 +385,10 @@ test "does not refetch if the time since the last refetch is greater than the in
test "preserves internal fields on refetch", %{mock_modified: mock_modified} do
%Object{} =
- object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
+ object =
+ Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
+ fetch: true
+ )
Object.set_cache(object)
diff --git a/test/pleroma/pagination_test.exs b/test/pleroma/pagination_test.exs
index e526f23e8..5ee1e60ae 100644
--- a/test/pleroma/pagination_test.exs
+++ b/test/pleroma/pagination_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.PaginationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/registration_test.exs b/test/pleroma/registration_test.exs
index 7db8e3664..462ab452b 100644
--- a/test/pleroma/registration_test.exs
+++ b/test/pleroma/registration_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.RegistrationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/repo/migrations/confirm_logged_in_users_test.exs b/test/pleroma/repo/migrations/confirm_logged_in_users_test.exs
new file mode 100644
index 000000000..f1fd89113
--- /dev/null
+++ b/test/pleroma/repo/migrations/confirm_logged_in_users_test.exs
@@ -0,0 +1,40 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.ConfirmLoggedInUsersTest do
+ alias Pleroma.Repo
+ alias Pleroma.User
+ use Pleroma.DataCase, async: true
+ import Ecto.Query
+ import Pleroma.Factory
+ import Pleroma.Tests.Helpers
+
+ setup_all do: require_migration("20201231185546_confirm_logged_in_users")
+
+ test "up/0 confirms unconfirmed but previously-logged-in users", %{migration: migration} do
+ insert_list(25, :oauth_token)
+ Repo.update_all(User, set: [confirmation_pending: true])
+ insert_list(5, :user, confirmation_pending: true)
+
+ count =
+ User
+ |> where(confirmation_pending: true)
+ |> Repo.aggregate(:count)
+
+ assert count == 30
+
+ assert {25, nil} == migration.up()
+
+ count =
+ User
+ |> where(confirmation_pending: true)
+ |> Repo.aggregate(:count)
+
+ assert count == 5
+ end
+
+ test "down/0 does nothing", %{migration: migration} do
+ assert :noop == migration.down()
+ end
+end
diff --git a/test/pleroma/repo/migrations/fix_legacy_tags_test.exs b/test/pleroma/repo/migrations/fix_legacy_tags_test.exs
index 432055e45..adfed1142 100644
--- a/test/pleroma/repo/migrations/fix_legacy_tags_test.exs
+++ b/test/pleroma/repo/migrations/fix_legacy_tags_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.Repo.Migrations.FixLegacyTagsTest do
alias Pleroma.User
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
import Pleroma.Tests.Helpers
diff --git a/test/pleroma/repo/migrations/move_welcome_settings_test.exs b/test/pleroma/repo/migrations/move_welcome_settings_test.exs
index 53d05a55a..5dbe9d7b0 100644
--- a/test/pleroma/repo/migrations/move_welcome_settings_test.exs
+++ b/test/pleroma/repo/migrations/move_welcome_settings_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.MoveWelcomeSettingsTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
import Pleroma.Tests.Helpers
alias Pleroma.ConfigDB
diff --git a/test/pleroma/repo_test.exs b/test/pleroma/repo_test.exs
index 155791be2..eaddef3a6 100644
--- a/test/pleroma/repo_test.exs
+++ b/test/pleroma/repo_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.RepoTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.User
diff --git a/test/pleroma/report_note_test.exs b/test/pleroma/report_note_test.exs
index 25c1d6a61..cc4561eea 100644
--- a/test/pleroma/report_note_test.exs
+++ b/test/pleroma/report_note_test.exs
@@ -4,7 +4,7 @@
defmodule Pleroma.ReportNoteTest do
alias Pleroma.ReportNote
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
test "create/3" do
diff --git a/test/pleroma/reverse_proxy_test.exs b/test/pleroma/reverse_proxy_test.exs
index 8df63de65..0a2c169ce 100644
--- a/test/pleroma/reverse_proxy_test.exs
+++ b/test/pleroma/reverse_proxy_test.exs
@@ -3,8 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReverseProxyTest do
- use Pleroma.Web.ConnCase, async: true
-
+ use Pleroma.Web.ConnCase
import ExUnit.CaptureLog
import Mox
diff --git a/test/pleroma/safe_jsonb_set_test.exs b/test/pleroma/safe_jsonb_set_test.exs
index 8b1274545..6d70f1026 100644
--- a/test/pleroma/safe_jsonb_set_test.exs
+++ b/test/pleroma/safe_jsonb_set_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.SafeJsonbSetTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
test "it doesn't wipe the object when asked to set the value to NULL" do
assert %{rows: [[%{"key" => "value", "test" => nil}]]} =
diff --git a/test/pleroma/stats_test.exs b/test/pleroma/stats_test.exs
index 74bf785b0..6c2fd5726 100644
--- a/test/pleroma/stats_test.exs
+++ b/test/pleroma/stats_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.StatsTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/upload/filter/dedupe_test.exs b/test/pleroma/upload/filter/dedupe_test.exs
index 92a3d7df3..6559cbb50 100644
--- a/test/pleroma/upload/filter/dedupe_test.exs
+++ b/test/pleroma/upload/filter/dedupe_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Upload.Filter.DedupeTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Upload
alias Pleroma.Upload.Filter.Dedupe
diff --git a/test/pleroma/upload/filter/exiftool_test.exs b/test/pleroma/upload/filter/exiftool_test.exs
index 6b978b64c..b5a5ba18d 100644
--- a/test/pleroma/upload/filter/exiftool_test.exs
+++ b/test/pleroma/upload/filter/exiftool_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Upload.Filter.ExiftoolTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Upload.Filter
test "apply exiftool filter" do
diff --git a/test/pleroma/uploaders/local_test.exs b/test/pleroma/uploaders/local_test.exs
index 1ce7be485..5b377d580 100644
--- a/test/pleroma/uploaders/local_test.exs
+++ b/test/pleroma/uploaders/local_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Uploaders.LocalTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Uploaders.Local
describe "get_file/1" do
diff --git a/test/pleroma/user/notification_setting_test.exs b/test/pleroma/user/notification_setting_test.exs
index 308da216a..701130380 100644
--- a/test/pleroma/user/notification_setting_test.exs
+++ b/test/pleroma/user/notification_setting_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.NotificationSettingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.User.NotificationSetting
diff --git a/test/pleroma/user/welcome_chat_message_test.exs b/test/pleroma/user/welcome_chat_message_test.exs
index fe26d6e4d..0b744fc1b 100644
--- a/test/pleroma/user/welcome_chat_message_test.exs
+++ b/test/pleroma/user/welcome_chat_message_test.exs
@@ -28,8 +28,10 @@ test "send a chat welcome message" do
{:ok, %Pleroma.Activity{} = activity} = WelcomeChatMessage.post_message(user)
assert user.ap_id in activity.recipients
- assert Pleroma.Object.normalize(activity).data["type"] == "ChatMessage"
- assert Pleroma.Object.normalize(activity).data["content"] == "Hello, welcome to Blob/Cat!"
+ assert Pleroma.Object.normalize(activity, fetch: false).data["type"] == "ChatMessage"
+
+ assert Pleroma.Object.normalize(activity, fetch: false).data["content"] ==
+ "Hello, welcome to Blob/Cat!"
end
end
end
diff --git a/test/pleroma/user/welcome_message_test.exs b/test/pleroma/user/welcome_message_test.exs
index 3cd6f5cb7..a1779ddec 100644
--- a/test/pleroma/user/welcome_message_test.exs
+++ b/test/pleroma/user/welcome_message_test.exs
@@ -28,7 +28,9 @@ test "send a direct welcome message" do
{:ok, %Pleroma.Activity{} = activity} = WelcomeMessage.post_message(user)
assert user.ap_id in activity.recipients
assert activity.data["directMessage"] == true
- assert Pleroma.Object.normalize(activity).data["content"] =~ "Hello. Welcome to Pleroma"
+
+ assert Pleroma.Object.normalize(activity, fetch: false).data["content"] =~
+ "Hello. Welcome to Pleroma"
end
end
end
diff --git a/test/pleroma/user_relationship_test.exs b/test/pleroma/user_relationship_test.exs
index f12406097..da4982065 100644
--- a/test/pleroma/user_relationship_test.exs
+++ b/test/pleroma/user_relationship_test.exs
@@ -5,7 +5,7 @@
defmodule Pleroma.UserRelationshipTest do
alias Pleroma.UserRelationship
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs
index f6d19be5b..60741d255 100644
--- a/test/pleroma/user_test.exs
+++ b/test/pleroma/user_test.exs
@@ -438,7 +438,7 @@ test "it sends a welcome message if it is set" do
activity = Repo.one(Pleroma.Activity)
assert registered_user.ap_id in activity.recipients
- assert Object.normalize(activity).data["content"] =~ "direct message"
+ assert Object.normalize(activity, fetch: false).data["content"] =~ "direct message"
assert activity.actor == welcome_user.ap_id
end
@@ -454,7 +454,7 @@ test "it sends a welcome chat message if it is set" do
activity = Repo.one(Pleroma.Activity)
assert registered_user.ap_id in activity.recipients
- assert Object.normalize(activity).data["content"] =~ "chat message"
+ assert Object.normalize(activity, fetch: false).data["content"] =~ "chat message"
assert activity.actor == welcome_user.ap_id
end
@@ -493,7 +493,7 @@ test "it sends a welcome chat message when Simple policy applied to local instan
activity = Repo.one(Pleroma.Activity)
assert registered_user.ap_id in activity.recipients
- assert Object.normalize(activity).data["content"] =~ "chat message"
+ assert Object.normalize(activity, fetch: false).data["content"] =~ "chat message"
assert activity.actor == welcome_user.ap_id
end
@@ -535,6 +535,22 @@ test "it sends a confirm email" do
|> assert_email_sent()
end
+ test "sends a pending approval email" do
+ clear_config([:instance, :account_approval_required], true)
+
+ {:ok, user} =
+ User.register_changeset(%User{}, @full_user_data)
+ |> User.register()
+
+ ObanHelpers.perform_all()
+
+ assert_email_sent(
+ from: Pleroma.Config.Helpers.sender(),
+ to: {user.name, user.email},
+ subject: "Your account is awaiting approval"
+ )
+ end
+
test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do
Pleroma.Config.put([:instance, :account_activation_required], true)
@@ -1393,6 +1409,98 @@ test "approves a list of users" do
assert false == user.approval_pending
end)
end
+
+ test "it sends welcome email if it is set" do
+ clear_config([:welcome, :email, :enabled], true)
+ clear_config([:welcome, :email, :sender], "tester@test.me")
+
+ user = insert(:user, approval_pending: true)
+ welcome_user = insert(:user, email: "tester@test.me")
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ User.approve(user)
+
+ ObanHelpers.perform_all()
+
+ assert_email_sent(
+ from: {instance_name, welcome_user.email},
+ to: {user.name, user.email},
+ html_body: "Welcome to #{instance_name}"
+ )
+ end
+
+ test "approving an approved user does not trigger post-register actions" do
+ clear_config([:welcome, :email, :enabled], true)
+
+ user = insert(:user, approval_pending: false)
+ User.approve(user)
+
+ ObanHelpers.perform_all()
+
+ assert_no_email_sent()
+ end
+ end
+
+ describe "confirm" do
+ test "confirms a user" do
+ user = insert(:user, confirmation_pending: true)
+ assert true == user.confirmation_pending
+ {:ok, user} = User.confirm(user)
+ assert false == user.confirmation_pending
+ end
+
+ test "confirms a list of users" do
+ unconfirmed_users = [
+ insert(:user, confirmation_pending: true),
+ insert(:user, confirmation_pending: true),
+ insert(:user, confirmation_pending: true)
+ ]
+
+ {:ok, users} = User.confirm(unconfirmed_users)
+
+ assert Enum.count(users) == 3
+
+ Enum.each(users, fn user ->
+ assert false == user.confirmation_pending
+ end)
+ end
+
+ test "sends approval emails when `approval_pending: true`" do
+ admin = insert(:user, is_admin: true)
+ user = insert(:user, confirmation_pending: true, approval_pending: true)
+ User.confirm(user)
+
+ ObanHelpers.perform_all()
+
+ user_email = Pleroma.Emails.UserEmail.approval_pending_email(user)
+ admin_email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
+
+ notify_email = Pleroma.Config.get([:instance, :notify_email])
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ # User approval email
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: user_email.html_body
+ )
+
+ # Admin email
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {admin.name, admin.email},
+ html_body: admin_email.html_body
+ )
+ end
+
+ test "confirming a confirmed user does not trigger post-register actions" do
+ user = insert(:user, confirmation_pending: false, approval_pending: true)
+ User.confirm(user)
+
+ ObanHelpers.perform_all()
+
+ assert_no_email_sent()
+ end
end
describe "delete" do
@@ -1889,24 +1997,6 @@ test "Only includes users with no read notifications" do
end
end
- describe "toggle_confirmation/1" do
- test "if user is confirmed" do
- user = insert(:user, confirmation_pending: false)
- {:ok, user} = User.toggle_confirmation(user)
-
- assert user.confirmation_pending
- assert user.confirmation_token
- end
-
- test "if user is unconfirmed" do
- user = insert(:user, confirmation_pending: true, confirmation_token: "some token")
- {:ok, user} = User.toggle_confirmation(user)
-
- refute user.confirmation_pending
- refute user.confirmation_token
- end
- end
-
describe "ensure_keys_present" do
test "it creates keys for a user and stores them in info" do
user = insert(:user)
diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
index 0063d0482..03aed794f 100644
--- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
@@ -219,7 +219,7 @@ test "it doesn't return a local-only object", %{conn: conn} do
assert Pleroma.Web.ActivityPub.Visibility.is_local_public?(post)
- object = Object.normalize(post, false)
+ object = Object.normalize(post, fetch: false)
uuid = String.split(object.data["id"], "/") |> List.last()
conn =
@@ -712,7 +712,7 @@ test "it rejects reads from other users", %{conn: conn} do
test "it returns a note activity in a collection", %{conn: conn} do
note_activity = insert(:direct_note_activity)
- note_object = Object.normalize(note_activity)
+ note_object = Object.normalize(note_activity, fetch: false)
user = User.get_cached_by_ap_id(hd(note_activity.data["to"]))
conn =
@@ -999,7 +999,7 @@ test "it returns 200 even if there're no activities", %{conn: conn} do
test "it returns a note activity in a collection", %{conn: conn} do
note_activity = insert(:note_activity)
- note_object = Object.normalize(note_activity)
+ note_object = Object.normalize(note_activity, fetch: false)
user = User.get_cached_by_ap_id(note_activity.data["actor"])
conn =
@@ -1073,7 +1073,7 @@ test "it inserts an incoming create activity into the database", %{
assert Activity.get_by_ap_id(result["id"])
assert result["object"]
- assert %Object{data: object} = Object.normalize(result["object"])
+ assert %Object{data: object} = Object.normalize(result["object"], fetch: false)
assert object["content"] == activity["object"]["content"]
end
@@ -1109,7 +1109,7 @@ test "it inserts an incoming sensitive activity into the database", %{
assert Activity.get_by_ap_id(response["id"])
assert response["object"]
- assert %Object{data: response_object} = Object.normalize(response["object"])
+ assert %Object{data: response_object} = Object.normalize(response["object"], fetch: false)
assert response_object["sensitive"] == true
assert response_object["content"] == activity["object"]["content"]
@@ -1137,7 +1137,7 @@ test "it rejects an incoming activity with bogus type", %{conn: conn, activity:
test "it erects a tombstone when receiving a delete activity", %{conn: conn} do
note_activity = insert(:note_activity)
- note_object = Object.normalize(note_activity)
+ note_object = Object.normalize(note_activity, fetch: false)
user = User.get_cached_by_ap_id(note_activity.data["actor"])
data = %{
@@ -1162,7 +1162,7 @@ test "it erects a tombstone when receiving a delete activity", %{conn: conn} do
test "it rejects delete activity of object from other actor", %{conn: conn} do
note_activity = insert(:note_activity)
- note_object = Object.normalize(note_activity)
+ note_object = Object.normalize(note_activity, fetch: false)
user = insert(:user)
data = %{
@@ -1183,7 +1183,7 @@ test "it rejects delete activity of object from other actor", %{conn: conn} do
test "it increases like count when receiving a like action", %{conn: conn} do
note_activity = insert(:note_activity)
- note_object = Object.normalize(note_activity)
+ note_object = Object.normalize(note_activity, fetch: false)
user = User.get_cached_by_ap_id(note_activity.data["actor"])
data = %{
@@ -1240,7 +1240,7 @@ test "it doesn't spreads faulty attributedTo or actor fields", %{
assert cirno_outbox["attributedTo"] == nil
assert cirno_outbox["actor"] == cirno.ap_id
- assert cirno_object = Object.normalize(cirno_outbox["object"])
+ assert cirno_object = Object.normalize(cirno_outbox["object"], fetch: false)
assert cirno_object.data["actor"] == cirno.ap_id
assert cirno_object.data["attributedTo"] == cirno.ap_id
end
@@ -1503,7 +1503,7 @@ test "does not require authentication", %{conn: conn} do
test "it tracks a signed object fetch", %{conn: conn} do
user = insert(:user, local: false)
activity = insert(:note_activity)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
object_path = String.trim_leading(object.data["id"], Pleroma.Web.Endpoint.url())
@@ -1519,7 +1519,7 @@ test "it tracks a signed object fetch", %{conn: conn} do
test "it tracks a signed activity fetch", %{conn: conn} do
user = insert(:user, local: false)
activity = insert(:note_activity)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
activity_path = String.trim_leading(activity.data["id"], Pleroma.Web.Endpoint.url())
@@ -1536,7 +1536,7 @@ test "it tracks a signed object fetch when the json is cached", %{conn: conn} do
user = insert(:user, local: false)
other_user = insert(:user, local: false)
activity = insert(:note_activity)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
object_path = String.trim_leading(object.data["id"], Pleroma.Web.Endpoint.url())
@@ -1560,7 +1560,7 @@ test "it tracks a signed activity fetch when the json is cached", %{conn: conn}
user = insert(:user, local: false)
other_user = insert(:user, local: false)
activity = insert(:note_activity)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
activity_path = String.trim_leading(activity.data["id"], Pleroma.Web.Endpoint.url())
@@ -1650,7 +1650,7 @@ test "POST /api/ap/upload_media", %{conn: conn} do
assert activity_response["actor"] == user.ap_id
assert %Object{data: %{"attachment" => [attachment]}} =
- Object.normalize(activity_response["object"])
+ Object.normalize(activity_response["object"], fetch: false)
assert attachment["type"] == "Document"
assert attachment["name"] == desc
diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs
index 9eb7ae86b..98242ff63 100644
--- a/test/pleroma/web/activity_pub/activity_pub_test.exs
+++ b/test/pleroma/web/activity_pub/activity_pub_test.exs
@@ -190,6 +190,24 @@ test "it returns a user that accepts chat messages" do
assert user.accepts_chat_messages
end
+
+ test "works for guppe actors" do
+ user_id = "https://gup.pe/u/bernie2020"
+
+ Tesla.Mock.mock(fn
+ %{method: :get, url: ^user_id} ->
+ %Tesla.Env{
+ status: 200,
+ body: File.read!("test/fixtures/guppe-actor.json"),
+ headers: [{"content-type", "application/activity+json"}]
+ }
+ end)
+
+ {:ok, user} = ActivityPub.make_user_from_ap_id(user_id)
+
+ assert user.name == "Bernie2020 group"
+ assert user.actor_type == "Group"
+ end
end
test "it fetches the appropriate tag-restricted posts" do
@@ -321,7 +339,7 @@ test "adds a context when none is there" do
}
{:ok, %Activity{} = activity} = ActivityPub.insert(data)
- object = Pleroma.Object.normalize(activity)
+ object = Pleroma.Object.normalize(activity, fetch: false)
assert is_binary(activity.data["context"])
assert is_binary(object.data["context"])
@@ -344,7 +362,7 @@ test "adds an id to a given object if it lacks one and is a note and inserts it
}
{:ok, %Activity{} = activity} = ActivityPub.insert(data)
- assert object = Object.normalize(activity)
+ assert object = Object.normalize(activity, fetch: false)
assert is_binary(object.data["id"])
end
end
@@ -678,7 +696,7 @@ test "doesn't return announce activities with blocked users in 'cc'" do
{:ok, activity_two} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
- assert object = Pleroma.Object.normalize(activity_two)
+ assert object = Pleroma.Object.normalize(activity_two, fetch: false)
data = %{
"actor" => friend.ap_id,
diff --git a/test/pleroma/web/activity_pub/mrf/anti_followbot_policy_test.exs b/test/pleroma/web/activity_pub/mrf/anti_followbot_policy_test.exs
index 3c795f5ac..49bbc271d 100644
--- a/test/pleroma/web/activity_pub/mrf/anti_followbot_policy_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/anti_followbot_policy_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicyTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy
diff --git a/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs b/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs
index 9a283f27d..19ea491c0 100644
--- a/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrependedTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Object
diff --git a/test/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy_test.exs b/test/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy_test.exs
index 86dd9ddae..b5f401ad2 100644
--- a/test/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicyTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy
diff --git a/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs b/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs
index 64ea61dd4..d03456b34 100644
--- a/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicyTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy
test "it clears content object" do
diff --git a/test/pleroma/web/activity_pub/mrf/normalize_markup_test.exs b/test/pleroma/web/activity_pub/mrf/normalize_markup_test.exs
index 9b39c45bd..5fccf7760 100644
--- a/test/pleroma/web/activity_pub/mrf/normalize_markup_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/normalize_markup_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkupTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.MRF.NormalizeMarkup
@html_sample """
diff --git a/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs b/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs
index 3f8222736..7665d00d0 100644
--- a/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs
@@ -6,6 +6,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do
use Pleroma.DataCase
alias Pleroma.Config
+ alias Pleroma.Emoji
alias Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy
setup_all do
@@ -14,55 +15,91 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do
end
setup do
- emoji_path = Path.join(Config.get([:instance, :static_dir]), "emoji/stolen")
- File.rm_rf!(emoji_path)
- File.mkdir!(emoji_path)
+ emoji_path = [:instance, :static_dir] |> Config.get() |> Path.join("emoji/stolen")
- Pleroma.Emoji.reload()
+ Emoji.reload()
+
+ message = %{
+ "type" => "Create",
+ "object" => %{
+ "emoji" => [{"firedfox", "https://example.org/emoji/firedfox.png"}],
+ "actor" => "https://example.org/users/admin"
+ }
+ }
on_exit(fn ->
File.rm_rf!(emoji_path)
end)
- :ok
+ [message: message, path: emoji_path]
end
- test "does nothing by default" do
- installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
- refute "firedfox" in installed_emoji
+ test "does nothing by default", %{message: message} do
+ refute "firedfox" in installed()
- message = %{
- "type" => "Create",
- "object" => %{
- "emoji" => [{"firedfox", "https://example.org/emoji/firedfox.png"}],
- "actor" => "https://example.org/users/admin"
- }
- }
+ assert {:ok, _message} = StealEmojiPolicy.filter(message)
- assert {:ok, message} == StealEmojiPolicy.filter(message)
-
- installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
- refute "firedfox" in installed_emoji
+ refute "firedfox" in installed()
end
- test "Steals emoji on unknown shortcode from allowed remote host" do
- installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
- refute "firedfox" in installed_emoji
+ test "Steals emoji on unknown shortcode from allowed remote host", %{
+ message: message,
+ path: path
+ } do
+ refute "firedfox" in installed()
+ refute File.exists?(path)
- message = %{
- "type" => "Create",
- "object" => %{
- "emoji" => [{"firedfox", "https://example.org/emoji/firedfox.png"}],
- "actor" => "https://example.org/users/admin"
- }
- }
+ clear_config(:mrf_steal_emoji, hosts: ["example.org"], size_limit: 284_468)
- clear_config([:mrf_steal_emoji, :hosts], ["example.org"])
- clear_config([:mrf_steal_emoji, :size_limit], 284_468)
+ assert {:ok, _message} = StealEmojiPolicy.filter(message)
- assert {:ok, message} == StealEmojiPolicy.filter(message)
+ assert "firedfox" in installed()
+ assert File.exists?(path)
- installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
- assert "firedfox" in installed_emoji
+ assert path
+ |> Path.join("firedfox.png")
+ |> File.exists?()
end
+
+ test "reject shortcode", %{message: message} do
+ refute "firedfox" in installed()
+
+ clear_config(:mrf_steal_emoji,
+ hosts: ["example.org"],
+ size_limit: 284_468,
+ rejected_shortcodes: [~r/firedfox/]
+ )
+
+ assert {:ok, _message} = StealEmojiPolicy.filter(message)
+
+ refute "firedfox" in installed()
+ end
+
+ test "reject if size is above the limit", %{message: message} do
+ refute "firedfox" in installed()
+
+ clear_config(:mrf_steal_emoji, hosts: ["example.org"], size_limit: 50_000)
+
+ assert {:ok, _message} = StealEmojiPolicy.filter(message)
+
+ refute "firedfox" in installed()
+ end
+
+ test "reject if host returns error", %{message: message} do
+ refute "firedfox" in installed()
+
+ Tesla.Mock.mock(fn %{method: :get, url: "https://example.org/emoji/firedfox.png"} ->
+ {:ok, %Tesla.Env{status: 404, body: "Not found"}}
+ end)
+
+ clear_config(:mrf_steal_emoji, hosts: ["example.org"], size_limit: 284_468)
+
+ ExUnit.CaptureLog.capture_log(fn ->
+ assert {:ok, _message} = StealEmojiPolicy.filter(message)
+ end) =~ "MRF.StealEmojiPolicy: Failed to fetch https://example.org/emoji/firedfox.png"
+
+ refute "firedfox" in installed()
+ end
+
+ defp installed, do: Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
end
diff --git a/test/pleroma/web/activity_pub/mrf/tag_policy_test.exs b/test/pleroma/web/activity_pub/mrf/tag_policy_test.exs
index ffc30ba62..4f289739f 100644
--- a/test/pleroma/web/activity_pub/mrf/tag_policy_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/tag_policy_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.TagPolicyTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.ActivityPub.MRF.TagPolicy
diff --git a/test/pleroma/web/activity_pub/object_validators/accept_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/accept_validation_test.exs
index d6111ba41..bafa2a672 100644
--- a/test/pleroma/web/activity_pub/object_validators/accept_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/accept_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AcceptValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/announce_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/announce_validation_test.exs
index 4771c4698..da60ac844 100644
--- a/test/pleroma/web/activity_pub/object_validators/announce_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/announce_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Object
alias Pleroma.Web.ActivityPub.Builder
@@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidationTest do
announcer = insert(:user)
{:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
- object = Object.normalize(post_activity, false)
+ object = Object.normalize(post_activity, fetch: false)
{:ok, valid_announce, []} = Builder.announce(announcer, object)
%{
@@ -81,7 +81,7 @@ test "returns an error if the actor can't announce the object", %{
{:ok, post_activity} =
CommonAPI.post(user, %{status: "a secret post", visibility: "private"})
- object = Object.normalize(post_activity, false)
+ object = Object.normalize(post_activity, fetch: false)
# Another user can't announce it
{:ok, announce, []} = Builder.announce(announcer, object, public: false)
diff --git a/test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs
index cc6dab872..1f992b397 100644
--- a/test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNoteValidatorTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.ObjectValidators.ArticleNoteValidator
alias Pleroma.Web.ActivityPub.Utils
diff --git a/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs
index 2e1975a79..45e1d8852 100644
--- a/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidatorTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/block_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/block_validation_test.exs
index c08d4b2e8..d133aeb1a 100644
--- a/test/pleroma/web/activity_pub/object_validators/block_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/block_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.BlockValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
index d7e299224..941a8a3e3 100644
--- a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
@@ -17,7 +17,7 @@ test "it is invalid if the object already exists" do
user = insert(:user)
recipient = insert(:user)
{:ok, activity} = CommonAPI.post_chat_message(user, recipient, "hey")
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
{:ok, create_data, _} = Builder.create(user, object.data, [recipient.ap_id])
diff --git a/test/pleroma/web/activity_pub/object_validators/delete_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/delete_validation_test.exs
index 02683b899..57de83c8a 100644
--- a/test/pleroma/web/activity_pub/object_validators/delete_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/delete_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Object
alias Pleroma.Web.ActivityPub.Builder
diff --git a/test/pleroma/web/activity_pub/object_validators/emoji_react_handling_test.exs b/test/pleroma/web/activity_pub/object_validators/emoji_react_handling_test.exs
index 582e6d785..342cfeef8 100644
--- a/test/pleroma/web/activity_pub/object_validators/emoji_react_handling_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/emoji_react_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/follow_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/follow_validation_test.exs
index 6e1378be2..0f77ac8df 100644
--- a/test/pleroma/web/activity_pub/object_validators/follow_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/follow_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.FollowValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs
index 2c033b7e2..4cda3742d 100644
--- a/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.ObjectValidator
alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/reject_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/reject_validation_test.exs
index 370bb6e5c..69f5e8ac4 100644
--- a/test/pleroma/web/activity_pub/object_validators/reject_validation_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/reject_validation_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.RejectValidationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs b/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs
index 75bbcc4b6..dc85d1ac3 100644
--- a/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs b/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs
index 5e80cf731..2c4a50bfd 100644
--- a/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator
diff --git a/test/pleroma/web/activity_pub/pipeline_test.exs b/test/pleroma/web/activity_pub/pipeline_test.exs
index 210a06563..d568d825b 100644
--- a/test/pleroma/web/activity_pub/pipeline_test.exs
+++ b/test/pleroma/web/activity_pub/pipeline_test.exs
@@ -3,14 +3,35 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.PipelineTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
- import Mock
+ import Mox
import Pleroma.Factory
+ alias Pleroma.ConfigMock
+ alias Pleroma.Web.ActivityPub.ActivityPubMock
+ alias Pleroma.Web.ActivityPub.MRFMock
+ alias Pleroma.Web.ActivityPub.ObjectValidatorMock
+ alias Pleroma.Web.ActivityPub.SideEffectsMock
+ alias Pleroma.Web.FederatorMock
+
+ setup :verify_on_exit!
+
describe "common_pipeline/2" do
setup do
- clear_config([:instance, :federating], true)
+ ObjectValidatorMock
+ |> expect(:validate, fn o, m -> {:ok, o, m} end)
+
+ MRFMock
+ |> expect(:pipeline_filter, fn o, m -> {:ok, o, m} end)
+
+ ActivityPubMock
+ |> expect(:persist, fn o, m -> {:ok, o, m} end)
+
+ SideEffectsMock
+ |> expect(:handle, fn o, m -> {:ok, o, m} end)
+ |> expect(:handle_after_transaction, fn m -> m end)
+
:ok
end
@@ -21,159 +42,53 @@ test "when given an `object_data` in meta, Federation will receive a the origina
activity_with_object = %{activity | data: Map.put(activity.data, "object", object)}
- with_mocks([
- {Pleroma.Web.ActivityPub.ObjectValidator, [], [validate: fn o, m -> {:ok, o, m} end]},
- {
- Pleroma.Web.ActivityPub.MRF,
- [],
- [pipeline_filter: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.ActivityPub,
- [],
- [persist: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.SideEffects,
- [],
- [
- handle: fn o, m -> {:ok, o, m} end,
- handle_after_transaction: fn m -> m end
- ]
- },
- {
- Pleroma.Web.Federator,
- [],
- [publish: fn _o -> :ok end]
- }
- ]) do
- assert {:ok, ^activity, ^meta} =
- Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
+ FederatorMock
+ |> expect(:publish, fn ^activity_with_object -> :ok end)
- assert_called(Pleroma.Web.ActivityPub.ObjectValidator.validate(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.MRF.pipeline_filter(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.ActivityPub.persist(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.SideEffects.handle(activity, meta))
- refute called(Pleroma.Web.Federator.publish(activity))
- assert_called(Pleroma.Web.Federator.publish(activity_with_object))
- end
+ ConfigMock
+ |> expect(:get, fn [:instance, :federating] -> true end)
+
+ assert {:ok, ^activity, ^meta} =
+ Pleroma.Web.ActivityPub.Pipeline.common_pipeline(
+ activity,
+ meta
+ )
end
test "it goes through validation, filtering, persisting, side effects and federation for local activities" do
activity = insert(:note_activity)
meta = [local: true]
- with_mocks([
- {Pleroma.Web.ActivityPub.ObjectValidator, [], [validate: fn o, m -> {:ok, o, m} end]},
- {
- Pleroma.Web.ActivityPub.MRF,
- [],
- [pipeline_filter: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.ActivityPub,
- [],
- [persist: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.SideEffects,
- [],
- [
- handle: fn o, m -> {:ok, o, m} end,
- handle_after_transaction: fn m -> m end
- ]
- },
- {
- Pleroma.Web.Federator,
- [],
- [publish: fn _o -> :ok end]
- }
- ]) do
- assert {:ok, ^activity, ^meta} =
- Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
+ FederatorMock
+ |> expect(:publish, fn ^activity -> :ok end)
- assert_called(Pleroma.Web.ActivityPub.ObjectValidator.validate(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.MRF.pipeline_filter(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.ActivityPub.persist(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.SideEffects.handle(activity, meta))
- assert_called(Pleroma.Web.Federator.publish(activity))
- end
+ ConfigMock
+ |> expect(:get, fn [:instance, :federating] -> true end)
+
+ assert {:ok, ^activity, ^meta} =
+ Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
end
test "it goes through validation, filtering, persisting, side effects without federation for remote activities" do
activity = insert(:note_activity)
meta = [local: false]
- with_mocks([
- {Pleroma.Web.ActivityPub.ObjectValidator, [], [validate: fn o, m -> {:ok, o, m} end]},
- {
- Pleroma.Web.ActivityPub.MRF,
- [],
- [pipeline_filter: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.ActivityPub,
- [],
- [persist: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.SideEffects,
- [],
- [handle: fn o, m -> {:ok, o, m} end, handle_after_transaction: fn m -> m end]
- },
- {
- Pleroma.Web.Federator,
- [],
- []
- }
- ]) do
- assert {:ok, ^activity, ^meta} =
- Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
+ ConfigMock
+ |> expect(:get, fn [:instance, :federating] -> true end)
- assert_called(Pleroma.Web.ActivityPub.ObjectValidator.validate(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.MRF.pipeline_filter(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.ActivityPub.persist(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.SideEffects.handle(activity, meta))
- end
+ assert {:ok, ^activity, ^meta} =
+ Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
end
test "it goes through validation, filtering, persisting, side effects without federation for local activities if federation is deactivated" do
- clear_config([:instance, :federating], false)
-
activity = insert(:note_activity)
meta = [local: true]
- with_mocks([
- {Pleroma.Web.ActivityPub.ObjectValidator, [], [validate: fn o, m -> {:ok, o, m} end]},
- {
- Pleroma.Web.ActivityPub.MRF,
- [],
- [pipeline_filter: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.ActivityPub,
- [],
- [persist: fn o, m -> {:ok, o, m} end]
- },
- {
- Pleroma.Web.ActivityPub.SideEffects,
- [],
- [handle: fn o, m -> {:ok, o, m} end, handle_after_transaction: fn m -> m end]
- },
- {
- Pleroma.Web.Federator,
- [],
- []
- }
- ]) do
- assert {:ok, ^activity, ^meta} =
- Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
+ ConfigMock
+ |> expect(:get, fn [:instance, :federating] -> false end)
- assert_called(Pleroma.Web.ActivityPub.ObjectValidator.validate(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.MRF.pipeline_filter(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.ActivityPub.persist(activity, meta))
- assert_called(Pleroma.Web.ActivityPub.SideEffects.handle(activity, meta))
- end
+ assert {:ok, ^activity, ^meta} =
+ Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
end
end
end
diff --git a/test/pleroma/web/activity_pub/publisher_test.exs b/test/pleroma/web/activity_pub/publisher_test.exs
index 24e373e04..8529911ca 100644
--- a/test/pleroma/web/activity_pub/publisher_test.exs
+++ b/test/pleroma/web/activity_pub/publisher_test.exs
@@ -396,7 +396,7 @@ test "publish to url with with different ports" do
actor = insert(:user)
note_activity = insert(:note_activity, user: actor)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
activity_path = String.trim_leading(note_activity.data["id"], Pleroma.Web.Endpoint.url())
object_path = String.trim_leading(object.data["id"], Pleroma.Web.Endpoint.url())
diff --git a/test/pleroma/web/activity_pub/relay_test.exs b/test/pleroma/web/activity_pub/relay_test.exs
index 3284980f7..a7cd732bb 100644
--- a/test/pleroma/web/activity_pub/relay_test.exs
+++ b/test/pleroma/web/activity_pub/relay_test.exs
@@ -84,7 +84,7 @@ test "force unfollow when target service is dead" do
)
Pleroma.Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
assert {:ok, %Activity{} = activity} = Relay.unfollow(user_ap_id, %{force: true})
diff --git a/test/pleroma/web/activity_pub/side_effects/delete_test.exs b/test/pleroma/web/activity_pub/side_effects/delete_test.exs
new file mode 100644
index 000000000..cb11f93cd
--- /dev/null
+++ b/test/pleroma/web/activity_pub/side_effects/delete_test.exs
@@ -0,0 +1,147 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.SideEffects.DeleteTest do
+ use Oban.Testing, repo: Pleroma.Repo
+ use Pleroma.DataCase, async: true
+
+ alias Pleroma.Activity
+ alias Pleroma.Object
+ alias Pleroma.Repo
+ alias Pleroma.Tests.ObanHelpers
+ alias Pleroma.User
+ alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Web.ActivityPub.Builder
+ alias Pleroma.Web.ActivityPub.SideEffects
+ alias Pleroma.Web.CommonAPI
+
+ alias Pleroma.LoggerMock
+ alias Pleroma.Web.ActivityPub.ActivityPubMock
+
+ import Mox
+ import Pleroma.Factory
+
+ describe "user deletion" do
+ setup do
+ user = insert(:user)
+
+ {:ok, delete_user_data, _meta} = Builder.delete(user, user.ap_id)
+ {:ok, delete_user, _meta} = ActivityPub.persist(delete_user_data, local: true)
+
+ %{
+ user: user,
+ delete_user: delete_user
+ }
+ end
+
+ test "it handles user deletions", %{delete_user: delete, user: user} do
+ {:ok, _delete, _} = SideEffects.handle(delete)
+ ObanHelpers.perform_all()
+
+ assert User.get_cached_by_ap_id(user.ap_id).deactivated
+ end
+ end
+
+ describe "object deletion" do
+ setup do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, op} = CommonAPI.post(other_user, %{status: "big oof"})
+ {:ok, post} = CommonAPI.post(user, %{status: "hey", in_reply_to_id: op})
+ {:ok, favorite} = CommonAPI.favorite(user, post.id)
+ object = Object.normalize(post, fetch: false)
+ {:ok, delete_data, _meta} = Builder.delete(user, object.data["id"])
+ {:ok, delete, _meta} = ActivityPub.persist(delete_data, local: true)
+
+ %{
+ user: user,
+ delete: delete,
+ post: post,
+ object: object,
+ op: op,
+ favorite: favorite
+ }
+ end
+
+ test "it handles object deletions", %{
+ delete: delete,
+ post: post,
+ object: object,
+ user: user,
+ op: op,
+ favorite: favorite
+ } do
+ object_id = object.id
+ user_id = user.id
+
+ ActivityPubMock
+ |> expect(:stream_out, fn ^delete -> nil end)
+ |> expect(:stream_out_participations, fn %Object{id: ^object_id}, %User{id: ^user_id} ->
+ nil
+ end)
+
+ {:ok, _delete, _} = SideEffects.handle(delete)
+ user = User.get_cached_by_ap_id(object.data["actor"])
+
+ object = Object.get_by_id(object.id)
+ assert object.data["type"] == "Tombstone"
+ refute Activity.get_by_id(post.id)
+ refute Activity.get_by_id(favorite.id)
+
+ user = User.get_by_id(user.id)
+ assert user.note_count == 0
+
+ object = Object.normalize(op.data["object"], fetch: false)
+
+ assert object.data["repliesCount"] == 0
+ end
+
+ test "it handles object deletions when the object itself has been pruned", %{
+ delete: delete,
+ post: post,
+ object: object,
+ user: user,
+ op: op
+ } do
+ object_id = object.id
+ user_id = user.id
+
+ ActivityPubMock
+ |> expect(:stream_out, fn ^delete -> nil end)
+ |> expect(:stream_out_participations, fn %Object{id: ^object_id}, %User{id: ^user_id} ->
+ nil
+ end)
+
+ {:ok, _delete, _} = SideEffects.handle(delete)
+ user = User.get_cached_by_ap_id(object.data["actor"])
+
+ object = Object.get_by_id(object.id)
+ assert object.data["type"] == "Tombstone"
+ refute Activity.get_by_id(post.id)
+
+ user = User.get_by_id(user.id)
+ assert user.note_count == 0
+
+ object = Object.normalize(op.data["object"], fetch: false)
+
+ assert object.data["repliesCount"] == 0
+ end
+
+ test "it logs issues with objects deletion", %{
+ delete: delete,
+ object: object
+ } do
+ {:ok, _object} =
+ object
+ |> Object.change(%{data: Map.delete(object.data, "actor")})
+ |> Repo.update()
+
+ LoggerMock
+ |> expect(:error, fn str -> assert str =~ "The object doesn't have an actor" end)
+
+ {:error, :no_object_actor} = SideEffects.handle(delete)
+ end
+ end
+end
diff --git a/test/pleroma/web/activity_pub/side_effects_test.exs b/test/pleroma/web/activity_pub/side_effects_test.exs
index 297fc0b84..50af7a507 100644
--- a/test/pleroma/web/activity_pub/side_effects_test.exs
+++ b/test/pleroma/web/activity_pub/side_effects_test.exs
@@ -19,7 +19,6 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
alias Pleroma.Web.ActivityPub.SideEffects
alias Pleroma.Web.CommonAPI
- import ExUnit.CaptureLog
import Mock
import Pleroma.Factory
@@ -131,115 +130,6 @@ test "it uses a given changeset to update", %{user: user, update: update} do
end
end
- describe "delete objects" do
- setup do
- user = insert(:user)
- other_user = insert(:user)
-
- {:ok, op} = CommonAPI.post(other_user, %{status: "big oof"})
- {:ok, post} = CommonAPI.post(user, %{status: "hey", in_reply_to_id: op})
- {:ok, favorite} = CommonAPI.favorite(user, post.id)
- object = Object.normalize(post)
- {:ok, delete_data, _meta} = Builder.delete(user, object.data["id"])
- {:ok, delete_user_data, _meta} = Builder.delete(user, user.ap_id)
- {:ok, delete, _meta} = ActivityPub.persist(delete_data, local: true)
- {:ok, delete_user, _meta} = ActivityPub.persist(delete_user_data, local: true)
-
- %{
- user: user,
- delete: delete,
- post: post,
- object: object,
- delete_user: delete_user,
- op: op,
- favorite: favorite
- }
- end
-
- test "it handles object deletions", %{
- delete: delete,
- post: post,
- object: object,
- user: user,
- op: op,
- favorite: favorite
- } do
- with_mock Pleroma.Web.ActivityPub.ActivityPub, [:passthrough],
- stream_out: fn _ -> nil end,
- stream_out_participations: fn _, _ -> nil end do
- {:ok, delete, _} = SideEffects.handle(delete)
- user = User.get_cached_by_ap_id(object.data["actor"])
-
- assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out(delete))
- assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out_participations(object, user))
- end
-
- object = Object.get_by_id(object.id)
- assert object.data["type"] == "Tombstone"
- refute Activity.get_by_id(post.id)
- refute Activity.get_by_id(favorite.id)
-
- user = User.get_by_id(user.id)
- assert user.note_count == 0
-
- object = Object.normalize(op.data["object"], false)
-
- assert object.data["repliesCount"] == 0
- end
-
- test "it handles object deletions when the object itself has been pruned", %{
- delete: delete,
- post: post,
- object: object,
- user: user,
- op: op
- } do
- with_mock Pleroma.Web.ActivityPub.ActivityPub, [:passthrough],
- stream_out: fn _ -> nil end,
- stream_out_participations: fn _, _ -> nil end do
- {:ok, delete, _} = SideEffects.handle(delete)
- user = User.get_cached_by_ap_id(object.data["actor"])
-
- assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out(delete))
- assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out_participations(object, user))
- end
-
- object = Object.get_by_id(object.id)
- assert object.data["type"] == "Tombstone"
- refute Activity.get_by_id(post.id)
-
- user = User.get_by_id(user.id)
- assert user.note_count == 0
-
- object = Object.normalize(op.data["object"], false)
-
- assert object.data["repliesCount"] == 0
- end
-
- test "it handles user deletions", %{delete_user: delete, user: user} do
- {:ok, _delete, _} = SideEffects.handle(delete)
- ObanHelpers.perform_all()
-
- assert User.get_cached_by_ap_id(user.ap_id).deactivated
- end
-
- test "it logs issues with objects deletion", %{
- delete: delete,
- object: object
- } do
- {:ok, object} =
- object
- |> Object.change(%{data: Map.delete(object.data, "actor")})
- |> Repo.update()
-
- Object.invalid_object_cache(object)
-
- assert capture_log(fn ->
- {:error, :no_object_actor} = SideEffects.handle(delete)
- end) =~ "object doesn't have an actor"
- end
- end
-
describe "EmojiReact objects" do
setup do
poster = insert(:user)
diff --git a/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs
index 485216487..d356fcc72 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Transmogrifier
diff --git a/test/pleroma/web/activity_pub/transmogrifier/announce_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/announce_handling_test.exs
index c06bbc5e9..6ec7e1a0a 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/announce_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/announce_handling_test.exs
@@ -130,7 +130,7 @@ test "it works for incoming announces with an inlined activity" do
assert data["id"] ==
"http://mastodon.example.org/users/admin/statuses/99542391527669785/activity"
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert object.data["id"] == "http://mastodon.example.org/@admin/99541947525187368"
assert object.data["content"] == "this is a private toot"
@@ -158,7 +158,7 @@ test "it does not clobber the addressing on announce activities" do
data =
File.read!("test/fixtures/mastodon-announce.json")
|> Jason.decode!()
- |> Map.put("object", Object.normalize(activity).data["id"])
+ |> Map.put("object", Object.normalize(activity, fetch: false).data["id"])
|> Map.put("to", ["http://mastodon.example.org/users/admin/followers"])
|> Map.put("cc", [])
diff --git a/test/pleroma/web/activity_pub/transmogrifier/answer_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/answer_handling_test.exs
index a1c2ba28a..c6483ccaf 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/answer_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/answer_handling_test.exs
@@ -26,7 +26,7 @@ test "incoming, rewrites Note to Answer and increments vote counters" do
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["repliesCount"] == nil
data =
@@ -37,7 +37,7 @@ test "incoming, rewrites Note to Answer and increments vote counters" do
|> Kernel.put_in(["object", "to"], user.ap_id)
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- answer_object = Object.normalize(activity)
+ answer_object = Object.normalize(activity, fetch: false)
assert answer_object.data["type"] == "Answer"
assert answer_object.data["inReplyTo"] == object.data["id"]
@@ -62,7 +62,7 @@ test "outgoing, rewrites Answer to Note" do
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
})
- poll_object = Object.normalize(poll_activity)
+ poll_object = Object.normalize(poll_activity, fetch: false)
# TODO: Replace with CommonAPI vote creation when implemented
data =
File.read!("test/fixtures/mastodon-vote.json")
diff --git a/test/pleroma/web/activity_pub/transmogrifier/article_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/article_handling_test.exs
index b0ae804c5..26216f7fc 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/article_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/article_handling_test.exs
@@ -25,7 +25,7 @@ test "Pterotype (Wordpress Plugin) Article" do
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert object.data["name"] == "The end is near: Mastodon plans to drop OStatus support"
@@ -75,7 +75,7 @@ test "Prismo Article" do
data = File.read!("test/fixtures/prismo-url-map.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert object.data["url"] == "https://prismo.news/posts/83"
end
diff --git a/test/pleroma/web/activity_pub/transmogrifier/audio_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/audio_handling_test.exs
index 7a2ac5d4d..ac80d0ddd 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/audio_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/audio_handling_test.exs
@@ -35,7 +35,7 @@ test "it works for incoming listens" do
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["title"] == "lain radio episode 1"
assert object.data["artist"] == "lain"
@@ -57,7 +57,7 @@ test "Funkwhale Audio object" do
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- assert object = Object.normalize(activity, false)
+ assert object = Object.normalize(activity, fetch: false)
assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
diff --git a/test/pleroma/web/activity_pub/transmogrifier/block_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/block_handling_test.exs
index 679c33c6c..6adad88f5 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/block_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/block_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Transmogrifier.BlockHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.User
diff --git a/test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs
index cffaa7c44..6dd508894 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs
@@ -40,7 +40,7 @@ test "it works for incoming deletes" do
assert actor == deleting_user.ap_id
# Objects are replaced by a tombstone object.
- object = Object.normalize(activity.data["object"])
+ object = Object.normalize(activity.data["object"], fetch: false)
assert object.data["type"] == "Tombstone"
end
@@ -48,9 +48,10 @@ test "it works for incoming when the object has been pruned" do
activity = insert(:note_activity)
{:ok, object} =
- Object.normalize(activity.data["object"])
+ Object.normalize(activity.data["object"], fetch: false)
|> Repo.delete()
+ # TODO: mock cachex
Cachex.del(:object_cache, "object:#{object.data["id"]}")
deleting_user = insert(:user)
diff --git a/test/pleroma/web/activity_pub/transmogrifier/emoji_react_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/emoji_react_handling_test.exs
index aea4ed6f8..1ebf6b1e8 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/emoji_react_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/emoji_react_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Object
diff --git a/test/pleroma/web/activity_pub/transmogrifier/like_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/like_handling_test.exs
index 967bad151..35211b8f2 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/like_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/like_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Web.ActivityPub.Transmogrifier
diff --git a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs
index b4a006aec..b61e5013a 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs
@@ -28,7 +28,7 @@ test "it works for incoming notices with tag not being an array (kroeg)" do
data = File.read!("test/fixtures/kroeg-array-less-emoji.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert object.data["emoji"] == %{
"icon_e_smile" => "https://puckipedia.com/forum/images/smilies/icon_e_smile.png"
@@ -37,7 +37,7 @@ test "it works for incoming notices with tag not being an array (kroeg)" do
data = File.read!("test/fixtures/kroeg-array-less-hashtag.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert "test" in object.data["tag"]
end
@@ -66,7 +66,7 @@ test "it cleans up incoming notices which are not really DMs" do
assert data["to"] == []
assert data["cc"] == to
- object_data = Object.normalize(activity).data
+ object_data = Object.normalize(activity, fetch: false).data
assert object_data["to"] == []
assert object_data["cc"] == to
@@ -78,7 +78,7 @@ test "it ignores an incoming notice if we already have it" do
data =
File.read!("test/fixtures/mastodon-post-activity.json")
|> Jason.decode!()
- |> Map.put("object", Object.normalize(activity).data)
+ |> Map.put("object", Object.normalize(activity, fetch: false).data)
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
@@ -97,7 +97,7 @@ test "it fetches reply-to activities if we don't have them" do
data = Map.put(data, "object", object)
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
- returned_object = Object.normalize(returned_activity, false)
+ returned_object = Object.normalize(returned_activity, fetch: false)
assert %Activity{} =
Activity.get_create_by_object_ap_id(
@@ -123,7 +123,7 @@ test "it does not fetch reply-to activities beyond max replies depth limit" do
allowed_thread_distance?: fn _ -> false end do
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
- returned_object = Object.normalize(returned_activity, false)
+ returned_object = Object.normalize(returned_activity, fetch: false)
refute Activity.get_create_by_object_ap_id(
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
@@ -179,7 +179,7 @@ test "it works for incoming notices" do
assert data["actor"] == "http://mastodon.example.org/users/admin"
- object_data = Object.normalize(data["object"]).data
+ object_data = Object.normalize(data["object"], fetch: false).data
assert object_data["id"] ==
"http://mastodon.example.org/users/admin/statuses/99512778738411822"
@@ -209,7 +209,7 @@ test "it works for incoming notices without the sensitive property but an nsfw h
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object_data = Object.normalize(data["object"], false).data
+ object_data = Object.normalize(data["object"], fetch: false).data
assert object_data["sensitive"] == true
end
@@ -218,7 +218,7 @@ test "it works for incoming notices with hashtags" do
data = File.read!("test/fixtures/mastodon-post-activity-hashtag.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert Enum.at(object.data["tag"], 2) == "moo"
end
@@ -227,7 +227,7 @@ test "it works for incoming notices with contentMap" do
data = File.read!("test/fixtures/mastodon-post-activity-contentmap.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert object.data["content"] ==
"@lain
"
@@ -237,7 +237,7 @@ test "it works for incoming notices with to/cc not being an array (kroeg)" do
data = File.read!("test/fixtures/kroeg-post-activity.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(data["object"])
+ object = Object.normalize(data["object"], fetch: false)
assert object.data["content"] ==
"henlo from my Psion netBook
message sent from my Psion netBook
"
@@ -725,7 +725,7 @@ test "sets `replies` collection with a limited number of self-replies" do
in_reply_to_status_id: id1
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
replies_uris = Enum.map([self_reply1, self_reply2], fn a -> a.object.data["id"] end)
assert %{"type" => "Collection", "items" => ^replies_uris} =
diff --git a/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs
index 47f92cf4d..ae470f984 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs
@@ -22,7 +22,7 @@ test "Mastodon Question activity" do
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert object.data["url"] == "https://mastodon.sdf.org/@rinpatch/102070944809637304"
@@ -65,7 +65,7 @@ test "Mastodon Question activity" do
{:ok, reply_activity} = CommonAPI.post(user, %{status: "hewwo", in_reply_to_id: activity.id})
- reply_object = Object.normalize(reply_activity, false)
+ reply_object = Object.normalize(reply_activity, fetch: false)
assert reply_object.data["context"] == object.data["context"]
assert reply_object.data["context_id"] == object.data["context_id"]
@@ -101,7 +101,7 @@ test "Mastodon Question activity with HTML tags in plaintext" do
|> Kernel.put_in(["object", "oneOf"], options)
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert Enum.sort(object.data["oneOf"]) == Enum.sort(options)
end
@@ -147,7 +147,7 @@ test "Mastodon Question activity with custom emojis" do
|> Kernel.put_in(["object", "tag"], tag)
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert object.data["oneOf"] == options
diff --git a/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs
index 5a3bef792..851236758 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.User
diff --git a/test/pleroma/web/activity_pub/transmogrifier/undo_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/undo_handling_test.exs
index fcfc7b4b6..107121ef8 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/undo_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/undo_handling_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Object
diff --git a/test/pleroma/web/activity_pub/transmogrifier/user_update_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/user_update_handling_test.exs
index c62d5e139..8ed5e5e90 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/user_update_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/user_update_handling_test.exs
@@ -103,7 +103,7 @@ test "it works with custom profile fields" do
%{"name" => "foo1", "value" => "updated"}
]
- Pleroma.Config.put([:instance, :max_remote_account_fields], 2)
+ clear_config([:instance, :max_remote_account_fields], 2)
update_data =
update_data
diff --git a/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs
index 57411fafa..be4ac4c13 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs
@@ -24,7 +24,7 @@ test "skip converting the content when it is nil" do
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- assert object = Object.normalize(activity, false)
+ assert object = Object.normalize(activity, fetch: false)
assert object.data["content"] == nil
end
@@ -34,7 +34,7 @@ test "it converts content of object to html" do
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- assert object = Object.normalize(activity, false)
+ assert object = Object.normalize(activity, fetch: false)
assert object.data["content"] ==
"Après avoir mené avec un certain succès la campagne « Dégooglisons Internet » en 2014, l’association Framasoft annonce fin 2019 arrêter progressivement un certain nombre de ses services alternatifs aux GAFAM. Pourquoi ?
Transcription par @aprilorg ici : https://www.april.org/deframasoftisons-internet-pierre-yves-gosset-framasoft
"
@@ -70,7 +70,7 @@ test "it remaps video URLs as attachments if necessary" do
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
- assert object = Object.normalize(activity, false)
+ assert object = Object.normalize(activity, fetch: false)
assert object.data["attachment"] == [
%{
diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs
index 66ea7664a..c32ea9ae4 100644
--- a/test/pleroma/web/activity_pub/transmogrifier_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs
@@ -56,7 +56,7 @@ test "it accepts Flag activities" do
other_user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
note_obj = %{
"type" => "Note",
@@ -281,6 +281,21 @@ test "it can handle Listen activities" do
{:ok, _modified} = Transmogrifier.prepare_outgoing(activity.data)
end
+
+ test "custom emoji urls are URI encoded" do
+ # :dinosaur: filename has a space -> dino walking.gif
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
+
+ {:ok, prepared} = Transmogrifier.prepare_outgoing(activity.data)
+
+ assert length(prepared["object"]["tag"]) == 1
+
+ url = prepared["object"]["tag"] |> List.first() |> Map.get("icon") |> Map.get("url")
+
+ assert url == "http://localhost:4001/emoji/dino%20walking.gif"
+ end
end
describe "user upgrade" do
diff --git a/test/pleroma/web/activity_pub/utils_test.exs b/test/pleroma/web/activity_pub/utils_test.exs
index be9cd7d13..83668caa4 100644
--- a/test/pleroma/web/activity_pub/utils_test.exs
+++ b/test/pleroma/web/activity_pub/utils_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.UtilsTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Object
alias Pleroma.Repo
@@ -165,7 +165,7 @@ test "fetches existing votes" do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, votes, object} = CommonAPI.vote(other_user, object, [0, 1])
assert Enum.sort(Utils.get_existing_votes(other_user.ap_id, object)) == Enum.sort(votes)
end
@@ -183,7 +183,7 @@ test "fetches only Create activities" do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, [vote], object} = CommonAPI.vote(other_user, object, [0])
{:ok, _activity} = CommonAPI.favorite(user, activity.id)
[fetched_vote] = Utils.get_existing_votes(other_user.ap_id, object)
@@ -242,7 +242,7 @@ test "updates the state of the given follow activity" do
test "updates likes" do
user = insert(:user)
activity = insert(:note_activity)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert {:ok, updated_object} =
Utils.update_element_in_object(
@@ -302,7 +302,7 @@ test "removes ap_id from likes" do
describe "get_existing_like/2" do
test "fetches existing like" do
note_activity = insert(:note_activity)
- assert object = Object.normalize(note_activity)
+ assert object = Object.normalize(note_activity, fetch: false)
user = insert(:user)
refute Utils.get_existing_like(user.ap_id, object)
@@ -320,7 +320,7 @@ test "returns nil if announce not found" do
test "fetches existing announce" do
note_activity = insert(:note_activity)
- assert object = Object.normalize(note_activity)
+ assert object = Object.normalize(note_activity, fetch: false)
actor = insert(:user)
{:ok, announce} = CommonAPI.repeat(note_activity.id, actor)
@@ -412,7 +412,7 @@ test "returns false" do
describe "lazy_put_activity_defaults/2" do
test "returns map with id and published data" do
note_activity = insert(:note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
res = Utils.lazy_put_activity_defaults(%{"context" => object.data["id"]})
assert res["context"] == object.data["id"]
assert res["context_id"] == object.id
@@ -431,7 +431,7 @@ test "returns map with fake id and published data" do
test "returns activity data with object" do
note_activity = insert(:note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
res =
Utils.lazy_put_activity_defaults(%{
diff --git a/test/pleroma/web/activity_pub/views/object_view_test.exs b/test/pleroma/web/activity_pub/views/object_view_test.exs
index f0389845d..967acad19 100644
--- a/test/pleroma/web/activity_pub/views/object_view_test.exs
+++ b/test/pleroma/web/activity_pub/views/object_view_test.exs
@@ -24,7 +24,7 @@ test "renders a note object" do
test "renders a note activity" do
note = insert(:note_activity)
- object = Object.normalize(note)
+ object = Object.normalize(note, fetch: false)
result = ObjectView.render("object.json", %{object: note})
@@ -56,7 +56,7 @@ test "renders `replies` collection for a note activity" do
test "renders a like activity" do
note = insert(:note_activity)
- object = Object.normalize(note)
+ object = Object.normalize(note, fetch: false)
user = insert(:user)
{:ok, like_activity} = CommonAPI.favorite(user, note.id)
@@ -70,7 +70,7 @@ test "renders a like activity" do
test "renders an announce activity" do
note = insert(:note_activity)
- object = Object.normalize(note)
+ object = Object.normalize(note, fetch: false)
user = insert(:user)
{:ok, announce_activity} = CommonAPI.repeat(note.id, user)
diff --git a/test/pleroma/web/activity_pub/views/user_view_test.exs b/test/pleroma/web/activity_pub/views/user_view_test.exs
index 98c7c9d09..5702c1b6f 100644
--- a/test/pleroma/web/activity_pub/views/user_view_test.exs
+++ b/test/pleroma/web/activity_pub/views/user_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.UserViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.User
@@ -80,6 +80,12 @@ test "renders an invisible user with the invisible property set to true" do
assert %{"invisible" => true} = UserView.render("service.json", %{user: user})
end
+ test "renders AKAs" do
+ akas = ["https://i.tusooa.xyz/users/test-pleroma"]
+ user = insert(:user, also_known_as: akas)
+ assert %{"alsoKnownAs" => ^akas} = UserView.render("user.json", %{user: user})
+ end
+
describe "endpoints" do
test "local users have a usable endpoints structure" do
user = insert(:user)
diff --git a/test/pleroma/web/activity_pub/visibility_test.exs b/test/pleroma/web/activity_pub/visibility_test.exs
index 836d44994..1ec41aa19 100644
--- a/test/pleroma/web/activity_pub/visibility_test.exs
+++ b/test/pleroma/web/activity_pub/visibility_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.VisibilityTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Web.ActivityPub.Visibility
@@ -159,7 +159,7 @@ test "doesn't die when the user doesn't exist",
user: user
} do
Repo.delete(user)
- Cachex.clear(:user_cache)
+ Pleroma.User.invalidate_cache(user)
refute Visibility.is_private?(direct)
end
diff --git a/test/pleroma/web/admin_api/controllers/admin_api_controller_test.exs b/test/pleroma/web/admin_api/controllers/admin_api_controller_test.exs
index e50d1425b..90b25b782 100644
--- a/test/pleroma/web/admin_api/controllers/admin_api_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/admin_api_controller_test.exs
@@ -422,10 +422,20 @@ test "renders user's statuses", %{conn: conn, user: user} do
assert json_response(conn, 200) |> length() == 3
end
- test "renders user's statuses with a limit", %{conn: conn, user: user} do
- conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=2")
+ test "renders user's statuses with pagination", %{conn: conn, user: user} do
+ conn1 = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=1")
- assert json_response(conn, 200) |> length() == 2
+ response1 = json_response(conn1, 200)
+
+ assert response1 |> length() == 1
+
+ conn2 = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=2")
+
+ response2 = json_response(conn2, 200)
+
+ assert response2 |> length() == 1
+
+ refute response1 == response2
end
test "doesn't return private statuses by default", %{conn: conn, user: user} do
diff --git a/test/pleroma/web/admin_api/controllers/chat_controller_test.exs b/test/pleroma/web/admin_api/controllers/chat_controller_test.exs
index 5aefa1e60..00e67a91c 100644
--- a/test/pleroma/web/admin_api/controllers/chat_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/chat_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ChatControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
@@ -36,7 +36,7 @@ test "it deletes a message from the chat", %{conn: conn, admin: admin} do
{:ok, message} =
CommonAPI.post_chat_message(user, recipient, "Hello darkness my old friend")
- object = Object.normalize(message, false)
+ object = Object.normalize(message, fetch: false)
chat = Chat.get(user.id, recipient.ap_id)
recipient_chat = Chat.get(recipient.id, user.ap_id)
@@ -143,7 +143,7 @@ test "it returns a chat", %{conn: conn} do
recipient = insert(:user)
{:ok, message} = CommonAPI.post_chat_message(user, recipient, "Yo")
- object = Object.normalize(message, false)
+ object = Object.normalize(message, fetch: false)
chat = Chat.get(user.id, recipient.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
@@ -183,7 +183,7 @@ test "GET /api/pleroma/admin/chats/:id", %{conn: conn, chat: chat} do
recipient = insert(:user)
{:ok, message} = CommonAPI.post_chat_message(user, recipient, "Yo")
- object = Object.normalize(message, false)
+ object = Object.normalize(message, fetch: false)
chat = Chat.get(user.id, recipient.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
diff --git a/test/pleroma/web/admin_api/controllers/config_controller_test.exs b/test/pleroma/web/admin_api/controllers/config_controller_test.exs
index e6b203e74..df5d74d45 100644
--- a/test/pleroma/web/admin_api/controllers/config_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/config_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
- use Pleroma.Web.ConnCase, async: true
+ use Pleroma.Web.ConnCase
import ExUnit.CaptureLog
import Pleroma.Factory
diff --git a/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs b/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs
index f243d1fb2..62fb9592a 100644
--- a/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs
@@ -12,10 +12,6 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
setup do: clear_config([:media_proxy])
- setup do
- on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
- end
-
setup do
admin = insert(:user, is_admin: true)
token = insert(:oauth_admin_token, user: admin)
diff --git a/test/pleroma/web/admin_api/controllers/report_controller_test.exs b/test/pleroma/web/admin_api/controllers/report_controller_test.exs
index cbfc2e7b0..2ab2f2f6d 100644
--- a/test/pleroma/web/admin_api/controllers/report_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/report_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/web/admin_api/controllers/status_controller_test.exs b/test/pleroma/web/admin_api/controllers/status_controller_test.exs
index a18ef9e4b..40714c8a4 100644
--- a/test/pleroma/web/admin_api/controllers/status_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/status_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/web/admin_api/controllers/user_controller_test.exs b/test/pleroma/web/admin_api/controllers/user_controller_test.exs
index 5705306c7..67b0c578c 100644
--- a/test/pleroma/web/admin_api/controllers/user_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/user_controller_test.exs
@@ -953,6 +953,7 @@ defp user_response(user, attrs \\ %{}) do
%{
"deactivated" => user.deactivated,
"id" => user.id,
+ "email" => user.email,
"nickname" => user.nickname,
"roles" => %{"admin" => false, "moderator" => false},
"local" => user.local,
diff --git a/test/pleroma/web/admin_api/search_test.exs b/test/pleroma/web/admin_api/search_test.exs
index 9bc58640c..fdf22a8e6 100644
--- a/test/pleroma/web/admin_api/search_test.exs
+++ b/test/pleroma/web/admin_api/search_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.SearchTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Web.AdminAPI.Search
diff --git a/test/pleroma/web/admin_api/views/account_view_test.exs b/test/pleroma/web/admin_api/views/account_view_test.exs
new file mode 100644
index 000000000..f54214575
--- /dev/null
+++ b/test/pleroma/web/admin_api/views/account_view_test.exs
@@ -0,0 +1,16 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.AdminAPI.AccountViewTest do
+ use Pleroma.DataCase, async: true
+ import Pleroma.Factory
+ alias Pleroma.Web.AdminAPI.AccountView
+
+ describe "show.json" do
+ test "renders the user's email" do
+ user = insert(:user, email: "yolo@yolofam.tld")
+ assert %{"email" => "yolo@yolofam.tld"} = AccountView.render("show.json", %{user: user})
+ end
+ end
+end
diff --git a/test/pleroma/web/admin_api/views/moderation_log_view_test.exs b/test/pleroma/web/admin_api/views/moderation_log_view_test.exs
index e6c5aaa7f..a4748990e 100644
--- a/test/pleroma/web/admin_api/views/moderation_log_view_test.exs
+++ b/test/pleroma/web/admin_api/views/moderation_log_view_test.exs
@@ -2,13 +2,14 @@
# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ModerationLogViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.AdminAPI.ModerationLogView
describe "renders `report_note_delete` log messages" do
setup do
log1 = %Pleroma.ModerationLog{
+ id: 1,
data: %{
"action" => "report_note_delete",
"actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"},
@@ -21,6 +22,7 @@ defmodule Pleroma.Web.AdminAPI.ModerationLogViewTest do
}
log2 = %Pleroma.ModerationLog{
+ id: 2,
data: %{
"action" => "report_note_delete",
"actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"},
@@ -42,6 +44,7 @@ test "renders `report_note_delete` log messages", %{log1: log1, log2: log2} do
) == %{
items: [
%{
+ id: 1,
data: %{
"action" => "report_note_delete",
"actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"},
@@ -59,6 +62,7 @@ test "renders `report_note_delete` log messages", %{log1: log1, log2: log2} do
time: 1_605_622_400
},
%{
+ id: 2,
data: %{
"action" => "report_note_delete",
"actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"},
@@ -82,6 +86,7 @@ test "renders `report_note_delete` log messages", %{log1: log1, log2: log2} do
test "renders `report_note_delete` log message", %{log1: log} do
assert ModerationLogView.render("show.json", %{log_entry: log}) == %{
+ id: 1,
data: %{
"action" => "report_note_delete",
"actor" => %{"id" => "A1I7G8", "nickname" => "admin", "type" => "user"},
diff --git a/test/pleroma/web/admin_api/views/report_view_test.exs b/test/pleroma/web/admin_api/views/report_view_test.exs
index 5a02292be..3914751b5 100644
--- a/test/pleroma/web/admin_api/views/report_view_test.exs
+++ b/test/pleroma/web/admin_api/views/report_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ReportViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
@@ -143,4 +143,29 @@ test "doesn't error out when the user doesn't exists" do
assert %{} = ReportView.render("show.json", Report.extract_report_info(activity))
end
+
+ test "reports are ordered newest first" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, report1} =
+ CommonAPI.report(user, %{
+ account_id: other_user.id,
+ comment: "first report"
+ })
+
+ {:ok, report2} =
+ CommonAPI.report(user, %{
+ account_id: other_user.id,
+ comment: "second report"
+ })
+
+ %{reports: rendered} =
+ ReportView.render("index.json",
+ reports: Pleroma.Web.ActivityPub.Utils.get_reports(%{}, 1, 50)
+ )
+
+ assert report2.id == rendered |> Enum.at(0) |> Map.get(:id)
+ assert report1.id == rendered |> Enum.at(1) |> Map.get(:id)
+ end
end
diff --git a/test/pleroma/web/auth/authenticator_test.exs b/test/pleroma/web/auth/authenticator_test.exs
index d54253343..862eb8051 100644
--- a/test/pleroma/web/auth/authenticator_test.exs
+++ b/test/pleroma/web/auth/authenticator_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Auth.AuthenticatorTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Web.Auth.Authenticator
import Pleroma.Factory
diff --git a/test/pleroma/web/auth/basic_auth_test.exs b/test/pleroma/web/auth/basic_auth_test.exs
index bf6e3d2fc..e56c1e1e8 100644
--- a/test/pleroma/web/auth/basic_auth_test.exs
+++ b/test/pleroma/web/auth/basic_auth_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Auth.BasicAuthTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/web/auth/pleroma_authenticator_test.exs b/test/pleroma/web/auth/pleroma_authenticator_test.exs
index 1ba0dfecc..4539ffe87 100644
--- a/test/pleroma/web/auth/pleroma_authenticator_test.exs
+++ b/test/pleroma/web/auth/pleroma_authenticator_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Auth.PleromaAuthenticatorTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Web.Auth.PleromaAuthenticator
import Pleroma.Factory
diff --git a/test/pleroma/web/auth/totp_authenticator_test.exs b/test/pleroma/web/auth/totp_authenticator_test.exs
index 84d4cd840..7f99d62bf 100644
--- a/test/pleroma/web/auth/totp_authenticator_test.exs
+++ b/test/pleroma/web/auth/totp_authenticator_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Auth.TOTPAuthenticatorTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.MFA
alias Pleroma.MFA.BackupCodes
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs
index 585b2c174..56a3d6531 100644
--- a/test/pleroma/web/common_api_test.exs
+++ b/test/pleroma/web/common_api_test.exs
@@ -39,7 +39,7 @@ test "it posts a poll" do
poll: %{expires_in: 600, options: ["reimu", "marisa"]}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["type"] == "Question"
assert object.data["oneOf"] |> length() == 2
@@ -174,7 +174,7 @@ test "it adds html newlines" do
assert other_user.ap_id not in activity.recipients
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert object.data["content"] == "uguu
uguuu"
end
@@ -194,7 +194,7 @@ test "it linkifies" do
assert other_user.ap_id not in activity.recipients
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert object.data["content"] ==
"https://example.org is the site of Object.prune()
with_mock Pleroma.Web.Federator,
@@ -491,7 +491,7 @@ test "it de-duplicates tags" do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "#2hu #2HU"})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["tag"] == ["2hu"]
end
@@ -500,10 +500,23 @@ test "it adds emoji in the object" do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: ":firefox:"})
- assert Object.normalize(activity).data["emoji"]["firefox"]
+ assert Object.normalize(activity, fetch: false).data["emoji"]["firefox"]
end
describe "posting" do
+ test "it adds an emoji on an external site" do
+ user = insert(:user)
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey :external_emoji:"})
+
+ assert %{"external_emoji" => url} = Object.normalize(activity).data["emoji"]
+ assert url == "https://example.com/emoji.png"
+
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey :blank:"})
+
+ assert %{"blank" => url} = Object.normalize(activity).data["emoji"]
+ assert url == "#{Pleroma.Web.base_url()}/emoji/blank.png"
+ end
+
test "deactivated users can't post" do
user = insert(:user, deactivated: true)
assert {:error, _} = CommonAPI.post(user, %{status: "ye"})
@@ -539,7 +552,7 @@ test "it filters out obviously bad tags when accepting a post as HTML" do
content_type: "text/html"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["content"] == "2hu
alert('xss')"
assert object.data["source"] == post
@@ -556,7 +569,7 @@ test "it filters out obviously bad tags when accepting a post as Markdown" do
content_type: "text/markdown"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["content"] == "2hu
alert('xss')"
assert object.data["source"] == post
@@ -1211,7 +1224,7 @@ test "does not allow to vote twice" do
poll: %{options: ["Yes", "No"], expires_in: 20}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, _, object} = CommonAPI.vote(other_user, object, [0])
@@ -1231,7 +1244,7 @@ test "returns a valid activity" do
length: 180_000
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["title"] == "lain radio episode 1"
@@ -1250,7 +1263,7 @@ test "respects visibility=private" do
visibility: "private"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert object.data["title"] == "lain radio episode 1"
diff --git a/test/pleroma/web/endpoint/metrics_exporter_test.exs b/test/pleroma/web/endpoint/metrics_exporter_test.exs
index 875addc96..d0cae3d42 100644
--- a/test/pleroma/web/endpoint/metrics_exporter_test.exs
+++ b/test/pleroma/web/endpoint/metrics_exporter_test.exs
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Endpoint.MetricsExporterTest do
+ # Modifies AppEnv, has to stay synchronous
use Pleroma.Web.ConnCase
alias Pleroma.Web.Endpoint.MetricsExporter
diff --git a/test/pleroma/web/feed/tag_controller_test.exs b/test/pleroma/web/feed/tag_controller_test.exs
index e4084b0e5..48dc3b404 100644
--- a/test/pleroma/web/feed/tag_controller_test.exs
+++ b/test/pleroma/web/feed/tag_controller_test.exs
@@ -24,7 +24,7 @@ test "gets a feed (ATOM)", %{conn: conn} do
user = insert(:user)
{:ok, activity1} = CommonAPI.post(user, %{status: "yeah #PleromaArt"})
- object = Object.normalize(activity1)
+ object = Object.normalize(activity1, fetch: false)
object_data =
Map.put(object.data, "attachment", [
@@ -91,7 +91,7 @@ test "gets a feed (RSS)", %{conn: conn} do
user = insert(:user)
{:ok, activity1} = CommonAPI.post(user, %{status: "yeah #PleromaArt"})
- object = Object.normalize(activity1)
+ object = Object.normalize(activity1, fetch: false)
object_data =
Map.put(object.data, "attachment", [
@@ -131,7 +131,7 @@ test "gets a feed (RSS)", %{conn: conn} do
'#{Pleroma.Web.base_url()}/tags/pleromaart.rss'
assert xpath(xml, ~x"//channel/webfeeds:logo/text()") ==
- '#{Pleroma.Web.base_url()}/static/logo.png'
+ '#{Pleroma.Web.base_url()}/static/logo.svg'
assert xpath(xml, ~x"//channel/item/title/text()"l) == [
'42 This is :moominmamm...',
@@ -147,8 +147,8 @@ test "gets a feed (RSS)", %{conn: conn} do
"https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4"
]
- obj1 = Object.normalize(activity1)
- obj2 = Object.normalize(activity2)
+ obj1 = Object.normalize(activity1, fetch: false)
+ obj2 = Object.normalize(activity2, fetch: false)
assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
HtmlEntities.decode(FeedView.activity_content(obj2.data)),
diff --git a/test/pleroma/web/feed/user_controller_test.exs b/test/pleroma/web/feed/user_controller_test.exs
index 16f002717..50445862b 100644
--- a/test/pleroma/web/feed/user_controller_test.exs
+++ b/test/pleroma/web/feed/user_controller_test.exs
@@ -58,7 +58,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
)
note_activity2 = insert(:note_activity, note: note2)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
[user: user, object: object, max_id: note_activity2.id]
end
diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
index 3361c8669..cc7b3cf8b 100644
--- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
@@ -469,6 +469,21 @@ test "muted reactions", %{user: user, conn: conn} do
}
] = result
end
+
+ test "paginates a user's statuses", %{user: user, conn: conn} do
+ {:ok, post_1} = CommonAPI.post(user, %{status: "first post"})
+ {:ok, post_2} = CommonAPI.post(user, %{status: "second post"})
+
+ response_1 = get(conn, "/api/v1/accounts/#{user.id}/statuses?limit=1")
+ assert [res] = json_response(response_1, 200)
+ assert res["id"] == post_2.id
+
+ response_2 = get(conn, "/api/v1/accounts/#{user.id}/statuses?limit=1&max_id=#{res["id"]}")
+ assert [res] = json_response(response_2, 200)
+ assert res["id"] == post_1.id
+
+ refute response_1 == response_2
+ end
end
defp local_and_remote_activities(%{local: local, remote: remote}) do
@@ -1411,8 +1426,6 @@ test "creates an account and returns 200 if captcha is valid", %{conn: conn} do
|> json_response_and_validate_schema(:ok)
assert Token |> Repo.get_by(token: access_token) |> Repo.preload(:user) |> Map.get(:user)
-
- Cachex.del(:used_captcha_cache, token)
end
test "returns 400 if any captcha field is not provided", %{conn: conn} do
diff --git a/test/pleroma/web/mastodon_api/controllers/auth_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/auth_controller_test.exs
index d7834c876..ce957054b 100644
--- a/test/pleroma/web/mastodon_api/controllers/auth_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/auth_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AuthControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Config
alias Pleroma.Repo
diff --git a/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs
index b00615ac9..a03513e06 100644
--- a/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Conversation.Participation
alias Pleroma.User
diff --git a/test/pleroma/web/mastodon_api/controllers/domain_block_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/domain_block_controller_test.exs
index 664654500..b10aa6966 100644
--- a/test/pleroma/web/mastodon_api/controllers/domain_block_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/domain_block_controller_test.exs
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do
+ # TODO: Should not need Cachex
use Pleroma.Web.ConnCase
alias Pleroma.User
diff --git a/test/pleroma/web/mastodon_api/controllers/filter_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/filter_controller_test.exs
index 0d426ec34..e639cdde1 100644
--- a/test/pleroma/web/mastodon_api/controllers/filter_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/filter_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Web.MastodonAPI.FilterView
diff --git a/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs
index b977b41ae..f0a466212 100644
--- a/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.User
alias Pleroma.Web.CommonAPI
diff --git a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs
index 605df6ed6..71a170240 100644
--- a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
+ # TODO: Should not need Cachex
use Pleroma.Web.ConnCase
alias Pleroma.User
diff --git a/test/pleroma/web/mastodon_api/controllers/list_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/list_controller_test.exs
index 091ec006c..01f64cfcc 100644
--- a/test/pleroma/web/mastodon_api/controllers/list_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/list_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ListControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Repo
diff --git a/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
index 9f0481120..ee944a67c 100644
--- a/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/web/mastodon_api/controllers/poll_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/poll_controller_test.exs
index f41de6448..71cea8462 100644
--- a/test/pleroma/web/mastodon_api/controllers/poll_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/poll_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Object
alias Pleroma.Web.CommonAPI
@@ -20,7 +20,7 @@ test "returns poll entity for object id", %{user: user, conn: conn} do
poll: %{options: ["what Mastodon't", "n't what Mastodoes"], expires_in: 20}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
conn = get(conn, "/api/v1/polls/#{object.id}")
@@ -39,7 +39,7 @@ test "does not expose polls for private statuses", %{conn: conn} do
visibility: "private"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
conn = get(conn, "/api/v1/polls/#{object.id}")
@@ -63,7 +63,7 @@ test "votes are added to the poll", %{conn: conn} do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
conn =
conn
@@ -85,7 +85,7 @@ test "author can't vote", %{user: user, conn: conn} do
poll: %{options: ["Yes", "No"], expires_in: 20}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert conn
|> put_req_header("content-type", "application/json")
@@ -106,7 +106,7 @@ test "does not allow multiple choices on a single-choice question", %{conn: conn
poll: %{options: ["half empty", "half full"], expires_in: 20}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert conn
|> put_req_header("content-type", "application/json")
@@ -129,7 +129,7 @@ test "does not allow choice index to be greater than options count", %{conn: con
poll: %{options: ["Yes", "No"], expires_in: 20}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
conn =
conn
@@ -158,7 +158,7 @@ test "returns 404 when poll is private and not available for user", %{conn: conn
visibility: "private"
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
conn =
conn
diff --git a/test/pleroma/web/mastodon_api/controllers/report_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/report_controller_test.exs
index 6636cff96..322eb475c 100644
--- a/test/pleroma/web/mastodon_api/controllers/report_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/report_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ReportControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Web.CommonAPI
diff --git a/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
index 1045ab265..664bdce01 100644
--- a/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
@@ -309,7 +309,7 @@ test "search doesn't show statuses that it shouldn't", %{conn: conn} do
})
capture_log(fn ->
- q = Object.normalize(activity).data["id"]
+ q = Object.normalize(activity, fetch: false).data["id"]
results =
conn
diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
index 30d542dfa..ffff0ae9d 100644
--- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
@@ -67,10 +67,6 @@ test "posting a status", %{conn: conn} do
"sensitive" => "0"
})
- {:ok, ttl} = Cachex.ttl(:idempotency_cache, idempotency_key)
- # Six hours
- assert ttl > :timer.seconds(6 * 60 * 60 - 1)
-
assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu", "sensitive" => false} =
json_response_and_validate_schema(conn_one, 200)
@@ -804,7 +800,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
test "when you created it" do
%{user: author, conn: conn} = oauth_access(["write:statuses"])
activity = insert(:note_activity, user: author)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
content = object.data["content"]
source = object.data["source"]
@@ -1378,7 +1374,9 @@ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{c
activity = Activity.get_by_id_with_object(id)
- assert Object.normalize(activity).data["inReplyTo"] == Object.normalize(replied_to).data["id"]
+ assert Object.normalize(activity, fetch: false).data["inReplyTo"] ==
+ Object.normalize(replied_to, fetch: false).data["id"]
+
assert Activity.get_in_reply_to_activity(activity).id == replied_to.id
# Reblog from the third user
diff --git a/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs
index 5ef39bdb2..4bb085750 100644
--- a/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.SubscriptionControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
diff --git a/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs
index 7f08e187c..c3471266a 100644
--- a/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
setup do: oauth_access(["read"])
diff --git a/test/pleroma/web/mastodon_api/mastodon_api_controller_test.exs b/test/pleroma/web/mastodon_api/mastodon_api_controller_test.exs
index bb4bc4396..be5bf68a3 100644
--- a/test/pleroma/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/mastodon_api_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
describe "empty_array/2 (stubs)" do
test "GET /api/v1/accounts/:id/identity_proofs" do
diff --git a/test/pleroma/web/mastodon_api/mastodon_api_test.exs b/test/pleroma/web/mastodon_api/mastodon_api_test.exs
index 687fe5585..cf7f464be 100644
--- a/test/pleroma/web/mastodon_api/mastodon_api_test.exs
+++ b/test/pleroma/web/mastodon_api/mastodon_api_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.MastodonAPITest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Notification
alias Pleroma.ScheduledActivity
diff --git a/test/pleroma/web/mastodon_api/update_credentials_test.exs b/test/pleroma/web/mastodon_api/update_credentials_test.exs
index ed1921c91..e3e437a19 100644
--- a/test/pleroma/web/mastodon_api/update_credentials_test.exs
+++ b/test/pleroma/web/mastodon_api/update_credentials_test.exs
@@ -11,8 +11,6 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
import Mock
import Pleroma.Factory
- setup do: clear_config([:instance, :max_account_fields])
-
describe "updating credentials" do
setup do: oauth_access(["write:accounts"])
setup :request_content_type
@@ -220,6 +218,25 @@ test "updates the user's name", %{conn: conn} do
assert update_activity.data["object"]["name"] == "markorepairs"
end
+ test "updates the user's AKAs", %{conn: conn} do
+ conn =
+ patch(conn, "/api/v1/accounts/update_credentials", %{
+ "also_known_as" => ["https://mushroom.kingdom/users/mario"]
+ })
+
+ assert user_data = json_response_and_validate_schema(conn, 200)
+ assert user_data["pleroma"]["also_known_as"] == ["https://mushroom.kingdom/users/mario"]
+ end
+
+ test "doesn't update non-url akas", %{conn: conn} do
+ conn =
+ patch(conn, "/api/v1/accounts/update_credentials", %{
+ "also_known_as" => ["aReallyCoolGuy"]
+ })
+
+ assert json_response_and_validate_schema(conn, 403)
+ end
+
test "updates the user's avatar", %{user: user, conn: conn} do
new_avatar = %Plug.Upload{
content_type: "image/jpeg",
@@ -446,7 +463,7 @@ test "update fields when invalid request", %{conn: conn} do
|> patch("/api/v1/accounts/update_credentials", %{"fields_attributes" => fields})
|> json_response_and_validate_schema(403)
- Pleroma.Config.put([:instance, :max_account_fields], 1)
+ clear_config([:instance, :max_account_fields], 1)
fields = [
%{"name" => "foo", "value" => "bar"},
diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs
index 8c77f14d4..f9afd0afc 100644
--- a/test/pleroma/web/mastodon_api/views/account_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs
@@ -35,7 +35,8 @@ test "Represent a user account" do
"valid html. a
b
c
d
f '&<>\"",
inserted_at: ~N[2017-08-15 15:47:06.597036],
emoji: %{"karjalanpiirakka" => "/file.png"},
- raw_bio: "valid html. a\nb\nc\nd\nf '&<>\""
+ raw_bio: "valid html. a\nb\nc\nd\nf '&<>\"",
+ also_known_as: ["https://shitposter.zone/users/shp"]
})
expected = %{
@@ -75,6 +76,7 @@ test "Represent a user account" do
},
pleroma: %{
ap_id: user.ap_id,
+ also_known_as: ["https://shitposter.zone/users/shp"],
background_image: "https://example.com/images/asuka_hospital.png",
favicon: nil,
confirmation_pending: false,
@@ -173,6 +175,7 @@ test "Represent a Service(bot) account" do
},
pleroma: %{
ap_id: user.ap_id,
+ also_known_as: [],
background_image: nil,
favicon: nil,
confirmation_pending: false,
diff --git a/test/pleroma/web/mastodon_api/views/conversation_view_test.exs b/test/pleroma/web/mastodon_api/views/conversation_view_test.exs
index 20c10ba3d..f02253b68 100644
--- a/test/pleroma/web/mastodon_api/views/conversation_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/conversation_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ConversationViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Conversation.Participation
alias Pleroma.Web.CommonAPI
diff --git a/test/pleroma/web/mastodon_api/views/list_view_test.exs b/test/pleroma/web/mastodon_api/views/list_view_test.exs
index ca99242cb..377941332 100644
--- a/test/pleroma/web/mastodon_api/views/list_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/list_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ListViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.MastodonAPI.ListView
diff --git a/test/pleroma/web/mastodon_api/views/marker_view_test.exs b/test/pleroma/web/mastodon_api/views/marker_view_test.exs
index 48a0a6d33..a0bec758f 100644
--- a/test/pleroma/web/mastodon_api/views/marker_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/marker_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.MarkerViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.MastodonAPI.MarkerView
import Pleroma.Factory
diff --git a/test/pleroma/web/mastodon_api/views/notification_view_test.exs b/test/pleroma/web/mastodon_api/views/notification_view_test.exs
index 9de11a87e..79dd23a51 100644
--- a/test/pleroma/web/mastodon_api/views/notification_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/notification_view_test.exs
@@ -44,7 +44,7 @@ test "ChatMessage notification" do
{:ok, [notification]} = Notification.create_notifications(activity)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
chat = Chat.get(recipient.id, user.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
diff --git a/test/pleroma/web/mastodon_api/views/poll_view_test.exs b/test/pleroma/web/mastodon_api/views/poll_view_test.exs
index c655ca438..f83e5b368 100644
--- a/test/pleroma/web/mastodon_api/views/poll_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/poll_view_test.exs
@@ -29,7 +29,7 @@ test "renders a poll" do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
expected = %{
emojis: [],
@@ -72,7 +72,7 @@ test "detects if it is multiple choice" do
voter = insert(:user)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, _votes, object} = CommonAPI.vote(voter, object, [0, 1])
@@ -98,7 +98,7 @@ test "detects emoji" do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert %{emojis: [%{shortcode: "blank"}]} = PollView.render("show.json", %{object: object})
end
@@ -117,7 +117,7 @@ test "detects vote status" do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
{:ok, _, object} = CommonAPI.vote(other_user, object, [1, 2])
@@ -129,7 +129,7 @@ test "detects vote status" do
end
test "does not crash on polls with no end date" do
- object = Object.normalize("https://skippers-bin.com/notes/7x9tmrp97i")
+ object = Object.normalize("https://skippers-bin.com/notes/7x9tmrp97i", fetch: true)
result = PollView.render("show.json", %{object: object})
assert result[:expires_at] == nil
@@ -153,7 +153,7 @@ test "doesn't strips HTML tags" do
}
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert %{
options: [
diff --git a/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs b/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
index 04f73f5a0..c41ac7f7f 100644
--- a/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.ScheduledActivity
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.CommonAPI
diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs
index f2a7469ed..789acb487 100644
--- a/test/pleroma/web/mastodon_api/views/status_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs
@@ -61,7 +61,7 @@ test "works correctly with badly formatted emojis" do
{:ok, activity} = CommonAPI.post(user, %{status: "yo"})
activity
- |> Object.normalize(false)
+ |> Object.normalize(fetch: false)
|> Object.update_data(%{"reactions" => %{"☕" => [user.ap_id], "x" => 1}})
activity = Activity.get_by_id(activity.id)
@@ -160,7 +160,7 @@ test "returns a temporary ap_id based user for activities missing db users" do
{:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
finger_url =
"https://localhost/.well-known/webfinger?resource=acct:#{user.nickname}@localhost"
@@ -194,7 +194,7 @@ test "tries to get a user by nickname if fetching by ap_id doesn't work" do
|> Ecto.Changeset.change(%{ap_id: "#{user.ap_id}/extension/#{user.nickname}"})
|> Repo.update()
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
result = StatusView.render("show.json", activity: activity)
@@ -204,7 +204,7 @@ test "tries to get a user by nickname if fetching by ap_id doesn't work" do
test "a note with null content" do
note = insert(:note_activity)
- note_object = Object.normalize(note)
+ note_object = Object.normalize(note, fetch: false)
data =
note_object.data
@@ -223,7 +223,7 @@ test "a note with null content" do
test "a note activity" do
note = insert(:note_activity)
- object_data = Object.normalize(note).data
+ object_data = Object.normalize(note, fetch: false).data
user = User.get_cached_by_ap_id(note.data["actor"])
convo_id = Utils.context_to_conversation_id(object_data["context"])
diff --git a/test/pleroma/web/mastodon_api/views/subscription_view_test.exs b/test/pleroma/web/mastodon_api/views/subscription_view_test.exs
index 981524c0e..c2bb535c5 100644
--- a/test/pleroma/web/mastodon_api/views/subscription_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/subscription_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.SubscriptionViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.MastodonAPI.SubscriptionView, as: View
alias Pleroma.Web.Push
diff --git a/test/pleroma/web/media_proxy/invalidation/http_test.exs b/test/pleroma/web/media_proxy/invalidation/http_test.exs
index 13d081325..c81010423 100644
--- a/test/pleroma/web/media_proxy/invalidation/http_test.exs
+++ b/test/pleroma/web/media_proxy/invalidation/http_test.exs
@@ -9,10 +9,6 @@ defmodule Pleroma.Web.MediaProxy.Invalidation.HttpTest do
import ExUnit.CaptureLog
import Tesla.Mock
- setup do
- on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
- end
-
test "logs hasn't error message when request is valid" do
mock(fn
%{method: :purge, url: "http://example.com/media/example.jpg"} ->
diff --git a/test/pleroma/web/media_proxy/invalidation/script_test.exs b/test/pleroma/web/media_proxy/invalidation/script_test.exs
index 692cbb2df..6940a4539 100644
--- a/test/pleroma/web/media_proxy/invalidation/script_test.exs
+++ b/test/pleroma/web/media_proxy/invalidation/script_test.exs
@@ -3,15 +3,11 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MediaProxy.Invalidation.ScriptTest do
- use ExUnit.Case
+ use ExUnit.Case, async: true
alias Pleroma.Web.MediaProxy.Invalidation
import ExUnit.CaptureLog
- setup do
- on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
- end
-
test "it logger error when script not found" do
assert capture_log(fn ->
assert Invalidation.Script.purge(
diff --git a/test/pleroma/web/media_proxy/invalidation_test.exs b/test/pleroma/web/media_proxy/invalidation_test.exs
index aa1435ac0..b7be36b47 100644
--- a/test/pleroma/web/media_proxy/invalidation_test.exs
+++ b/test/pleroma/web/media_proxy/invalidation_test.exs
@@ -3,8 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MediaProxy.InvalidationTest do
- use ExUnit.Case
- use Pleroma.Tests.Helpers
+ use Pleroma.DataCase
alias Pleroma.Config
alias Pleroma.Web.MediaProxy.Invalidation
@@ -15,10 +14,6 @@ defmodule Pleroma.Web.MediaProxy.InvalidationTest do
setup do: clear_config([:media_proxy])
- setup do
- on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
- end
-
describe "Invalidation.Http" do
test "perform request to clear cache" do
Config.put([:media_proxy, :enabled], false)
diff --git a/test/pleroma/web/media_proxy/media_proxy_controller_test.exs b/test/pleroma/web/media_proxy/media_proxy_controller_test.exs
index e9b584822..65cf2a01b 100644
--- a/test/pleroma/web/media_proxy/media_proxy_controller_test.exs
+++ b/test/pleroma/web/media_proxy/media_proxy_controller_test.exs
@@ -10,10 +10,6 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
alias Pleroma.Web.MediaProxy
alias Plug.Conn
- setup do
- on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
- end
-
describe "Media Proxy" do
setup do
clear_config([:media_proxy, :enabled], true)
diff --git a/test/pleroma/web/metadata/player_view_test.exs b/test/pleroma/web/metadata/player_view_test.exs
index e6c990242..6d22317d2 100644
--- a/test/pleroma/web/metadata/player_view_test.exs
+++ b/test/pleroma/web/metadata/player_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.PlayerViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.Metadata.PlayerView
diff --git a/test/pleroma/web/metadata/providers/feed_test.exs b/test/pleroma/web/metadata/providers/feed_test.exs
index e6e5cc5ed..c7359e00b 100644
--- a/test/pleroma/web/metadata/providers/feed_test.exs
+++ b/test/pleroma/web/metadata/providers/feed_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.FeedTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.Metadata.Providers.Feed
diff --git a/test/pleroma/web/metadata/providers/rel_me_test.exs b/test/pleroma/web/metadata/providers/rel_me_test.exs
index 2293d6e13..ae449c052 100644
--- a/test/pleroma/web/metadata/providers/rel_me_test.exs
+++ b/test/pleroma/web/metadata/providers/rel_me_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.RelMeTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.Metadata.Providers.RelMe
diff --git a/test/pleroma/web/metadata/utils_test.exs b/test/pleroma/web/metadata/utils_test.exs
index 8183256d8..3794db766 100644
--- a/test/pleroma/web/metadata/utils_test.exs
+++ b/test/pleroma/web/metadata/utils_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.UtilsTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.Metadata.Utils
diff --git a/test/pleroma/web/mongoose_im_controller_test.exs b/test/pleroma/web/mongoose_im_controller_test.exs
index e3a8aa3d8..4590e1296 100644
--- a/test/pleroma/web/mongoose_im_controller_test.exs
+++ b/test/pleroma/web/mongoose_im_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MongooseIMControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
test "/user_exists", %{conn: conn} do
diff --git a/test/pleroma/web/o_auth/app_test.exs b/test/pleroma/web/o_auth/app_test.exs
index 993a490e0..24d7049f1 100644
--- a/test/pleroma/web/o_auth/app_test.exs
+++ b/test/pleroma/web/o_auth/app_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OAuth.AppTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.OAuth.App
import Pleroma.Factory
diff --git a/test/pleroma/web/o_auth/authorization_test.exs b/test/pleroma/web/o_auth/authorization_test.exs
index d74b26cf8..d1920962c 100644
--- a/test/pleroma/web/o_auth/authorization_test.exs
+++ b/test/pleroma/web/o_auth/authorization_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OAuth.AuthorizationTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.OAuth.App
alias Pleroma.Web.OAuth.Authorization
import Pleroma.Factory
diff --git a/test/pleroma/web/o_auth/mfa_controller_test.exs b/test/pleroma/web/o_auth/mfa_controller_test.exs
index 6ecd0f6c9..bc50d8d18 100644
--- a/test/pleroma/web/o_auth/mfa_controller_test.exs
+++ b/test/pleroma/web/o_auth/mfa_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OAuth.MFAControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
alias Pleroma.MFA
diff --git a/test/pleroma/web/o_auth/token/utils_test.exs b/test/pleroma/web/o_auth/token/utils_test.exs
index a610d92f8..3444692ec 100644
--- a/test/pleroma/web/o_auth/token/utils_test.exs
+++ b/test/pleroma/web/o_auth/token/utils_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OAuth.Token.UtilsTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.OAuth.Token.Utils
import Pleroma.Factory
diff --git a/test/pleroma/web/o_auth/token_test.exs b/test/pleroma/web/o_auth/token_test.exs
index c88b9cc98..866f1c00a 100644
--- a/test/pleroma/web/o_auth/token_test.exs
+++ b/test/pleroma/web/o_auth/token_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OAuth.TokenTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Repo
alias Pleroma.Web.OAuth.App
alias Pleroma.Web.OAuth.Authorization
diff --git a/test/pleroma/web/o_status/o_status_controller_test.exs b/test/pleroma/web/o_status/o_status_controller_test.exs
index 65b2c22db..f21180a89 100644
--- a/test/pleroma/web/o_status/o_status_controller_test.exs
+++ b/test/pleroma/web/o_status/o_status_controller_test.exs
@@ -72,7 +72,7 @@ test "redirects to /notice/:id for html format for activity", %{
test "redirects to /notice/id for html format", %{conn: conn} do
note_activity = insert(:note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"]))
url = "/objects/#{uuid}"
@@ -82,7 +82,7 @@ test "redirects to /notice/id for html format", %{conn: conn} do
test "404s on private objects", %{conn: conn} do
note_activity = insert(:direct_note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"]))
conn
@@ -133,7 +133,7 @@ test "redirects to a proper object URL when json requested and the object is loc
conn: conn
} do
note_activity = insert(:note_activity)
- expected_redirect_url = Object.normalize(note_activity).data["id"]
+ expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
redirect_url =
conn
@@ -230,7 +230,7 @@ test "does not require authentication on non-federating instances", %{
describe "GET /notice/:id/embed_player" do
setup do
note_activity = insert(:note_activity)
- object = Pleroma.Object.normalize(note_activity)
+ object = Pleroma.Object.normalize(note_activity, fetch: false)
object_data =
Map.put(object.data, "attachment", [
@@ -287,7 +287,7 @@ test "404s when activity is direct message", %{conn: conn} do
test "404s when attachment is empty", %{conn: conn} do
note_activity = insert(:note_activity)
- object = Pleroma.Object.normalize(note_activity)
+ object = Pleroma.Object.normalize(note_activity, fetch: false)
object_data = Map.put(object.data, "attachment", [])
object
@@ -301,7 +301,7 @@ test "404s when attachment is empty", %{conn: conn} do
test "404s when attachment isn't audio or video", %{conn: conn} do
note_activity = insert(:note_activity)
- object = Pleroma.Object.normalize(note_activity)
+ object = Pleroma.Object.normalize(note_activity, fetch: false)
object_data =
Map.put(object.data, "attachment", [
diff --git a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
index a6c9d0c1b..24efeeb73 100644
--- a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
@@ -22,7 +22,7 @@ test "it marks one message as read", %{conn: conn, user: user} do
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
{:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
{:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
- object = Object.normalize(create, false)
+ object = Object.normalize(create, fetch: false)
cm_ref = MessageReference.for_chat_and_object(chat, object)
assert cm_ref.unread == true
@@ -52,7 +52,7 @@ test "given a `last_read_id`, it marks everything until then as read", %{
{:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
{:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
{:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
- object = Object.normalize(create, false)
+ object = Object.normalize(create, fetch: false)
cm_ref = MessageReference.for_chat_and_object(chat, object)
assert cm_ref.unread == true
@@ -158,7 +158,7 @@ test "it deletes a message from the chat", %{conn: conn, user: user} do
{:ok, other_message} = CommonAPI.post_chat_message(recipient, user, "nico nico ni")
- object = Object.normalize(message, false)
+ object = Object.normalize(message, fetch: false)
chat = Chat.get(user.id, recipient.ap_id)
@@ -176,7 +176,7 @@ test "it deletes a message from the chat", %{conn: conn, user: user} do
assert %{data: %{"type" => "Tombstone"}} = Object.get_by_id(object.id)
# Deleting other people's messages just removes the reference
- object = Object.normalize(other_message, false)
+ object = Object.normalize(other_message, fetch: false)
cm_ref = MessageReference.for_chat_and_object(chat, object)
result =
@@ -394,11 +394,11 @@ test "it return a list of chats the current user is participating in, in descend
tridi = insert(:user)
{:ok, chat_1} = Chat.get_or_create(user.id, har.ap_id)
- :timer.sleep(1000)
- {:ok, _chat_2} = Chat.get_or_create(user.id, jafnhar.ap_id)
- :timer.sleep(1000)
+ {:ok, chat_1} = time_travel(chat_1, -3)
+ {:ok, chat_2} = Chat.get_or_create(user.id, jafnhar.ap_id)
+ {:ok, _chat_2} = time_travel(chat_2, -2)
{:ok, chat_3} = Chat.get_or_create(user.id, tridi.ap_id)
- :timer.sleep(1000)
+ {:ok, chat_3} = time_travel(chat_3, -1)
# bump the second one
{:ok, chat_2} = Chat.bump_or_create(user.id, jafnhar.ap_id)
diff --git a/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs
index f2feeaaef..c8c2433ae 100644
--- a/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ConversationControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Conversation.Participation
alias Pleroma.Repo
diff --git a/test/pleroma/web/pleroma_api/controllers/emoji_file_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/emoji_file_controller_test.exs
index 82de86ee3..6fbdaec7a 100644
--- a/test/pleroma/web/pleroma_api/controllers/emoji_file_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/emoji_file_controller_test.exs
@@ -5,6 +5,7 @@
defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
use Pleroma.Web.ConnCase
+ import Mock
import Tesla.Mock
import Pleroma.Factory
@@ -200,6 +201,31 @@ test "add file with not loaded pack", %{admin_conn: admin_conn} do
}
end
+ test "returns an error on add file when file system is not writable", %{
+ admin_conn: admin_conn
+ } do
+ pack_file = Path.join([@emoji_path, "not_loaded", "pack.json"])
+
+ with_mocks([
+ {File, [:passthrough], [stat: fn ^pack_file -> {:error, :eacces} end]}
+ ]) do
+ assert admin_conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/emoji/packs/files?name=not_loaded", %{
+ shortcode: "blank3",
+ filename: "dir/blank.png",
+ file: %Plug.Upload{
+ filename: "blank.png",
+ path: "#{@emoji_path}/test_pack/blank.png"
+ }
+ })
+ |> json_response_and_validate_schema(500) == %{
+ "error" =>
+ "Unexpected error occurred while adding file to pack. (POSIX error: Permission denied)"
+ }
+ end
+ end
+
test "remove file with not loaded pack", %{admin_conn: admin_conn} do
assert admin_conn
|> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=blank3")
diff --git a/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs
index 3445f0ca0..d9385389b 100644
--- a/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs
@@ -3,8 +3,9 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: false
+ import Mock
import Tesla.Mock
import Pleroma.Factory
@@ -346,7 +347,7 @@ test "other error", %{admin_conn: admin_conn} do
end
end
- describe "PATCH /api/pleroma/emoji/pack?name=:name" do
+ describe "PATCH/update /api/pleroma/emoji/pack?name=:name" do
setup do
pack_file = "#{@emoji_path}/test_pack/pack.json"
original_content = File.read!(pack_file)
@@ -365,6 +366,20 @@ test "other error", %{admin_conn: admin_conn} do
}}
end
+ test "returns error when file system not writable", %{admin_conn: conn} = ctx do
+ with_mocks([
+ {File, [:passthrough], [stat: fn _ -> {:error, :eacces} end]}
+ ]) do
+ assert conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch(
+ "/api/pleroma/emoji/pack?name=test_pack",
+ %{"metadata" => ctx[:new_data]}
+ )
+ |> json_response_and_validate_schema(500)
+ end
+ end
+
test "for a pack without a fallback source", ctx do
assert ctx[:admin_conn]
|> put_req_header("content-type", "multipart/form-data")
@@ -424,6 +439,46 @@ test "when the fallback source doesn't have all the files", ctx do
end
describe "POST/DELETE /api/pleroma/emoji/pack?name=:name" do
+ test "returns an error on creates pack when file system not writable", %{
+ admin_conn: admin_conn
+ } do
+ path_pack = Path.join(@emoji_path, "test_pack")
+
+ with_mocks([
+ {File, [:passthrough], [mkdir: fn ^path_pack -> {:error, :eacces} end]}
+ ]) do
+ assert admin_conn
+ |> post("/api/pleroma/emoji/pack?name=test_pack")
+ |> json_response_and_validate_schema(500) == %{
+ "error" =>
+ "Unexpected error occurred while creating pack. (POSIX error: Permission denied)"
+ }
+ end
+ end
+
+ test "returns an error on deletes pack when the file system is not writable", %{
+ admin_conn: admin_conn
+ } do
+ path_pack = Path.join(@emoji_path, "test_emoji_pack")
+
+ try do
+ {:ok, _pack} = Pleroma.Emoji.Pack.create("test_emoji_pack")
+
+ with_mocks([
+ {File, [:passthrough], [rm_rf: fn ^path_pack -> {:error, :eacces, path_pack} end]}
+ ]) do
+ assert admin_conn
+ |> delete("/api/pleroma/emoji/pack?name=test_emoji_pack")
+ |> json_response_and_validate_schema(500) == %{
+ "error" =>
+ "Couldn't delete the `test_emoji_pack` pack (POSIX error: Permission denied)"
+ }
+ end
+ after
+ File.rm_rf(path_pack)
+ end
+ end
+
test "creating and deleting a pack", %{admin_conn: admin_conn} do
assert admin_conn
|> post("/api/pleroma/emoji/pack?name=test_created")
diff --git a/test/pleroma/web/pleroma_api/controllers/mascot_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/mascot_controller_test.exs
index 289119d45..5f8fa03f6 100644
--- a/test/pleroma/web/pleroma_api/controllers/mascot_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/mascot_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.User
diff --git a/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs
index bb4fe6c49..03af4d70c 100644
--- a/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.NotificationControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Notification
alias Pleroma.Repo
diff --git a/test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs
index f39c07ac6..4ab6d9132 100644
--- a/test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Web.CommonAPI
diff --git a/test/pleroma/web/pleroma_api/controllers/two_factor_authentication_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/two_factor_authentication_controller_test.exs
index 22988c881..8d4e0104a 100644
--- a/test/pleroma/web/pleroma_api/controllers/two_factor_authentication_controller_test.exs
+++ b/test/pleroma/web/pleroma_api/controllers/two_factor_authentication_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.TwoFactorAuthenticationControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
import Pleroma.Factory
alias Pleroma.MFA.Settings
diff --git a/test/pleroma/web/pleroma_api/views/backup_view_test.exs b/test/pleroma/web/pleroma_api/views/backup_view_test.exs
new file mode 100644
index 000000000..7dda8480b
--- /dev/null
+++ b/test/pleroma/web/pleroma_api/views/backup_view_test.exs
@@ -0,0 +1,18 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.PleromaAPI.BackupViewTest do
+ use Pleroma.DataCase, async: true
+ alias Pleroma.User.Backup
+ alias Pleroma.Web.PleromaAPI.BackupView
+ import Pleroma.Factory
+
+ test "it renders the ID" do
+ user = insert(:user)
+ backup = Backup.new(user)
+
+ result = BackupView.render("show.json", backup: backup)
+ assert result.id == backup.id
+ end
+end
diff --git a/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs b/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
index 93eef00a2..0966e9166 100644
--- a/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
+++ b/test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
@@ -31,7 +31,7 @@ test "it displays a chat message" do
chat = Chat.get(user.id, recipient.ap_id)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
cm_ref = MessageReference.for_chat_and_object(chat, object)
@@ -58,7 +58,7 @@ test "it displays a chat message" do
media_id: upload.id
)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
cm_ref = MessageReference.for_chat_and_object(chat, object)
diff --git a/test/pleroma/web/pleroma_api/views/chat_view_test.exs b/test/pleroma/web/pleroma_api/views/chat_view_test.exs
index 02484b705..1cc5f16ba 100644
--- a/test/pleroma/web/pleroma_api/views/chat_view_test.exs
+++ b/test/pleroma/web/pleroma_api/views/chat_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Chat
alias Pleroma.Chat.MessageReference
@@ -35,7 +35,7 @@ test "it represents a chat" do
{:ok, chat_message_creation} = CommonAPI.post_chat_message(user, recipient, "hello")
- chat_message = Object.normalize(chat_message_creation, false)
+ chat_message = Object.normalize(chat_message_creation, fetch: false)
{:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id)
diff --git a/test/pleroma/web/pleroma_api/views/scrobble_view_test.exs b/test/pleroma/web/pleroma_api/views/scrobble_view_test.exs
index 0f43cbdc3..113b8f690 100644
--- a/test/pleroma/web/pleroma_api/views/scrobble_view_test.exs
+++ b/test/pleroma/web/pleroma_api/views/scrobble_view_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ScrobbleViewTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.PleromaAPI.ScrobbleView
diff --git a/test/pleroma/web/plugs/cache_control_test.exs b/test/pleroma/web/plugs/cache_control_test.exs
index fcf3d2be8..c775787ca 100644
--- a/test/pleroma/web/plugs/cache_control_test.exs
+++ b/test/pleroma/web/plugs/cache_control_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.CacheControlTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Plug.Conn
test "Verify Cache-Control header on static assets", %{conn: conn} do
diff --git a/test/pleroma/web/plugs/cache_test.exs b/test/pleroma/web/plugs/cache_test.exs
index 93a66f5d3..0e5fa6f36 100644
--- a/test/pleroma/web/plugs/cache_test.exs
+++ b/test/pleroma/web/plugs/cache_test.exs
@@ -3,7 +3,8 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.CacheTest do
- use ExUnit.Case, async: true
+ # Relies on Cachex, has to stay synchronous
+ use Pleroma.DataCase
use Plug.Test
alias Pleroma.Web.Plugs.Cache
@@ -24,11 +25,6 @@ defmodule Pleroma.Web.Plugs.CacheTest do
@ttl 5
- setup do
- Cachex.clear(:web_resp_cache)
- :ok
- end
-
test "caches a response" do
assert @miss_resp ==
conn(:get, "/")
diff --git a/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs b/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs
index 211443a55..9f15f5c93 100644
--- a/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs
+++ b/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlugTest do
- use Pleroma.Web.ConnCase, async: true
+ use Pleroma.Web.ConnCase
alias Pleroma.Config
alias Pleroma.User
diff --git a/test/pleroma/web/plugs/idempotency_plug_test.exs b/test/pleroma/web/plugs/idempotency_plug_test.exs
index 4a7835993..ed8b3fc1a 100644
--- a/test/pleroma/web/plugs/idempotency_plug_test.exs
+++ b/test/pleroma/web/plugs/idempotency_plug_test.exs
@@ -3,7 +3,8 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.IdempotencyPlugTest do
- use ExUnit.Case, async: true
+ # Relies on Cachex, has to stay synchronous
+ use Pleroma.DataCase
use Plug.Test
alias Pleroma.Web.Plugs.IdempotencyPlug
diff --git a/test/pleroma/web/plugs/uploaded_media_plug_test.exs b/test/pleroma/web/plugs/uploaded_media_plug_test.exs
index 7c8313121..bae9208ec 100644
--- a/test/pleroma/web/plugs/uploaded_media_plug_test.exs
+++ b/test/pleroma/web/plugs/uploaded_media_plug_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.UploadedMediaPlugTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Upload
defp upload_file(context) do
diff --git a/test/pleroma/web/plugs/user_enabled_plug_test.exs b/test/pleroma/web/plugs/user_enabled_plug_test.exs
index 71c56f03a..e9c9e5f3e 100644
--- a/test/pleroma/web/plugs/user_enabled_plug_test.exs
+++ b/test/pleroma/web/plugs/user_enabled_plug_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
- use Pleroma.Web.ConnCase, async: true
+ use Pleroma.Web.ConnCase
alias Pleroma.Web.Plugs.UserEnabledPlug
import Pleroma.Factory
diff --git a/test/pleroma/web/preload/providers/instance_test.exs b/test/pleroma/web/preload/providers/instance_test.exs
index 8493f2a94..6033899b0 100644
--- a/test/pleroma/web/preload/providers/instance_test.exs
+++ b/test/pleroma/web/preload/providers/instance_test.exs
@@ -50,7 +50,7 @@ test "it renders the frontend configurations", %{
"/api/pleroma/frontend_configurations" => fe_configs
} do
assert %{
- pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.png"}
+ pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.svg"}
} = fe_configs
end
end
diff --git a/test/pleroma/web/preload/providers/user_test.exs b/test/pleroma/web/preload/providers/user_test.exs
index 83f065e27..6be03af79 100644
--- a/test/pleroma/web/preload/providers/user_test.exs
+++ b/test/pleroma/web/preload/providers/user_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Preload.Providers.UserTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Web.Preload.Providers.User
diff --git a/test/pleroma/web/push/impl_test.exs b/test/pleroma/web/push/impl_test.exs
index 2a4a8fd06..d14e0bdef 100644
--- a/test/pleroma/web/push/impl_test.exs
+++ b/test/pleroma/web/push/impl_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Push.ImplTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
@@ -118,7 +118,7 @@ test "renders title and body for create activity" do
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(
%{
@@ -137,7 +137,7 @@ test "renders title and body for follow activity" do
user = insert(:user, nickname: "Bob")
other_user = insert(:user)
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: activity, type: "follow"}, user, object) ==
"@Bob has followed you"
@@ -156,7 +156,7 @@ test "renders title and body for announce activity" do
})
{:ok, announce_activity} = CommonAPI.repeat(activity.id, user)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: announce_activity}, user, object) ==
"@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
@@ -175,7 +175,7 @@ test "renders title and body for like activity" do
})
{:ok, activity} = CommonAPI.favorite(user, activity.id)
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: activity, type: "favourite"}, user, object) ==
"@Bob has favorited your post"
@@ -193,7 +193,7 @@ test "renders title and body for pleroma:emoji_reaction activity" do
})
{:ok, activity} = CommonAPI.react_with_emoji(activity.id, user, "👍")
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.format_body(%{activity: activity, type: "pleroma:emoji_reaction"}, user, object) ==
"@Bob reacted with 👍"
@@ -221,7 +221,7 @@ test "builds content for chat messages" do
recipient = insert(:user)
{:ok, chat} = CommonAPI.post_chat_message(user, recipient, "hey")
- object = Object.normalize(chat, false)
+ object = Object.normalize(chat, fetch: false)
[notification] = Notification.for_user(recipient)
res = Impl.build_content(notification, user, object)
@@ -245,7 +245,7 @@ test "builds content for chat messages with no content" do
{:ok, upload} = ActivityPub.upload(file, actor: user.ap_id)
{:ok, chat} = CommonAPI.post_chat_message(user, recipient, nil, media_id: upload.id)
- object = Object.normalize(chat, false)
+ object = Object.normalize(chat, fetch: false)
[notification] = Notification.for_user(recipient)
res = Impl.build_content(notification, user, object)
@@ -271,7 +271,7 @@ test "hides contents of notifications when option enabled" do
notif = insert(:notification, user: user2, activity: activity)
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "New Direct Message"
@@ -286,7 +286,7 @@ test "hides contents of notifications when option enabled" do
notif = insert(:notification, user: user2, activity: activity, type: "mention")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "New Mention"
@@ -297,7 +297,7 @@ test "hides contents of notifications when option enabled" do
notif = insert(:notification, user: user2, activity: activity, type: "favourite")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "New Favorite"
@@ -320,7 +320,7 @@ test "returns regular content when hiding contents option disabled" do
notif = insert(:notification, user: user2, activity: activity)
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body:
@@ -338,7 +338,7 @@ test "returns regular content when hiding contents option disabled" do
notif = insert(:notification, user: user2, activity: activity, type: "mention")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body:
@@ -351,7 +351,7 @@ test "returns regular content when hiding contents option disabled" do
notif = insert(:notification, user: user2, activity: activity, type: "favourite")
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
- object = Object.normalize(activity)
+ object = Object.normalize(activity, fetch: false)
assert Impl.build_content(notif, actor, object) == %{
body: "@Bob has favorited your post",
diff --git a/test/pleroma/web/rel_me_test.exs b/test/pleroma/web/rel_me_test.exs
index 65255916d..811cb0893 100644
--- a/test/pleroma/web/rel_me_test.exs
+++ b/test/pleroma/web/rel_me_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.RelMeTest do
- use ExUnit.Case
+ use Pleroma.DataCase
setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
diff --git a/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs b/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs
index 2f17bebd7..242521138 100644
--- a/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs
+++ b/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs
@@ -3,7 +3,8 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do
- use ExUnit.Case, async: true
+ # Relies on Cachex, needs to be synchronous
+ use Pleroma.DataCase
test "s3 signed url is parsed correct for expiration time" do
url = "https://pleroma.social/amz"
diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs
index ad66ddc9d..764b799bb 100644
--- a/test/pleroma/web/streamer_test.exs
+++ b/test/pleroma/web/streamer_test.exs
@@ -266,7 +266,7 @@ test "it sends chat messages to the 'user:pleroma_chat' stream", %{
{:ok, create_activity} =
CommonAPI.post_chat_message(other_user, user, "hey cirno", idempotency_key: "123")
- object = Object.normalize(create_activity, false)
+ object = Object.normalize(create_activity, fetch: false)
chat = Chat.get(user.id, other_user.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
cm_ref = %{cm_ref | chat: chat, object: object}
@@ -284,7 +284,7 @@ test "it sends chat messages to the 'user' stream", %{user: user, token: oauth_t
other_user = insert(:user)
{:ok, create_activity} = CommonAPI.post_chat_message(other_user, user, "hey cirno")
- object = Object.normalize(create_activity, false)
+ object = Object.normalize(create_activity, fetch: false)
chat = Chat.get(user.id, other_user.ap_id)
cm_ref = MessageReference.for_chat_and_object(chat, object)
cm_ref = %{cm_ref | chat: chat, object: object}
diff --git a/test/pleroma/web/twitter_api/controller_test.exs b/test/pleroma/web/twitter_api/controller_test.exs
index 464d0ea2e..b3ca67637 100644
--- a/test/pleroma/web/twitter_api/controller_test.exs
+++ b/test/pleroma/web/twitter_api/controller_test.exs
@@ -3,11 +3,11 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.TwitterAPI.ControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
- alias Pleroma.Builders.ActivityBuilder
alias Pleroma.Repo
alias Pleroma.User
+ alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OAuth.Token
import Pleroma.Factory
@@ -36,22 +36,20 @@ test "with credentials, with params" do
other_user = insert(:user)
{:ok, _activity} =
- ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: other_user})
+ CommonAPI.post(other_user, %{
+ status: "Hey @#{current_user.nickname}"
+ })
response_conn =
conn
- |> assign(:user, current_user)
|> get("/api/v1/notifications")
- [notification] = response = json_response(response_conn, 200)
-
- assert length(response) == 1
+ [notification] = json_response(response_conn, 200)
assert notification["pleroma"]["is_seen"] == false
response_conn =
conn
- |> assign(:user, current_user)
|> post("/api/qvitter/statuses/notifications/read", %{"latest_id" => notification["id"]})
[notification] = response = json_response(response_conn, 200)
diff --git a/test/pleroma/web/twitter_api/password_controller_test.exs b/test/pleroma/web/twitter_api/password_controller_test.exs
index 6d08075cc..c1f5bc5c7 100644
--- a/test/pleroma/web/twitter_api/password_controller_test.exs
+++ b/test/pleroma/web/twitter_api/password_controller_test.exs
@@ -37,8 +37,7 @@ test "it returns an error when the token has expired", %{conn: conn} do
user = insert(:user)
{:ok, token} = PasswordResetToken.create_token(user)
-
- :timer.sleep(2000)
+ {:ok, token} = time_travel(token, -2)
response =
conn
@@ -55,7 +54,7 @@ test "it fails for an expired token", %{conn: conn} do
user = insert(:user)
{:ok, token} = PasswordResetToken.create_token(user)
- :timer.sleep(2000)
+ {:ok, token} = time_travel(token, -2)
{:ok, _access_token} = Token.create(insert(:oauth_app), user, %{})
params = %{
diff --git a/test/pleroma/web/twitter_api/remote_follow_controller_test.exs b/test/pleroma/web/twitter_api/remote_follow_controller_test.exs
index a3e784d13..dfe5b02be 100644
--- a/test/pleroma/web/twitter_api/remote_follow_controller_test.exs
+++ b/test/pleroma/web/twitter_api/remote_follow_controller_test.exs
@@ -14,18 +14,27 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
import Pleroma.Factory
import Ecto.Query
- setup do
- Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
- :ok
- end
-
setup_all do: clear_config([:instance, :federating], true)
- setup do: clear_config([:instance])
- setup do: clear_config([:frontend_configurations, :pleroma_fe])
setup do: clear_config([:user, :deny_follow_blocked])
describe "GET /ostatus_subscribe - remote_follow/2" do
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
+ Tesla.Mock.mock(fn
+ %{method: :get, url: "https://mastodon.social/users/emelie/statuses/101849165031453009"} ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-type", "application/activity+json"}],
+ body: File.read!("test/fixtures/tesla_mock/status.emelie.json")
+ }
+
+ %{method: :get, url: "https://mastodon.social/users/emelie"} ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-type", "application/activity+json"}],
+ body: File.read!("test/fixtures/tesla_mock/emelie.json")
+ }
+ end)
+
assert conn
|> get(
remote_follow_path(conn, :follow, %{
@@ -36,6 +45,15 @@ test "adds status to pleroma instance if the `acct` is a status", %{conn: conn}
end
test "show follow account page if the `acct` is a account link", %{conn: conn} do
+ Tesla.Mock.mock(fn
+ %{method: :get, url: "https://mastodon.social/users/emelie"} ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-type", "application/activity+json"}],
+ body: File.read!("test/fixtures/tesla_mock/emelie.json")
+ }
+ end)
+
response =
conn
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
@@ -45,6 +63,15 @@ test "show follow account page if the `acct` is a account link", %{conn: conn} d
end
test "show follow page if the `acct` is a account link", %{conn: conn} do
+ Tesla.Mock.mock(fn
+ %{method: :get, url: "https://mastodon.social/users/emelie"} ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-type", "application/activity+json"}],
+ body: File.read!("test/fixtures/tesla_mock/emelie.json")
+ }
+ end)
+
user = insert(:user)
response =
@@ -56,7 +83,14 @@ test "show follow page if the `acct` is a account link", %{conn: conn} do
assert response =~ "Remote follow"
end
- test "show follow page with error when user cannot fecth by `acct` link", %{conn: conn} do
+ test "show follow page with error when user can not be fetched by `acct` link", %{conn: conn} do
+ Tesla.Mock.mock(fn
+ %{method: :get, url: "https://mastodon.social/users/not_found"} ->
+ %Tesla.Env{
+ status: 404
+ }
+ end)
+
user = insert(:user)
assert capture_log(fn ->
diff --git a/test/pleroma/web/twitter_api/twitter_api_test.exs b/test/pleroma/web/twitter_api/twitter_api_test.exs
index 20a45cb6f..5586a9a13 100644
--- a/test/pleroma/web/twitter_api/twitter_api_test.exs
+++ b/test/pleroma/web/twitter_api/twitter_api_test.exs
@@ -80,13 +80,9 @@ test "it sends confirmation email if :account_activation_required is specified i
end
test "it sends an admin email if :account_approval_required is specified in instance config" do
- admin = insert(:user, is_admin: true)
- setting = Pleroma.Config.get([:instance, :account_approval_required])
+ clear_config([:instance, :account_approval_required], true)
- unless setting do
- Pleroma.Config.put([:instance, :account_approval_required], true)
- on_exit(fn -> Pleroma.Config.put([:instance, :account_approval_required], setting) end)
- end
+ admin = insert(:user, is_admin: true)
data = %{
:username => "lain",
@@ -103,15 +99,24 @@ test "it sends an admin email if :account_approval_required is specified in inst
assert user.approval_pending
- email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
+ user_email = Pleroma.Emails.UserEmail.approval_pending_email(user)
+ admin_email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
notify_email = Pleroma.Config.get([:instance, :notify_email])
instance_name = Pleroma.Config.get([:instance, :name])
+ # User approval email
+ Swoosh.TestAssertions.assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: user_email.html_body
+ )
+
+ # Admin email
Swoosh.TestAssertions.assert_email_sent(
from: {instance_name, notify_email},
to: {admin.name, admin.email},
- html_body: email.html_body
+ html_body: admin_email.html_body
)
end
@@ -423,10 +428,4 @@ test "it returns the error on registration problems" do
assert is_binary(error)
refute User.get_cached_by_nickname("lain")
end
-
- setup do
- Supervisor.terminate_child(Pleroma.Supervisor, Cachex)
- Supervisor.restart_child(Pleroma.Supervisor, Cachex)
- :ok
- end
end
diff --git a/test/pleroma/web/uploader_controller_test.exs b/test/pleroma/web/uploader_controller_test.exs
index 21e518236..00f9e72ec 100644
--- a/test/pleroma/web/uploader_controller_test.exs
+++ b/test/pleroma/web/uploader_controller_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.UploaderControllerTest do
- use Pleroma.Web.ConnCase
+ use Pleroma.Web.ConnCase, async: true
alias Pleroma.Uploaders.Uploader
describe "callback/2" do
diff --git a/test/pleroma/web/web_finger/web_finger_controller_test.exs b/test/pleroma/web/web_finger/web_finger_controller_test.exs
index 0023f1e81..ce9eb0650 100644
--- a/test/pleroma/web/web_finger/web_finger_controller_test.exs
+++ b/test/pleroma/web/web_finger/web_finger_controller_test.exs
@@ -30,14 +30,24 @@ test "GET host-meta" do
end
test "Webfinger JRD" do
- user = insert(:user)
+ user =
+ insert(:user,
+ ap_id: "https://hyrule.world/users/zelda",
+ also_known_as: ["https://mushroom.kingdom/users/toad"]
+ )
response =
build_conn()
|> put_req_header("accept", "application/jrd+json")
|> get("/.well-known/webfinger?resource=acct:#{user.nickname}@localhost")
+ |> json_response(200)
- assert json_response(response, 200)["subject"] == "acct:#{user.nickname}@localhost"
+ assert response["subject"] == "acct:#{user.nickname}@localhost"
+
+ assert response["aliases"] == [
+ "https://hyrule.world/users/zelda",
+ "https://mushroom.kingdom/users/toad"
+ ]
end
test "it returns 404 when user isn't found (JSON)" do
@@ -51,14 +61,20 @@ test "it returns 404 when user isn't found (JSON)" do
end
test "Webfinger XML" do
- user = insert(:user)
+ user =
+ insert(:user,
+ ap_id: "https://hyrule.world/users/zelda",
+ also_known_as: ["https://mushroom.kingdom/users/toad"]
+ )
response =
build_conn()
|> put_req_header("accept", "application/xrd+xml")
|> get("/.well-known/webfinger?resource=acct:#{user.nickname}@localhost")
+ |> response(200)
- assert response(response, 200)
+ assert response =~ "https://hyrule.world/users/zelda"
+ assert response =~ "https://mushroom.kingdom/users/toad"
end
test "it returns 404 when user isn't found (XML)" do
diff --git a/test/pleroma/web/web_finger_test.exs b/test/pleroma/web/web_finger_test.exs
index 96fc0bbaa..cdb84ae1e 100644
--- a/test/pleroma/web/web_finger_test.exs
+++ b/test/pleroma/web/web_finger_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.WebFingerTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Web.WebFinger
import Pleroma.Factory
import Tesla.Mock
@@ -56,12 +56,13 @@ test "returns the ActivityPub actor URI for an ActivityPub user" do
{:ok, _data} = WebFinger.finger(user)
end
- test "returns the ActivityPub actor URI for an ActivityPub user with the ld+json mimetype" do
+ test "returns the ActivityPub actor URI and subscribe address for an ActivityPub user with the ld+json mimetype" do
user = "kaniini@gerzilla.de"
{:ok, data} = WebFinger.finger(user)
assert data["ap_id"] == "https://gerzilla.de/channel/kaniini"
+ assert data["subscribe_address"] == "https://gerzilla.de/follow?f=&url={uri}"
end
test "it work for AP-only user" do
diff --git a/test/pleroma/workers/cron/new_users_digest_worker_test.exs b/test/pleroma/workers/cron/new_users_digest_worker_test.exs
index 129534cb1..e00ed6745 100644
--- a/test/pleroma/workers/cron/new_users_digest_worker_test.exs
+++ b/test/pleroma/workers/cron/new_users_digest_worker_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
import Pleroma.Factory
alias Pleroma.Tests.ObanHelpers
@@ -28,7 +28,7 @@ test "it sends new users digest emails" do
assert email.html_body =~ user.nickname
assert email.html_body =~ user2.nickname
assert email.html_body =~ "cofe"
- assert email.html_body =~ "#{Pleroma.Web.Endpoint.url()}/static/logo.png"
+ assert email.html_body =~ "#{Pleroma.Web.Endpoint.url()}/static/logo.svg"
end
test "it doesn't fail when admin has no email" do
diff --git a/test/pleroma/workers/scheduled_activity_worker_test.exs b/test/pleroma/workers/scheduled_activity_worker_test.exs
index f3eddf7b1..c9e2091a9 100644
--- a/test/pleroma/workers/scheduled_activity_worker_test.exs
+++ b/test/pleroma/workers/scheduled_activity_worker_test.exs
@@ -36,7 +36,7 @@ test "creates a status from the scheduled activity" do
refute Repo.get(ScheduledActivity, scheduled_activity.id)
activity = Repo.all(Pleroma.Activity) |> Enum.find(&(&1.actor == user.ap_id))
- assert Pleroma.Object.normalize(activity).data["content"] == "hi"
+ assert Pleroma.Object.normalize(activity, fetch: false).data["content"] == "hi"
end
test "adds log message if ScheduledActivity isn't find" do
diff --git a/test/pleroma/xml_builder_test.exs b/test/pleroma/xml_builder_test.exs
index 059384c34..a4c73359d 100644
--- a/test/pleroma/xml_builder_test.exs
+++ b/test/pleroma/xml_builder_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.XmlBuilderTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.XmlBuilder
test "Build a basic xml string from a tuple" do
diff --git a/test/support/cachex_proxy.ex b/test/support/cachex_proxy.ex
new file mode 100644
index 000000000..e296b5c6a
--- /dev/null
+++ b/test/support/cachex_proxy.ex
@@ -0,0 +1,40 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.CachexProxy do
+ @behaviour Pleroma.Caching
+
+ @impl true
+ defdelegate get!(cache, key), to: Cachex
+
+ @impl true
+ defdelegate stream!(cache, key), to: Cachex
+
+ @impl true
+ defdelegate put(cache, key, value, options), to: Cachex
+
+ @impl true
+ defdelegate put(cache, key, value), to: Cachex
+
+ @impl true
+ defdelegate get_and_update(cache, key, func), to: Cachex
+
+ @impl true
+ defdelegate get(cache, key), to: Cachex
+
+ @impl true
+ defdelegate fetch!(cache, key, func), to: Cachex
+
+ @impl true
+ defdelegate expire_at(cache, str, num), to: Cachex
+
+ @impl true
+ defdelegate exists?(cache, key), to: Cachex
+
+ @impl true
+ defdelegate del(cache, key), to: Cachex
+
+ @impl true
+ defdelegate execute!(cache, func), to: Cachex
+end
diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex
index 114184a9f..f4696adb3 100644
--- a/test/support/channel_case.ex
+++ b/test/support/channel_case.ex
@@ -33,8 +33,14 @@ defmodule Pleroma.Web.ChannelCase do
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
- unless tags[:async] do
+ if tags[:async] do
+ Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
+ Mox.set_mox_private()
+ else
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
+ Mox.stub_with(Pleroma.CachexMock, Pleroma.CachexProxy)
+ Mox.set_mox_global()
+ Pleroma.DataCase.clear_cachex()
end
:ok
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index 47cb65a80..f20e3d955 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -116,12 +116,16 @@ defp json_response_and_validate_schema(conn, _status) do
end
setup tags do
- Cachex.clear(:user_cache)
- Cachex.clear(:object_cache)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
- unless tags[:async] do
+ if tags[:async] do
+ Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
+ Mox.set_mox_private()
+ else
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
+ Mox.stub_with(Pleroma.CachexMock, Pleroma.CachexProxy)
+ Mox.set_mox_global()
+ Pleroma.DataCase.clear_cachex()
end
if tags[:needs_streamer] do
@@ -132,6 +136,10 @@ defp json_response_and_validate_schema(conn, _status) do
})
end
+ Pleroma.DataCase.stub_pipeline()
+
+ Mox.verify_on_exit!()
+
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end
diff --git a/test/support/data_case.ex b/test/support/data_case.ex
index d5456521c..0b41f0f63 100644
--- a/test/support/data_case.ex
+++ b/test/support/data_case.ex
@@ -45,13 +45,34 @@ defp oauth_access(scopes, opts \\ []) do
end
end
+ def clear_cachex do
+ Pleroma.Supervisor
+ |> Supervisor.which_children()
+ |> Enum.each(fn
+ {name, _, _, [Cachex]} ->
+ name
+ |> to_string
+ |> String.trim_leading("cachex_")
+ |> Kernel.<>("_cache")
+ |> String.to_existing_atom()
+ |> Cachex.clear()
+
+ _ ->
+ nil
+ end)
+ end
+
setup tags do
- Cachex.clear(:user_cache)
- Cachex.clear(:object_cache)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
- unless tags[:async] do
+ if tags[:async] do
+ Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
+ Mox.set_mox_private()
+ else
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, {:shared, self()})
+ Mox.stub_with(Pleroma.CachexMock, Pleroma.CachexProxy)
+ Mox.set_mox_global()
+ clear_cachex()
end
if tags[:needs_streamer] do
@@ -62,9 +83,27 @@ defp oauth_access(scopes, opts \\ []) do
})
end
+ stub_pipeline()
+
+ Mox.verify_on_exit!()
+
:ok
end
+ def stub_pipeline do
+ Mox.stub_with(Pleroma.Web.ActivityPub.SideEffectsMock, Pleroma.Web.ActivityPub.SideEffects)
+
+ Mox.stub_with(
+ Pleroma.Web.ActivityPub.ObjectValidatorMock,
+ Pleroma.Web.ActivityPub.ObjectValidator
+ )
+
+ Mox.stub_with(Pleroma.Web.ActivityPub.MRFMock, Pleroma.Web.ActivityPub.MRF)
+ Mox.stub_with(Pleroma.Web.ActivityPub.ActivityPubMock, Pleroma.Web.ActivityPub.ActivityPub)
+ Mox.stub_with(Pleroma.Web.FederatorMock, Pleroma.Web.Federator)
+ Mox.stub_with(Pleroma.ConfigMock, Pleroma.Config)
+ end
+
def ensure_local_uploader(context) do
test_uploader = Map.get(context, :uploader, Pleroma.Uploaders.Local)
uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])
diff --git a/test/support/factory.ex b/test/support/factory.ex
index bbb04837a..786d12c4b 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -291,7 +291,7 @@ def announce_activity_factory(attrs \\ %{}) do
def like_activity_factory(attrs \\ %{}) do
note_activity = attrs[:note_activity] || insert(:note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity, fetch: false)
user = insert(:user)
data =
diff --git a/test/support/helpers.ex b/test/support/helpers.ex
index 224034521..15e8cbd9d 100644
--- a/test/support/helpers.ex
+++ b/test/support/helpers.ex
@@ -55,6 +55,14 @@ defmacro __using__(_opts) do
clear_config: 2
]
+ def time_travel(entity, seconds) do
+ new_time = NaiveDateTime.add(entity.inserted_at, seconds)
+
+ entity
+ |> Ecto.Changeset.change(%{inserted_at: new_time, updated_at: new_time})
+ |> Pleroma.Repo.update()
+ end
+
def to_datetime(%NaiveDateTime{} = naive_datetime) do
naive_datetime
|> DateTime.from_naive!("Etc/UTC")
diff --git a/test/support/mocks.ex b/test/support/mocks.ex
new file mode 100644
index 000000000..442ff5b71
--- /dev/null
+++ b/test/support/mocks.ex
@@ -0,0 +1,30 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+Mox.defmock(Pleroma.CachexMock, for: Pleroma.Caching)
+
+Mox.defmock(Pleroma.Web.ActivityPub.ObjectValidatorMock,
+ for: Pleroma.Web.ActivityPub.ObjectValidator.Validating
+)
+
+Mox.defmock(Pleroma.Web.ActivityPub.MRFMock,
+ for: Pleroma.Web.ActivityPub.MRF.PipelineFiltering
+)
+
+Mox.defmock(Pleroma.Web.ActivityPub.ActivityPubMock,
+ for: [
+ Pleroma.Web.ActivityPub.ActivityPub.Persisting,
+ Pleroma.Web.ActivityPub.ActivityPub.Streaming
+ ]
+)
+
+Mox.defmock(Pleroma.Web.ActivityPub.SideEffectsMock,
+ for: Pleroma.Web.ActivityPub.SideEffects.Handling
+)
+
+Mox.defmock(Pleroma.Web.FederatorMock, for: Pleroma.Web.Federator.Publishing)
+
+Mox.defmock(Pleroma.ConfigMock, for: Pleroma.Config.Getting)
+
+Mox.defmock(Pleroma.LoggerMock, for: Pleroma.Logging)
diff --git a/test/support/null_cache.ex b/test/support/null_cache.ex
new file mode 100644
index 000000000..c63df6a39
--- /dev/null
+++ b/test/support/null_cache.ex
@@ -0,0 +1,49 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.NullCache do
+ @moduledoc """
+ A module simulating a permanently empty cache.
+ """
+ @behaviour Pleroma.Caching
+
+ @impl true
+ def get!(_, _), do: nil
+
+ @impl true
+ def put(_, _, _, _ \\ nil), do: {:ok, true}
+
+ @impl true
+ def stream!(_, _), do: []
+
+ @impl true
+ def get(_, _), do: {:ok, nil}
+
+ @impl true
+ def fetch!(_, key, func) do
+ case func.(key) do
+ {_, res} -> res
+ res -> res
+ end
+ end
+
+ @impl true
+ def get_and_update(_, _, func) do
+ func.(nil)
+ end
+
+ @impl true
+ def expire_at(_, _, _), do: {:ok, true}
+
+ @impl true
+ def exists?(_, _), do: {:ok, false}
+
+ @impl true
+ def execute!(_, func) do
+ func.(:nothing)
+ end
+
+ @impl true
+ def del(_, _), do: {:ok, true}
+end