Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into feature/expire-mutes
This commit is contained in:
commit
dd2b3a8da9
767 changed files with 8187 additions and 4306 deletions
166
test/credo/check/consistency/file_location.ex
Normal file
166
test/credo/check/consistency/file_location.ex
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Originally taken from
|
||||
# https://github.com/VeryBigThings/elixir_common/blob/master/lib/vbt/credo/check/consistency/file_location.ex
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Credo.Check.Consistency.FileLocation do
|
||||
@moduledoc false
|
||||
|
||||
# credo:disable-for-this-file Credo.Check.Readability.Specs
|
||||
|
||||
@checkdoc """
|
||||
File location should follow the namespace hierarchy of the module it defines.
|
||||
|
||||
Examples:
|
||||
|
||||
- `lib/my_system.ex` should define the `MySystem` module
|
||||
- `lib/my_system/accounts.ex` should define the `MySystem.Accounts` module
|
||||
"""
|
||||
@explanation [warning: @checkdoc]
|
||||
|
||||
@special_namespaces [
|
||||
"controllers",
|
||||
"views",
|
||||
"operations",
|
||||
"channels"
|
||||
]
|
||||
|
||||
# `use Credo.Check` required that module attributes are already defined, so we need
|
||||
# to place these attributes
|
||||
# before use/alias expressions.
|
||||
# credo:disable-for-next-line VBT.Credo.Check.Consistency.ModuleLayout
|
||||
use Credo.Check, category: :warning, base_priority: :high
|
||||
|
||||
alias Credo.Code
|
||||
|
||||
def run(source_file, params \\ []) do
|
||||
case verify(source_file, params) do
|
||||
:ok ->
|
||||
[]
|
||||
|
||||
{:error, module, expected_file} ->
|
||||
error(IssueMeta.for(source_file, params), module, expected_file)
|
||||
end
|
||||
end
|
||||
|
||||
defp verify(source_file, params) do
|
||||
source_file.filename
|
||||
|> Path.relative_to_cwd()
|
||||
|> verify(Code.ast(source_file), params)
|
||||
end
|
||||
|
||||
@doc false
|
||||
def verify(relative_path, ast, params) do
|
||||
if verify_path?(relative_path, params),
|
||||
do: ast |> main_module() |> verify_module(relative_path, params),
|
||||
else: :ok
|
||||
end
|
||||
|
||||
defp verify_path?(relative_path, params) do
|
||||
case Path.split(relative_path) do
|
||||
["lib" | _] -> not exclude?(relative_path, params)
|
||||
["test", "support" | _] -> false
|
||||
["test", "test_helper.exs"] -> false
|
||||
["test" | _] -> not exclude?(relative_path, params)
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
|
||||
defp exclude?(relative_path, params) do
|
||||
params
|
||||
|> Keyword.get(:exclude, [])
|
||||
|> Enum.any?(&String.starts_with?(relative_path, &1))
|
||||
end
|
||||
|
||||
defp main_module(ast) do
|
||||
{_ast, modules} = Macro.prewalk(ast, [], &traverse/2)
|
||||
Enum.at(modules, -1)
|
||||
end
|
||||
|
||||
defp traverse({:defmodule, _meta, args}, modules) do
|
||||
[{:__aliases__, _, name_parts}, _module_body] = args
|
||||
{args, [Module.concat(name_parts) | modules]}
|
||||
end
|
||||
|
||||
defp traverse(ast, state), do: {ast, state}
|
||||
|
||||
# empty file - shouldn't really happen, but we'll let it through
|
||||
defp verify_module(nil, _relative_path, _params), do: :ok
|
||||
|
||||
defp verify_module(main_module, relative_path, params) do
|
||||
parsed_path = parsed_path(relative_path, params)
|
||||
|
||||
expected_file =
|
||||
expected_file_base(parsed_path.root, main_module) <>
|
||||
Path.extname(parsed_path.allowed)
|
||||
|
||||
cond do
|
||||
expected_file == parsed_path.allowed ->
|
||||
:ok
|
||||
|
||||
special_namespaces?(parsed_path.allowed) ->
|
||||
original_path = parsed_path.allowed
|
||||
|
||||
namespace =
|
||||
Enum.find(@special_namespaces, original_path, fn namespace ->
|
||||
String.contains?(original_path, namespace)
|
||||
end)
|
||||
|
||||
allowed = String.replace(original_path, "/" <> namespace, "")
|
||||
|
||||
if expected_file == allowed,
|
||||
do: :ok,
|
||||
else: {:error, main_module, expected_file}
|
||||
|
||||
true ->
|
||||
{:error, main_module, expected_file}
|
||||
end
|
||||
end
|
||||
|
||||
defp special_namespaces?(path), do: String.contains?(path, @special_namespaces)
|
||||
|
||||
defp parsed_path(relative_path, params) do
|
||||
parts = Path.split(relative_path)
|
||||
|
||||
allowed =
|
||||
Keyword.get(params, :ignore_folder_namespace, %{})
|
||||
|> Stream.flat_map(fn {root, folders} -> Enum.map(folders, &Path.join([root, &1])) end)
|
||||
|> Stream.map(&Path.split/1)
|
||||
|> Enum.find(&List.starts_with?(parts, &1))
|
||||
|> case do
|
||||
nil ->
|
||||
relative_path
|
||||
|
||||
ignore_parts ->
|
||||
Stream.drop(ignore_parts, -1)
|
||||
|> Enum.concat(Stream.drop(parts, length(ignore_parts)))
|
||||
|> Path.join()
|
||||
end
|
||||
|
||||
%{root: hd(parts), allowed: allowed}
|
||||
end
|
||||
|
||||
defp expected_file_base(root_folder, module) do
|
||||
{parent_namespace, module_name} = module |> Module.split() |> Enum.split(-1)
|
||||
|
||||
relative_path =
|
||||
if parent_namespace == [],
|
||||
do: "",
|
||||
else: parent_namespace |> Module.concat() |> Macro.underscore()
|
||||
|
||||
file_name = module_name |> Module.concat() |> Macro.underscore()
|
||||
|
||||
Path.join([root_folder, relative_path, file_name])
|
||||
end
|
||||
|
||||
defp error(issue_meta, module, expected_file) do
|
||||
format_issue(issue_meta,
|
||||
message:
|
||||
"Mismatch between file name and main module #{inspect(module)}. " <>
|
||||
"Expected file path to be #{expected_file}. " <>
|
||||
"Either move the file or rename the module.",
|
||||
line_no: 1
|
||||
)
|
||||
end
|
||||
end
|
||||
4
test/fixtures/config/temp.secret.exs
vendored
4
test/fixtures/config/temp.secret.exs
vendored
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
use Mix.Config
|
||||
|
||||
config :pleroma, :first_setting, key: "value", key2: [Pleroma.Repo]
|
||||
|
|
|
|||
68
test/fixtures/mastodon-post-activity-nsfw.json
vendored
Normal file
68
test/fixtures/mastodon-post-activity-nsfw.json
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"Emoji": "toot:Emoji",
|
||||
"Hashtag": "as:Hashtag",
|
||||
"atomUri": "ostatus:atomUri",
|
||||
"conversation": "ostatus:conversation",
|
||||
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"movedTo": "as:movedTo",
|
||||
"ostatus": "http://ostatus.org#",
|
||||
"toot": "http://joinmastodon.org/ns#"
|
||||
}
|
||||
],
|
||||
"actor": "http://mastodon.example.org/users/admin",
|
||||
"cc": [
|
||||
"http://mastodon.example.org/users/admin/followers",
|
||||
"http://localtesting.pleroma.lol/users/lain"
|
||||
],
|
||||
"id": "http://mastodon.example.org/users/admin/statuses/99512778738411822/activity",
|
||||
"nickname": "lain",
|
||||
"object": {
|
||||
"atomUri": "http://mastodon.example.org/users/admin/statuses/99512778738411822",
|
||||
"attachment": [],
|
||||
"attributedTo": "http://mastodon.example.org/users/admin",
|
||||
"cc": [
|
||||
"http://mastodon.example.org/users/admin/followers",
|
||||
"http://localtesting.pleroma.lol/users/lain"
|
||||
],
|
||||
"content": "<p><span class=\"h-card\"><a href=\"http://localtesting.pleroma.lol/users/lain\" class=\"u-url mention\">@<span>lain</span></a></span> #moo</p>",
|
||||
"conversation": "tag:mastodon.example.org,2018-02-12:objectId=20:objectType=Conversation",
|
||||
"id": "http://mastodon.example.org/users/admin/statuses/99512778738411822",
|
||||
"inReplyTo": null,
|
||||
"inReplyToAtomUri": null,
|
||||
"published": "2018-02-12T14:08:20Z",
|
||||
"summary": "cw",
|
||||
"tag": [
|
||||
{
|
||||
"href": "http://localtesting.pleroma.lol/users/lain",
|
||||
"name": "@lain@localtesting.pleroma.lol",
|
||||
"type": "Mention"
|
||||
},
|
||||
{
|
||||
"href": "http://mastodon.example.org/tags/nsfw",
|
||||
"name": "#NSFW",
|
||||
"type": "Hashtag"
|
||||
}
|
||||
],
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"type": "Note",
|
||||
"url": "http://mastodon.example.org/@admin/99512778738411822"
|
||||
},
|
||||
"published": "2018-02-12T14:08:20Z",
|
||||
"signature": {
|
||||
"created": "2018-02-12T14:08:20Z",
|
||||
"creator": "http://mastodon.example.org/users/admin#main-key",
|
||||
"signatureValue": "rnNfcopkc6+Ju73P806popcfwrK9wGYHaJVG1/ZvrlEbWVDzaHjkXqj9Q3/xju5l8CSn9tvSgCCtPFqZsFQwn/pFIFUcw7ZWB2xi4bDm3NZ3S4XQ8JRaaX7og5hFxAhWkGhJhAkfxVnOg2hG+w2d/7d7vRVSC1vo5ip4erUaA/PkWusZvPIpxnRWoXaxJsFmVx0gJgjpJkYDyjaXUlp+jmaoseeZ4EPQUWqHLKJ59PRG0mg8j2xAjYH9nQaN14qMRmTGPxY8gfv/CUFcatA+8VJU9KEsJkDAwLVvglydNTLGrxpAJU78a2eaht0foV43XUIZGe3DKiJPgE+UOKGCJw==",
|
||||
"type": "RsaSignature2017"
|
||||
},
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"type": "Create"
|
||||
}
|
||||
46
test/fixtures/mewmew_no_name.json
vendored
Normal file
46
test/fixtures/mewmew_no_name.json
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"@context" : [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://princess.cat/schemas/litepub-0.1.jsonld",
|
||||
{
|
||||
"@language" : "und"
|
||||
}
|
||||
],
|
||||
"attachment" : [],
|
||||
"capabilities" : {
|
||||
"acceptsChatMessages" : true
|
||||
},
|
||||
"discoverable" : false,
|
||||
"endpoints" : {
|
||||
"oauthAuthorizationEndpoint" : "https://princess.cat/oauth/authorize",
|
||||
"oauthRegistrationEndpoint" : "https://princess.cat/api/v1/apps",
|
||||
"oauthTokenEndpoint" : "https://princess.cat/oauth/token",
|
||||
"sharedInbox" : "https://princess.cat/inbox",
|
||||
"uploadMedia" : "https://princess.cat/api/ap/upload_media"
|
||||
},
|
||||
"followers" : "https://princess.cat/users/mewmew/followers",
|
||||
"following" : "https://princess.cat/users/mewmew/following",
|
||||
"icon" : {
|
||||
"type" : "Image",
|
||||
"url" : "https://princess.cat/media/12794fb50e86911e65be97f69196814049dcb398a2f8b58b99bb6591576e648c.png?name=blobcatpresentpink.png"
|
||||
},
|
||||
"id" : "https://princess.cat/users/mewmew",
|
||||
"image" : {
|
||||
"type" : "Image",
|
||||
"url" : "https://princess.cat/media/05d8bf3953ab6028fc920494ffc643fbee9dcef40d7bdd06f107e19acbfbd7f9.png"
|
||||
},
|
||||
"inbox" : "https://princess.cat/users/mewmew/inbox",
|
||||
"manuallyApprovesFollowers" : true,
|
||||
"name" : " ",
|
||||
"outbox" : "https://princess.cat/users/mewmew/outbox",
|
||||
"preferredUsername" : "mewmew",
|
||||
"publicKey" : {
|
||||
"id" : "https://princess.cat/users/mewmew#main-key",
|
||||
"owner" : "https://princess.cat/users/mewmew",
|
||||
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAru7VpygVef4zrFwnj0Mh\nrbO/2z2EdKN3rERtNrT8zWsLXNLQ50lfpRPnGDrd+xq7Rva4EIu0d5KJJ9n4vtY0\nuxK3On9vA2oyjLlR9O0lI3XTrHJborG3P7IPXrmNUMFpHiFHNqHp5tugUrs1gUFq\n7tmOmM92IP4Wjk8qNHFcsfnUbaPTX7sNIhteQKdi5HrTb/6lrEIe4G/FlMKRqxo3\nRNHuv6SNFQuiUKvFzjzazvjkjvBSm+aFROgdHa2tKl88StpLr7xmuY8qNFCRT6W0\nLacRp6c8ah5f03Kd+xCBVhCKvKaF1K0ERnQTBiitUh85md+Mtx/CoDoLnmpnngR3\nvQIDAQAB\n-----END PUBLIC KEY-----\n\n"
|
||||
},
|
||||
"summary" : "please reply to my posts as direct messages if you have many followers",
|
||||
"tag" : [],
|
||||
"type" : "Person",
|
||||
"url" : "https://princess.cat/users/mewmew"
|
||||
}
|
||||
2
test/fixtures/modules/runtime_module.ex
vendored
2
test/fixtures/modules/runtime_module.ex
vendored
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule RuntimeModule do
|
||||
defmodule Fixtures.Modules.RuntimeModule do
|
||||
@moduledoc """
|
||||
This is a dummy module to test custom runtime modules.
|
||||
"""
|
||||
|
|
|
|||
BIN
test/instance_static/emoji/blobs.gg/blank.png
Normal file
BIN
test/instance_static/emoji/blobs.gg/blank.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 B |
11
test/instance_static/emoji/blobs.gg/pack.json
Normal file
11
test/instance_static/emoji/blobs.gg/pack.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"files": {
|
||||
"blank": "blank.png"
|
||||
},
|
||||
"pack": {
|
||||
"description": "Test description",
|
||||
"homepage": "https://pleroma.social",
|
||||
"license": "Test license",
|
||||
"share-files": true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.DigestTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
127
test/mix/tasks/pleroma/email_test.exs
Normal file
127
test/mix/tasks/pleroma/email_test.exs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.EmailTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
import Swoosh.TestAssertions
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup_all do
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(Mix.Shell.IO)
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
|
||||
setup do: clear_config([:instance, :account_activation_required], true)
|
||||
|
||||
describe "pleroma.email test" do
|
||||
test "Sends test email with no given address" do
|
||||
mail_to = Config.get([:instance, :email])
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Email.run(["test"])
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_receive {:mix_shell, :info, [message]}
|
||||
assert message =~ "Test email has been sent"
|
||||
|
||||
assert_email_sent(
|
||||
to: mail_to,
|
||||
html_body: ~r/a test email was requested./i
|
||||
)
|
||||
end
|
||||
|
||||
test "Sends test email with given address" do
|
||||
mail_to = "hewwo@example.com"
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Email.run(["test", "--to", mail_to])
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_receive {:mix_shell, :info, [message]}
|
||||
assert message =~ "Test email has been sent"
|
||||
|
||||
assert_email_sent(
|
||||
to: mail_to,
|
||||
html_body: ~r/a test email was requested./i
|
||||
)
|
||||
end
|
||||
|
||||
test "Sends confirmation emails" do
|
||||
local_user1 =
|
||||
insert(:user, %{
|
||||
confirmation_pending: true,
|
||||
confirmation_token: "mytoken",
|
||||
deactivated: false,
|
||||
email: "local1@pleroma.com",
|
||||
local: true
|
||||
})
|
||||
|
||||
local_user2 =
|
||||
insert(:user, %{
|
||||
confirmation_pending: true,
|
||||
confirmation_token: "mytoken",
|
||||
deactivated: false,
|
||||
email: "local2@pleroma.com",
|
||||
local: true
|
||||
})
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Email.run(["resend_confirmation_emails"])
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_email_sent(to: {local_user1.name, local_user1.email})
|
||||
assert_email_sent(to: {local_user2.name, local_user2.email})
|
||||
end
|
||||
|
||||
test "Does not send confirmation email to inappropriate users" do
|
||||
# confirmed user
|
||||
insert(:user, %{
|
||||
confirmation_pending: false,
|
||||
confirmation_token: "mytoken",
|
||||
deactivated: false,
|
||||
email: "confirmed@pleroma.com",
|
||||
local: true
|
||||
})
|
||||
|
||||
# remote user
|
||||
insert(:user, %{
|
||||
deactivated: false,
|
||||
email: "remote@not-pleroma.com",
|
||||
local: false
|
||||
})
|
||||
|
||||
# deactivated user =
|
||||
insert(:user, %{
|
||||
deactivated: true,
|
||||
email: "deactivated@pleroma.com",
|
||||
local: false
|
||||
})
|
||||
|
||||
# invisible user
|
||||
insert(:user, %{
|
||||
deactivated: false,
|
||||
email: "invisible@pleroma.com",
|
||||
local: true,
|
||||
invisible: true
|
||||
})
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Email.run(["resend_confirmation_emails"])
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
refute_email_sent()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.EmojiTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.FrontendTest do
|
||||
defmodule Mix.Tasks.Pleroma.FrontendTest do
|
||||
use Pleroma.DataCase
|
||||
alias Mix.Tasks.Pleroma.Frontend
|
||||
|
||||
|
|
@ -2,9 +2,11 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.InstanceTest do
|
||||
defmodule Mix.Tasks.Pleroma.InstanceTest do
|
||||
use ExUnit.Case
|
||||
|
||||
@release_env_file "./test/pleroma.test.env"
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(tmp_path())
|
||||
|
||||
|
|
@ -16,6 +18,8 @@ defmodule Pleroma.InstanceTest do
|
|||
File.rm_rf(Path.join(static_dir, "robots.txt"))
|
||||
end
|
||||
|
||||
if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file)
|
||||
|
||||
Pleroma.Config.put([:instance, :static_dir], static_dir)
|
||||
end)
|
||||
|
||||
|
|
@ -63,7 +67,15 @@ defmodule Pleroma.InstanceTest do
|
|||
"--uploads-dir",
|
||||
"test/uploads",
|
||||
"--static-dir",
|
||||
"./test/../test/instance/static/"
|
||||
"./test/../test/instance/static/",
|
||||
"--strip-uploads",
|
||||
"y",
|
||||
"--dedupe-uploads",
|
||||
"n",
|
||||
"--anonymize-uploads",
|
||||
"n",
|
||||
"--release-env-file",
|
||||
@release_env_file
|
||||
])
|
||||
end
|
||||
|
||||
|
|
@ -82,8 +94,12 @@ defmodule Pleroma.InstanceTest do
|
|||
assert generated_config =~ "password: \"dbpass\""
|
||||
assert generated_config =~ "configurable_from_database: true"
|
||||
assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]"
|
||||
assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
|
||||
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
|
||||
assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
|
||||
assert File.exists?(@release_env_file)
|
||||
|
||||
assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/
|
||||
end
|
||||
|
||||
defp generated_setup_psql do
|
||||
|
|
@ -81,6 +81,80 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
|
|||
assert undo_activity.data["object"]["id"] == cancelled_activity.data["id"]
|
||||
refute "#{target_instance}/followers" in User.following(local_user)
|
||||
end
|
||||
|
||||
test "unfollow when relay is dead" do
|
||||
user = insert(:user)
|
||||
target_instance = user.ap_id
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["follow", target_instance])
|
||||
|
||||
%User{ap_id: follower_id} = local_user = Relay.get_actor()
|
||||
target_user = User.get_cached_by_ap_id(target_instance)
|
||||
follow_activity = Utils.fetch_latest_follow(local_user, target_user)
|
||||
User.follow(local_user, target_user)
|
||||
|
||||
assert "#{target_instance}/followers" in User.following(local_user)
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: ^target_instance} ->
|
||||
%Tesla.Env{status: 404}
|
||||
end)
|
||||
|
||||
Pleroma.Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
|
||||
|
||||
cancelled_activity = Activity.get_by_ap_id(follow_activity.data["id"])
|
||||
assert cancelled_activity.data["state"] == "accept"
|
||||
|
||||
assert [] ==
|
||||
ActivityPub.fetch_activities(
|
||||
[],
|
||||
%{
|
||||
type: "Undo",
|
||||
actor_id: follower_id,
|
||||
skip_preload: true,
|
||||
invisible_actors: true
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
test "force unfollow when relay is dead" do
|
||||
user = insert(:user)
|
||||
target_instance = user.ap_id
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["follow", target_instance])
|
||||
|
||||
%User{ap_id: follower_id} = local_user = Relay.get_actor()
|
||||
target_user = User.get_cached_by_ap_id(target_instance)
|
||||
follow_activity = Utils.fetch_latest_follow(local_user, target_user)
|
||||
User.follow(local_user, target_user)
|
||||
|
||||
assert "#{target_instance}/followers" in User.following(local_user)
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: ^target_instance} ->
|
||||
%Tesla.Env{status: 404}
|
||||
end)
|
||||
|
||||
Pleroma.Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance, "--force"])
|
||||
|
||||
cancelled_activity = Activity.get_by_ap_id(follow_activity.data["id"])
|
||||
assert cancelled_activity.data["state"] == "cancelled"
|
||||
|
||||
[undo_activity] =
|
||||
ActivityPub.fetch_activities(
|
||||
[],
|
||||
%{type: "Undo", actor_id: follower_id, skip_preload: true, invisible_actors: true}
|
||||
)
|
||||
|
||||
assert undo_activity.data["type"] == "Undo"
|
||||
assert undo_activity.data["actor"] == local_user.ap_id
|
||||
assert undo_activity.data["object"]["id"] == cancelled_activity.data["id"]
|
||||
refute "#{target_instance}/followers" in User.following(local_user)
|
||||
end
|
||||
end
|
||||
|
||||
describe "mix pleroma.relay list" do
|
||||
30
test/mix/tasks/pleroma/release_env_test.exs
Normal file
30
test/mix/tasks/pleroma/release_env_test.exs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.ReleaseEnvTest do
|
||||
use ExUnit.Case
|
||||
import ExUnit.CaptureIO, only: [capture_io: 1]
|
||||
|
||||
@path "config/pleroma.test.env"
|
||||
|
||||
def do_clean do
|
||||
if File.exists?(@path) do
|
||||
File.rm_rf(@path)
|
||||
end
|
||||
end
|
||||
|
||||
setup do
|
||||
do_clean()
|
||||
on_exit(fn -> do_clean() end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "generate pleroma.env" do
|
||||
assert capture_io(fn ->
|
||||
Mix.Tasks.Pleroma.ReleaseEnv.run(["gen", "--path", @path, "--force"])
|
||||
end) =~ "The file generated"
|
||||
|
||||
assert File.read!(@path) =~ "RELEASE_COOKIE="
|
||||
end
|
||||
end
|
||||
|
|
@ -225,47 +225,69 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
test "All statuses set" do
|
||||
user = insert(:user)
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["set", user.nickname, "--moderator", "--admin", "--locked"])
|
||||
Mix.Tasks.Pleroma.User.run([
|
||||
"set",
|
||||
user.nickname,
|
||||
"--admin",
|
||||
"--confirmed",
|
||||
"--locked",
|
||||
"--moderator"
|
||||
])
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Moderator status .* true/
|
||||
assert message =~ ~r/Admin status .* true/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Confirmation pending .* false/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Locked status .* true/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Admin status .* true/
|
||||
assert message =~ ~r/Moderator status .* true/
|
||||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.is_moderator
|
||||
assert user.locked
|
||||
assert user.is_locked
|
||||
assert user.is_admin
|
||||
refute user.confirmation_pending
|
||||
end
|
||||
|
||||
test "All statuses unset" do
|
||||
user = insert(:user, locked: true, is_moderator: true, is_admin: true)
|
||||
user =
|
||||
insert(:user,
|
||||
is_locked: true,
|
||||
is_moderator: true,
|
||||
is_admin: true,
|
||||
confirmation_pending: true
|
||||
)
|
||||
|
||||
Mix.Tasks.Pleroma.User.run([
|
||||
"set",
|
||||
user.nickname,
|
||||
"--no-moderator",
|
||||
"--no-admin",
|
||||
"--no-locked"
|
||||
"--no-confirmed",
|
||||
"--no-locked",
|
||||
"--no-moderator"
|
||||
])
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Moderator status .* false/
|
||||
assert message =~ ~r/Admin status .* false/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Confirmation pending .* true/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Locked status .* false/
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Admin status .* false/
|
||||
assert message =~ ~r/Moderator status .* false/
|
||||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
refute user.is_moderator
|
||||
refute user.locked
|
||||
refute user.is_locked
|
||||
refute user.is_admin
|
||||
assert user.confirmation_pending
|
||||
end
|
||||
|
||||
test "no user to set status" do
|
||||
|
|
@ -554,4 +576,44 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert message =~ "Could not change user tags"
|
||||
end
|
||||
end
|
||||
|
||||
describe "bulk confirm and unconfirm" do
|
||||
test "confirm all" do
|
||||
user1 = insert(:user, confirmation_pending: true)
|
||||
user2 = insert(:user, confirmation_pending: true)
|
||||
|
||||
assert user1.confirmation_pending
|
||||
assert user2.confirmation_pending
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["confirm_all"])
|
||||
|
||||
user1 = User.get_cached_by_nickname(user1.nickname)
|
||||
user2 = User.get_cached_by_nickname(user2.nickname)
|
||||
|
||||
refute user1.confirmation_pending
|
||||
refute user2.confirmation_pending
|
||||
end
|
||||
|
||||
test "unconfirm all" do
|
||||
user1 = insert(:user, confirmation_pending: false)
|
||||
user2 = insert(:user, confirmation_pending: false)
|
||||
admin = insert(:user, is_admin: true, confirmation_pending: false)
|
||||
mod = insert(:user, is_moderator: true, confirmation_pending: false)
|
||||
|
||||
refute user1.confirmation_pending
|
||||
refute user2.confirmation_pending
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["unconfirm_all"])
|
||||
|
||||
user1 = User.get_cached_by_nickname(user1.nickname)
|
||||
user2 = User.get_cached_by_nickname(user2.nickname)
|
||||
admin = User.get_cached_by_nickname(admin.nickname)
|
||||
mod = User.get_cached_by_nickname(mod.nickname)
|
||||
|
||||
assert user1.confirmation_pending
|
||||
assert user2.confirmation_pending
|
||||
refute admin.confirmation_pending
|
||||
refute mod.confirmation_pending
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Activity.Ir.TopicsTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -93,6 +97,20 @@ defmodule Pleroma.Activity.Ir.TopicsTest do
|
|||
|
||||
refute Enum.member?(topics, "hashtag:2")
|
||||
end
|
||||
|
||||
test "non-local action produces public:remote topic", %{activity: activity} do
|
||||
activity = %{activity | local: false, actor: "https://lain.com/users/lain"}
|
||||
topics = Topics.get_activity_topics(activity)
|
||||
|
||||
assert Enum.member?(topics, "public:remote:lain.com")
|
||||
end
|
||||
|
||||
test "local action doesn't produce public:remote topic", %{activity: activity} do
|
||||
activity = %{activity | local: true, actor: "https://lain.com/users/lain"}
|
||||
topics = Topics.get_activity_topics(activity)
|
||||
|
||||
refute Enum.member?(topics, "public:remote:lain.com")
|
||||
end
|
||||
end
|
||||
|
||||
describe "public visibility create events with attachments" do
|
||||
|
|
@ -124,6 +142,13 @@ defmodule Pleroma.Activity.Ir.TopicsTest do
|
|||
|
||||
refute Enum.member?(topics, "public:local:media")
|
||||
end
|
||||
|
||||
test "non-local action produces public:remote:media topic", %{activity: activity} do
|
||||
activity = %{activity | local: false, actor: "https://lain.com/users/lain"}
|
||||
topics = Topics.get_activity_topics(activity)
|
||||
|
||||
assert Enum.member?(topics, "public:remote:media:lain.com")
|
||||
end
|
||||
end
|
||||
|
||||
describe "non-public visibility" do
|
||||
|
|
@ -4,9 +4,12 @@
|
|||
|
||||
defmodule Pleroma.ApplicationRequirementsTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Mock
|
||||
|
||||
alias Pleroma.ApplicationRequirements
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Repo
|
||||
|
||||
describe "check_welcome_message_config!/1" do
|
||||
|
|
@ -70,42 +73,42 @@ defmodule Pleroma.ApplicationRequirementsTest do
|
|||
setup do: clear_config([:database, :rum_enabled])
|
||||
|
||||
test "raises if rum is enabled and detects unapplied rum migrations" do
|
||||
Pleroma.Config.put([:database, :rum_enabled], true)
|
||||
Config.put([:database, :rum_enabled], true)
|
||||
|
||||
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> false end]}]) do
|
||||
assert_raise Pleroma.ApplicationRequirements.VerifyError,
|
||||
assert_raise ApplicationRequirements.VerifyError,
|
||||
"Unapplied RUM Migrations detected",
|
||||
fn ->
|
||||
capture_log(&Pleroma.ApplicationRequirements.verify!/0)
|
||||
capture_log(&ApplicationRequirements.verify!/0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "raises if rum is disabled and detects rum migrations" do
|
||||
Pleroma.Config.put([:database, :rum_enabled], false)
|
||||
Config.put([:database, :rum_enabled], false)
|
||||
|
||||
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> true end]}]) do
|
||||
assert_raise Pleroma.ApplicationRequirements.VerifyError,
|
||||
assert_raise ApplicationRequirements.VerifyError,
|
||||
"RUM Migrations detected",
|
||||
fn ->
|
||||
capture_log(&Pleroma.ApplicationRequirements.verify!/0)
|
||||
capture_log(&ApplicationRequirements.verify!/0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "doesn't do anything if rum enabled and applied migrations" do
|
||||
Pleroma.Config.put([:database, :rum_enabled], true)
|
||||
Config.put([:database, :rum_enabled], true)
|
||||
|
||||
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> true end]}]) do
|
||||
assert Pleroma.ApplicationRequirements.verify!() == :ok
|
||||
assert ApplicationRequirements.verify!() == :ok
|
||||
end
|
||||
end
|
||||
|
||||
test "doesn't do anything if rum disabled" do
|
||||
Pleroma.Config.put([:database, :rum_enabled], false)
|
||||
Config.put([:database, :rum_enabled], false)
|
||||
|
||||
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> false end]}]) do
|
||||
assert Pleroma.ApplicationRequirements.verify!() == :ok
|
||||
assert ApplicationRequirements.verify!() == :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -130,17 +133,17 @@ defmodule Pleroma.ApplicationRequirementsTest do
|
|||
setup do: clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check])
|
||||
|
||||
test "raises if it detects unapplied migrations" do
|
||||
assert_raise Pleroma.ApplicationRequirements.VerifyError,
|
||||
assert_raise ApplicationRequirements.VerifyError,
|
||||
"Unapplied Migrations detected",
|
||||
fn ->
|
||||
capture_log(&Pleroma.ApplicationRequirements.verify!/0)
|
||||
capture_log(&ApplicationRequirements.verify!/0)
|
||||
end
|
||||
end
|
||||
|
||||
test "doesn't do anything if disabled" do
|
||||
Pleroma.Config.put([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true)
|
||||
Config.put([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true)
|
||||
|
||||
assert :ok == Pleroma.ApplicationRequirements.verify!()
|
||||
assert :ok == ApplicationRequirements.verify!()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||
use ExUnit.Case, async: true
|
||||
use ExUnit.Case
|
||||
use Pleroma.Tests.Helpers
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
|
|
@ -66,6 +70,30 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
|||
end) =~ "Your config is using old format (only domain) for MediaProxy whitelist option"
|
||||
end
|
||||
|
||||
test "check_welcome_message_config/0" do
|
||||
clear_config([:instance, :welcome_user_nickname], "LainChan")
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_welcome_message_config()
|
||||
end) =~ "Your config is using the old namespace for Welcome messages configuration."
|
||||
end
|
||||
|
||||
test "check_hellthread_threshold/0" do
|
||||
clear_config([:mrf_hellthread, :threshold], 16)
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_hellthread_threshold()
|
||||
end) =~ "You are using the old configuration mechanism for the hellthread filter."
|
||||
end
|
||||
|
||||
test "check_activity_expiration_config/0" do
|
||||
clear_config(Pleroma.ActivityExpiration, enabled: true)
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_activity_expiration_config()
|
||||
end) =~ "Your config is using old namespace for activity expiration configuration."
|
||||
end
|
||||
|
||||
describe "check_gun_pool_options/0" do
|
||||
test "await_up_timeout" do
|
||||
config = Config.get(:connections_pool)
|
||||
|
|
@ -74,7 +102,7 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
|||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_gun_pool_options()
|
||||
end) =~
|
||||
"Your config is using old setting name `await_up_timeout` instead of `connect_timeout`"
|
||||
"Your config is using old setting `config :pleroma, :connections_pool, await_up_timeout`."
|
||||
end
|
||||
|
||||
test "pool timeout" do
|
||||
|
|
@ -37,9 +37,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
[%{read: true}] = Participation.for_user(user)
|
||||
[%{read: false} = participation] = Participation.for_user(other_user)
|
||||
|
||||
assert User.get_cached_by_id(user.id).unread_conversation_count == 0
|
||||
assert User.get_cached_by_id(other_user.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(user) == 0
|
||||
assert Participation.unread_count(other_user) == 1
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(other_user, %{
|
||||
|
|
@ -54,8 +53,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
[%{read: false}] = Participation.for_user(user)
|
||||
[%{read: true}] = Participation.for_user(other_user)
|
||||
|
||||
assert User.get_cached_by_id(user.id).unread_conversation_count == 1
|
||||
assert User.get_cached_by_id(other_user.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(user) == 1
|
||||
assert Participation.unread_count(other_user) == 0
|
||||
end
|
||||
|
||||
test "for a new conversation, it sets the recipents of the participation" do
|
||||
|
|
@ -264,7 +263,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
assert [%{read: false}, %{read: false}, %{read: false}, %{read: false}] =
|
||||
Participation.for_user(blocker)
|
||||
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 4
|
||||
assert Participation.unread_count(blocker) == 4
|
||||
|
||||
{:ok, _user_relationship} = User.block(blocker, blocked)
|
||||
|
||||
|
|
@ -272,15 +271,15 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
assert [%{read: true}, %{read: true}, %{read: true}, %{read: false}] =
|
||||
Participation.for_user(blocker)
|
||||
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(blocker) == 1
|
||||
|
||||
# The conversation is not marked as read for the blocked user
|
||||
assert [_, _, %{read: false}] = Participation.for_user(blocked)
|
||||
assert User.get_cached_by_id(blocked.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(blocker) == 1
|
||||
|
||||
# The conversation is not marked as read for the third user
|
||||
assert [%{read: false}, _, _] = Participation.for_user(third_user)
|
||||
assert User.get_cached_by_id(third_user.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(third_user) == 1
|
||||
end
|
||||
|
||||
test "the new conversation with the blocked user is not marked as unread " do
|
||||
|
|
@ -298,7 +297,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
|
||||
# When the blocked user is a recipient
|
||||
{:ok, _direct2} =
|
||||
|
|
@ -308,10 +307,10 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}, %{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
|
||||
assert [%{read: false}, _] = Participation.for_user(blocked)
|
||||
assert User.get_cached_by_id(blocked.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(blocked) == 1
|
||||
end
|
||||
|
||||
test "the conversation with the blocked user is not marked as unread on a reply" do
|
||||
|
|
@ -327,8 +326,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
{:ok, _user_relationship} = User.block(blocker, blocked)
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
assert [blocked_participation] = Participation.for_user(blocked)
|
||||
|
||||
# When it's a reply from the blocked user
|
||||
|
|
@ -340,8 +339,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
assert [third_user_participation] = Participation.for_user(third_user)
|
||||
|
||||
# When it's a reply from the third user
|
||||
|
|
@ -353,11 +352,12 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
|
||||
# Marked as unread for the blocked user
|
||||
assert [%{read: false}] = Participation.for_user(blocked)
|
||||
assert User.get_cached_by_id(blocked.id).unread_conversation_count == 1
|
||||
|
||||
assert Participation.unread_count(blocked) == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Docs.GeneratorTest do
|
||||
use ExUnit.Case, async: true
|
||||
alias Pleroma.Docs.Generator
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.DateTimeTest do
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.DateTimeTest do
|
||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators.DateTime
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ObjectValidators.Types.ObjectIDTest do
|
||||
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectIDTest do
|
||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
defmodule Pleroma.Web.ObjectValidators.Types.RecipientsTest do
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.RecipientsTest do
|
||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators.Recipients
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeTextTest do
|
||||
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.SafeTextTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators.SafeText
|
||||
|
|
@ -63,7 +63,7 @@ defmodule Pleroma.Emails.AdminEmailTest do
|
|||
assert res.html_body == """
|
||||
<p>New account for review: <a href="#{account_url}">@#{account.nickname}</a></p>
|
||||
<blockquote>Plz let me in</blockquote>
|
||||
<a href="http://localhost:4001/pleroma/admin">Visit AdminFE</a>
|
||||
<a href="http://localhost:4001/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.EmojiTest do
|
||||
use ExUnit.Case, async: true
|
||||
use ExUnit.Case
|
||||
alias Pleroma.Emoji
|
||||
|
||||
describe "is_unicode_emoji?/1" do
|
||||
|
|
@ -49,6 +49,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||
test "allows public streams without authentication" do
|
||||
assert {:ok, _} = start_socket("?stream=public")
|
||||
assert {:ok, _} = start_socket("?stream=public:local")
|
||||
assert {:ok, _} = start_socket("?stream=public:remote&instance=lain.com")
|
||||
assert {:ok, _} = start_socket("?stream=hashtag&tag=lain")
|
||||
end
|
||||
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.MFA.BackupCodesTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.MFA.TOTPTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -346,7 +346,7 @@ defmodule Pleroma.NotificationTest do
|
|||
describe "follow / follow_request notifications" do
|
||||
test "it creates `follow` notification for approved Follow activity" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, locked: false)
|
||||
followed_user = insert(:user, is_locked: false)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
assert FollowingRelationship.following?(user, followed_user)
|
||||
|
|
@ -361,7 +361,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
test "it creates `follow_request` notification for pending Follow activity" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, locked: true)
|
||||
followed_user = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
refute FollowingRelationship.following?(user, followed_user)
|
||||
|
|
@ -383,7 +383,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
test "it doesn't create a notification for follow-unfollow-follow chains" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, locked: false)
|
||||
followed_user = insert(:user, is_locked: false)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
assert FollowingRelationship.following?(user, followed_user)
|
||||
|
|
@ -397,10 +397,10 @@ defmodule Pleroma.NotificationTest do
|
|||
end
|
||||
|
||||
test "dismisses the notification on follow request rejection" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
|
||||
assert [notification] = Notification.for_user(user)
|
||||
assert [_notification] = Notification.for_user(user)
|
||||
{:ok, _follower} = CommonAPI.reject_follow_request(follower, user)
|
||||
assert [] = Notification.for_user(user)
|
||||
end
|
||||
|
|
@ -82,7 +82,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], false)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ defmodule Pleroma.ObjectTest do
|
|||
File.mkdir_p!(uploads_dir)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.FixLegacyTagsTest do
|
||||
alias Pleroma.User
|
||||
use Pleroma.DataCase
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.MoveWelcomeSettingsTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.RuntimeTest do
|
|||
use ExUnit.Case, async: true
|
||||
|
||||
test "it loads custom runtime modules" do
|
||||
assert {:module, RuntimeModule} == Code.ensure_compiled(RuntimeModule)
|
||||
assert {:module, Fixtures.Modules.RuntimeModule} ==
|
||||
Code.ensure_compiled(Fixtures.Modules.RuntimeModule)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.SafeJsonbSetTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue