Merge remote-tracking branch 'pleroma/develop' into featureflag/emoji_reactions
This commit is contained in:
commit
212c31c637
119 changed files with 1458 additions and 485 deletions
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.ActivityExpirationTest do
|
|||
alias Pleroma.ActivityExpiration
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([ActivityExpiration, :enabled])
|
||||
setup do: clear_config([ActivityExpiration, :enabled])
|
||||
|
||||
test "finds activities due to be deleted only" do
|
||||
activity = insert(:note_activity)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ defmodule Pleroma.ActivityTest do
|
|||
}
|
||||
end
|
||||
|
||||
clear_config([:instance, :limit_to_local_content])
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "finds utf8 text in statuses", %{
|
||||
japanese_activity: japanese_activity,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ defmodule Pleroma.CaptchaTest do
|
|||
alias Pleroma.Captcha.Native
|
||||
|
||||
@ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}]
|
||||
|
||||
clear_config([Pleroma.Captcha, :enabled])
|
||||
setup do: clear_config([Pleroma.Captcha, :enabled])
|
||||
|
||||
describe "Kocaptcha" do
|
||||
setup do
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
alias Pleroma.Config.TransferTask
|
||||
alias Pleroma.ConfigDB
|
||||
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
setup do: clear_config(:configurable_from_database, true)
|
||||
|
||||
test "transfer config values from db to env" do
|
||||
refute Application.get_env(:pleroma, :test_key)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ defmodule Pleroma.ConversationTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config_all([:instance, :federating]) do
|
||||
Pleroma.Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "it goes through old direct conversations" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ defmodule Pleroma.Emails.MailerTest do
|
|||
subject: "Pleroma test email",
|
||||
to: [{"Test User", "user1@example.com"}]
|
||||
}
|
||||
|
||||
clear_config([Pleroma.Emails.Mailer, :enabled])
|
||||
setup do: clear_config([Pleroma.Emails.Mailer, :enabled])
|
||||
|
||||
test "not send email when mailer is disabled" do
|
||||
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ defmodule Pleroma.HTTP.RequestBuilderTest do
|
|||
alias Pleroma.HTTP.RequestBuilder
|
||||
|
||||
describe "headers/2" do
|
||||
clear_config([:http, :send_user_agent])
|
||||
clear_config([:http, :user_agent])
|
||||
setup do: clear_config([:http, :send_user_agent])
|
||||
setup do: clear_config([:http, :user_agent])
|
||||
|
||||
test "don't send pleroma user agent" do
|
||||
assert RequestBuilder.headers(%{}, []) == %{headers: []}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ defmodule Pleroma.Object.FetcherTest do
|
|||
|
||||
describe "max thread distance restriction" do
|
||||
@ap_id "http://mastodon.example.org/@admin/99541947525187367"
|
||||
|
||||
clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
|
||||
test "it returns thread depth exceeded error if thread depth is exceeded" do
|
||||
Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
|
||||
|
|
@ -160,7 +159,7 @@ defmodule Pleroma.Object.FetcherTest do
|
|||
end
|
||||
|
||||
describe "signed fetches" do
|
||||
clear_config([:activitypub, :sign_object_fetches])
|
||||
setup do: clear_config([:activitypub, :sign_object_fetches])
|
||||
|
||||
test_with_mock "it signs fetches when configured to do so",
|
||||
Pleroma.Signature,
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ defmodule Pleroma.ObjectTest do
|
|||
end
|
||||
|
||||
describe "delete attachments" do
|
||||
clear_config([Pleroma.Upload])
|
||||
clear_config([:instance, :cleanup_attachments])
|
||||
setup do: clear_config([Pleroma.Upload])
|
||||
setup do: clear_config([:instance, :cleanup_attachments])
|
||||
|
||||
test "Disabled via config" do
|
||||
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ defmodule Pleroma.Plugs.AdminSecretAuthenticationPlugTest do
|
|||
end
|
||||
|
||||
describe "when secret set it assigns an admin user" do
|
||||
clear_config([:admin_token])
|
||||
setup do: clear_config([:admin_token])
|
||||
|
||||
test "with `admin_token` query parameter", %{conn: conn} do
|
||||
Pleroma.Config.put(:admin_token, "password123")
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlugTest do
|
|||
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
|
||||
alias Pleroma.User
|
||||
|
||||
clear_config([:instance, :public])
|
||||
setup do: clear_config([:instance, :public])
|
||||
|
||||
test "it halts if not public and no user is assigned", %{conn: conn} do
|
||||
Config.put([:instance, :public], false)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ defmodule Pleroma.Web.Plugs.HTTPSecurityPlugTest do
|
|||
alias Pleroma.Config
|
||||
alias Plug.Conn
|
||||
|
||||
clear_config([:http_securiy, :enabled])
|
||||
clear_config([:http_security, :sts])
|
||||
clear_config([:http_security, :referrer_policy])
|
||||
setup do: clear_config([:http_securiy, :enabled])
|
||||
setup do: clear_config([:http_security, :sts])
|
||||
setup do: clear_config([:http_security, :referrer_policy])
|
||||
|
||||
describe "http security enabled" do
|
||||
setup do
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ defmodule Pleroma.Web.RuntimeStaticPlugTest do
|
|||
on_exit(fn -> File.rm_rf(@dir) end)
|
||||
end
|
||||
|
||||
clear_config([:instance, :static_dir]) do
|
||||
Pleroma.Config.put([:instance, :static_dir], @dir)
|
||||
end
|
||||
setup do: clear_config([:instance, :static_dir], @dir)
|
||||
|
||||
test "overrides index" do
|
||||
bundled_index = get(build_conn(), "/")
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do
|
|||
end
|
||||
|
||||
describe "transform_scopes/2" do
|
||||
clear_config([:auth, :enforce_oauth_admin_scope_usage])
|
||||
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage])
|
||||
|
||||
setup do
|
||||
{:ok, %{f: &OAuthScopesPlug.transform_scopes/2}}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,12 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2]
|
||||
|
||||
# Note: each example must work with separate buckets in order to prevent concurrency issues
|
||||
|
||||
clear_config([Pleroma.Web.Endpoint, :http, :ip])
|
||||
clear_config(:rate_limit)
|
||||
setup do: clear_config([Pleroma.Web.Endpoint, :http, :ip])
|
||||
setup do: clear_config(:rate_limit)
|
||||
|
||||
describe "config" do
|
||||
@limiter_name :test_init
|
||||
|
||||
clear_config([Pleroma.Plugs.RemoteIp, :enabled])
|
||||
setup do: clear_config([Pleroma.Plugs.RemoteIp, :enabled])
|
||||
|
||||
test "config is required for plug to work" do
|
||||
Config.put([:rate_limit, @limiter_name], {1, 1})
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ defmodule Pleroma.Plugs.RemoteIpTest do
|
|||
alias Pleroma.Plugs.RemoteIp
|
||||
|
||||
import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2]
|
||||
|
||||
clear_config(RemoteIp)
|
||||
setup do: clear_config(RemoteIp)
|
||||
|
||||
test "disabled" do
|
||||
Pleroma.Config.put(RemoteIp, enabled: false)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Plugs.UserEnabledPlugTest do
|
|||
alias Pleroma.Plugs.UserEnabledPlug
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "doesn't do anything if the user isn't set", %{conn: conn} do
|
||||
ret_conn =
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ defmodule Pleroma.Plugs.UserIsAdminPlugTest do
|
|||
import Pleroma.Factory
|
||||
|
||||
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
||||
Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||
end
|
||||
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||
|
||||
test "accepts a user that is an admin" do
|
||||
user = insert(:user, is_admin: true)
|
||||
|
|
@ -42,9 +40,7 @@ defmodule Pleroma.Plugs.UserIsAdminPlugTest do
|
|||
end
|
||||
|
||||
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
||||
Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], true)
|
||||
end
|
||||
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], true)
|
||||
|
||||
setup do
|
||||
admin_user = insert(:user, is_admin: true)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ defmodule Pleroma.RepoTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check])
|
||||
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.Repo.UnappliedMigrationsError, fn ->
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.ScheduledActivityTest do
|
|||
alias Pleroma.ScheduledActivity
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([ScheduledActivity, :enabled])
|
||||
setup do: clear_config([ScheduledActivity, :enabled])
|
||||
|
||||
setup context do
|
||||
DataCase.ensure_local_uploader(context)
|
||||
|
|
|
|||
|
|
@ -17,35 +17,17 @@ defmodule Pleroma.Tests.Helpers do
|
|||
|
||||
defmacro clear_config(config_path, do: yield) do
|
||||
quote do
|
||||
setup do
|
||||
initial_setting = Config.get(unquote(config_path))
|
||||
unquote(yield)
|
||||
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
|
||||
:ok
|
||||
end
|
||||
initial_setting = Config.get(unquote(config_path))
|
||||
unquote(yield)
|
||||
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
@doc "Stores initial config value and restores it after *all* test examples are executed."
|
||||
defmacro clear_config_all(config_path) do
|
||||
defmacro clear_config(config_path, temp_setting) do
|
||||
quote do
|
||||
clear_config_all(unquote(config_path)) do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Stores initial config value and restores it after *all* test examples are executed.
|
||||
Only use if *all* test examples should work with the same stubbed value
|
||||
(*no* examples set a different value).
|
||||
"""
|
||||
defmacro clear_config_all(config_path, do: yield) do
|
||||
quote do
|
||||
setup_all do
|
||||
initial_setting = Config.get(unquote(config_path))
|
||||
unquote(yield)
|
||||
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
|
||||
:ok
|
||||
clear_config(unquote(config_path)) do
|
||||
Config.put(unquote(config_path), unquote(temp_setting))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -55,9 +37,7 @@ defmodule Pleroma.Tests.Helpers do
|
|||
import Pleroma.Tests.Helpers,
|
||||
only: [
|
||||
clear_config: 1,
|
||||
clear_config: 2,
|
||||
clear_config_all: 1,
|
||||
clear_config_all: 2
|
||||
clear_config: 2
|
||||
]
|
||||
|
||||
def to_datetime(naive_datetime) do
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
setup_all do: clear_config(:configurable_from_database, true)
|
||||
|
||||
test "error if file with custom settings doesn't exist" do
|
||||
Mix.Tasks.Pleroma.Config.migrate_to_db("config/not_existance_config_file.exs")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
|
|||
use Pleroma.Tests.Helpers
|
||||
alias Mix.Tasks.Pleroma.RobotsTxt
|
||||
|
||||
clear_config([:instance, :static_dir])
|
||||
setup do: clear_config([:instance, :static_dir])
|
||||
|
||||
test "creates new dir" do
|
||||
path = "test/fixtures/new_dir/"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do
|
|||
%{upload_file: upload_file}
|
||||
end
|
||||
|
||||
clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
|
||||
setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
|
||||
|
||||
test "it replaces filename on pre-defined text", %{upload_file: upload_file} do
|
||||
Config.put([Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ defmodule Pleroma.Upload.Filter.MogrifyTest do
|
|||
alias Pleroma.Upload
|
||||
alias Pleroma.Upload.Filter
|
||||
|
||||
clear_config([Filter.Mogrify, :args])
|
||||
setup do: clear_config([Filter.Mogrify, :args])
|
||||
|
||||
test "apply mogrify filter" do
|
||||
Config.put([Filter.Mogrify, :args], [{"tint", "40"}])
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Upload.FilterTest do
|
|||
alias Pleroma.Config
|
||||
alias Pleroma.Upload.Filter
|
||||
|
||||
clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
|
||||
setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
|
||||
|
||||
test "applies filters" do
|
||||
Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
|
||||
|
|
|
|||
|
|
@ -250,9 +250,7 @@ defmodule Pleroma.UploadTest do
|
|||
end
|
||||
|
||||
describe "Setting a custom base_url for uploaded media" do
|
||||
clear_config([Pleroma.Upload, :base_url]) do
|
||||
Pleroma.Config.put([Pleroma.Upload, :base_url], "https://cache.pleroma.social")
|
||||
end
|
||||
setup do: clear_config([Pleroma.Upload, :base_url], "https://cache.pleroma.social")
|
||||
|
||||
test "returns a media url with configured base_url" do
|
||||
base_url = Pleroma.Config.get([Pleroma.Upload, :base_url])
|
||||
|
|
|
|||
|
|
@ -11,12 +11,11 @@ defmodule Pleroma.Uploaders.S3Test do
|
|||
import Mock
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
clear_config([Pleroma.Uploaders.S3]) do
|
||||
Config.put([Pleroma.Uploaders.S3],
|
||||
bucket: "test_bucket",
|
||||
public_endpoint: "https://s3.amazonaws.com"
|
||||
)
|
||||
end
|
||||
setup do:
|
||||
clear_config(Pleroma.Uploaders.S3,
|
||||
bucket: "test_bucket",
|
||||
public_endpoint: "https://s3.amazonaws.com"
|
||||
)
|
||||
|
||||
describe "get_file/1" do
|
||||
test "it returns path to local folder for files" do
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.UserSearchTest do
|
|||
end
|
||||
|
||||
describe "User.search" do
|
||||
clear_config([:instance, :limit_to_local_content])
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "excluded invisible users from results" do
|
||||
user = insert(:user, %{nickname: "john t1000"})
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ defmodule Pleroma.UserTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
describe "service actors" do
|
||||
test "returns updated invisible actor" do
|
||||
|
|
@ -297,7 +297,7 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
describe "unfollow/2" do
|
||||
clear_config([:instance, :external_user_synchronization])
|
||||
setup do: clear_config([:instance, :external_user_synchronization])
|
||||
|
||||
test "unfollow with syncronizes external user" do
|
||||
Pleroma.Config.put([:instance, :external_user_synchronization], true)
|
||||
|
|
@ -375,10 +375,9 @@ defmodule Pleroma.UserTest do
|
|||
password_confirmation: "test",
|
||||
email: "email@example.com"
|
||||
}
|
||||
|
||||
clear_config([:instance, :autofollowed_nicknames])
|
||||
clear_config([:instance, :welcome_message])
|
||||
clear_config([:instance, :welcome_user_nickname])
|
||||
setup do: clear_config([:instance, :autofollowed_nicknames])
|
||||
setup do: clear_config([:instance, :welcome_message])
|
||||
setup do: clear_config([:instance, :welcome_user_nickname])
|
||||
|
||||
test "it autofollows accounts that are set for it" do
|
||||
user = insert(:user)
|
||||
|
|
@ -412,7 +411,7 @@ defmodule Pleroma.UserTest do
|
|||
assert activity.actor == welcome_user.ap_id
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
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)
|
||||
|
|
@ -475,10 +474,7 @@ defmodule Pleroma.UserTest do
|
|||
password_confirmation: "test",
|
||||
email: "email@example.com"
|
||||
}
|
||||
|
||||
clear_config([:instance, :account_activation_required]) do
|
||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :account_activation_required], true)
|
||||
|
||||
test "it creates unconfirmed user" do
|
||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||
|
|
@ -621,9 +617,8 @@ defmodule Pleroma.UserTest do
|
|||
ap_id: "http...",
|
||||
avatar: %{some: "avatar"}
|
||||
}
|
||||
|
||||
clear_config([:instance, :user_bio_length])
|
||||
clear_config([:instance, :user_name_length])
|
||||
setup do: clear_config([:instance, :user_bio_length])
|
||||
setup do: clear_config([:instance, :user_name_length])
|
||||
|
||||
test "it confirms validity" do
|
||||
cs = User.remote_user_creation(@valid_remote)
|
||||
|
|
@ -1116,7 +1111,7 @@ defmodule Pleroma.UserTest do
|
|||
[user: user]
|
||||
end
|
||||
|
||||
clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
|
||||
test ".delete_user_activities deletes all create activities", %{user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
|
||||
|
|
@ -1297,7 +1292,7 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
describe "account_status/1" do
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "return confirmation_pending for unconfirm user" do
|
||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||
|
|
@ -1665,7 +1660,7 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
describe "following/followers synchronization" do
|
||||
clear_config([:instance, :external_user_synchronization])
|
||||
setup do: clear_config([:instance, :external_user_synchronization])
|
||||
|
||||
test "updates the counters normally on following/getting a follow when disabled" do
|
||||
Pleroma.Config.put([:instance, :external_user_synchronization], false)
|
||||
|
|
@ -1770,7 +1765,7 @@ defmodule Pleroma.UserTest do
|
|||
[local_user: local_user, remote_user: remote_user]
|
||||
end
|
||||
|
||||
clear_config([:instance, :limit_to_local_content])
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "allows getting remote users by id no matter what :limit_to_local_content is set to", %{
|
||||
remote_user: remote_user
|
||||
|
|
|
|||
|
|
@ -26,12 +26,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance, :federating]) do
|
||||
Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
describe "/relay" do
|
||||
clear_config([:instance, :allow_relay])
|
||||
setup do: clear_config([:instance, :allow_relay])
|
||||
|
||||
test "with the relay active, it returns the relay user", %{conn: conn} do
|
||||
res =
|
||||
|
|
@ -1227,8 +1225,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|> json_response(403)
|
||||
end
|
||||
|
||||
clear_config([:media_proxy])
|
||||
clear_config([Pleroma.Upload])
|
||||
setup do: clear_config([:media_proxy])
|
||||
setup do: clear_config([Pleroma.Upload])
|
||||
|
||||
test "POST /api/ap/upload_media", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
|
||||
describe "streaming out participations" do
|
||||
test "it streams them out" do
|
||||
|
|
@ -1396,7 +1396,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
|
||||
describe "deletion" do
|
||||
clear_config([:instance, :rewrite_policy])
|
||||
setup do: clear_config([:instance, :rewrite_policy])
|
||||
|
||||
test "it reverts deletion on error" do
|
||||
note = insert(:note_activity)
|
||||
|
|
@ -1425,6 +1425,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert Repo.get(Object, object.id).data["type"] == "Tombstone"
|
||||
end
|
||||
|
||||
test "it doesn't fail when an activity was already deleted" do
|
||||
{:ok, delete} = insert(:note_activity) |> Object.normalize() |> ActivityPub.delete()
|
||||
|
||||
assert {:ok, ^delete} = delete |> Object.normalize() |> ActivityPub.delete()
|
||||
end
|
||||
|
||||
test "decrements user note count only for public activities" do
|
||||
user = insert(:user, note_count: 10)
|
||||
|
||||
|
|
@ -1580,7 +1586,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
|
||||
describe "update" do
|
||||
clear_config([:instance, :max_pinned_statuses])
|
||||
setup do: clear_config([:instance, :max_pinned_statuses])
|
||||
|
||||
test "it creates an update activity with the new user data" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
|
|||
[user: user, message: message]
|
||||
end
|
||||
|
||||
clear_config(:mrf_hellthread)
|
||||
setup do: clear_config(:mrf_hellthread)
|
||||
|
||||
describe "reject" do
|
||||
test "rejects the message if the recipient count is above reject_threshold", %{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
|
|||
|
||||
alias Pleroma.Web.ActivityPub.MRF.KeywordPolicy
|
||||
|
||||
clear_config(:mrf_keyword)
|
||||
setup do: clear_config(:mrf_keyword)
|
||||
|
||||
setup do
|
||||
Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
|
|||
|
||||
alias Pleroma.Web.ActivityPub.MRF.MentionPolicy
|
||||
|
||||
clear_config(:mrf_mention)
|
||||
setup do: clear_config(:mrf_mention)
|
||||
|
||||
test "pass filter if allow list is empty" do
|
||||
Pleroma.Config.delete([:mrf_mention])
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
|||
end
|
||||
|
||||
describe "describe/0" do
|
||||
clear_config([:instance, :rewrite_policy])
|
||||
setup do: clear_config([:instance, :rewrite_policy])
|
||||
|
||||
test "it works as expected with noop policy" do
|
||||
expected = %{
|
||||
|
|
|
|||
|
|
@ -9,12 +9,11 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
|
|||
alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy
|
||||
alias Pleroma.Web.ActivityPub.Visibility
|
||||
|
||||
clear_config([:mrf_object_age]) do
|
||||
Config.put(:mrf_object_age,
|
||||
threshold: 172_800,
|
||||
actions: [:delist, :strip_followers]
|
||||
)
|
||||
end
|
||||
setup do:
|
||||
clear_config(:mrf_object_age,
|
||||
threshold: 172_800,
|
||||
actions: [:delist, :strip_followers]
|
||||
)
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublicTest do
|
|||
|
||||
alias Pleroma.Web.ActivityPub.MRF.RejectNonPublic
|
||||
|
||||
clear_config([:mrf_rejectnonpublic])
|
||||
setup do: clear_config([:mrf_rejectnonpublic])
|
||||
|
||||
describe "public message" do
|
||||
test "it's allowed when address is public" do
|
||||
|
|
|
|||
|
|
@ -8,18 +8,17 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||
alias Pleroma.Config
|
||||
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
|
||||
|
||||
clear_config([:mrf_simple]) do
|
||||
Config.put(:mrf_simple,
|
||||
media_removal: [],
|
||||
media_nsfw: [],
|
||||
federated_timeline_removal: [],
|
||||
report_removal: [],
|
||||
reject: [],
|
||||
accept: [],
|
||||
avatar_removal: [],
|
||||
banner_removal: []
|
||||
)
|
||||
end
|
||||
setup do:
|
||||
clear_config(:mrf_simple,
|
||||
media_removal: [],
|
||||
media_nsfw: [],
|
||||
federated_timeline_removal: [],
|
||||
report_removal: [],
|
||||
reject: [],
|
||||
accept: [],
|
||||
avatar_removal: [],
|
||||
banner_removal: []
|
||||
)
|
||||
|
||||
describe "when :media_removal" do
|
||||
test "is empty" do
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicyTest do
|
|||
"type" => "Create",
|
||||
"object" => %{"content" => "hi"}
|
||||
}
|
||||
|
||||
clear_config([:mrf_subchain, :match_actor])
|
||||
setup do: clear_config([:mrf_subchain, :match_actor])
|
||||
|
||||
test "it matches and processes subchains when the actor matches a configured target" do
|
||||
Pleroma.Config.put([:mrf_subchain, :match_actor], %{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicyTest do
|
|||
|
||||
alias Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy
|
||||
|
||||
clear_config([:mrf_user_allowlist, :localhost])
|
||||
setup do: clear_config([:mrf_user_allowlist, :localhost])
|
||||
|
||||
test "pass filter if allow list is empty" do
|
||||
actor = insert(:user)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
|
|||
alias Pleroma.Web.ActivityPub.MRF.VocabularyPolicy
|
||||
|
||||
describe "accept" do
|
||||
clear_config([:mrf_vocabulary, :accept])
|
||||
setup do: clear_config([:mrf_vocabulary, :accept])
|
||||
|
||||
test "it accepts based on parent activity type" do
|
||||
Pleroma.Config.put([:mrf_vocabulary, :accept], ["Like"])
|
||||
|
|
@ -65,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
|
|||
end
|
||||
|
||||
describe "reject" do
|
||||
clear_config([:mrf_vocabulary, :reject])
|
||||
setup do: clear_config([:mrf_vocabulary, :reject])
|
||||
|
||||
test "it rejects based on parent activity type" do
|
||||
Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"])
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all([:instance, :federating]) do
|
||||
Pleroma.Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
|
||||
describe "gather_webfinger_links/1" do
|
||||
test "it returns links" do
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
end
|
||||
|
||||
describe "publish/1" do
|
||||
clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
|
||||
test "returns error when activity not `Create` type" do
|
||||
activity = insert(:like_activity)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
|||
end
|
||||
|
||||
describe "handle_incoming" do
|
||||
clear_config([:user, :deny_follow_blocked])
|
||||
setup do: clear_config([:user, :deny_follow_blocked])
|
||||
|
||||
test "it works for osada follow request" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance, :max_remote_account_fields])
|
||||
setup do: clear_config([:instance, :max_remote_account_fields])
|
||||
|
||||
describe "handle_incoming" do
|
||||
test "it ignores an incoming notice if we already have it" do
|
||||
|
|
@ -1351,11 +1351,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
|
||||
describe "`handle_incoming/2`, Mastodon format `replies` handling" do
|
||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
||||
end
|
||||
|
||||
clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
setup do: clear_config([:activitypub, :note_replies_output_limit], 5)
|
||||
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
|
||||
setup do
|
||||
data =
|
||||
|
|
@ -1394,11 +1391,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
|
||||
describe "`handle_incoming/2`, Pleroma format `replies` handling" do
|
||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
||||
end
|
||||
|
||||
clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
setup do: clear_config([:activitypub, :note_replies_output_limit], 5)
|
||||
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
|
||||
setup do
|
||||
user = insert(:user)
|
||||
|
|
@ -1882,7 +1876,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
|
||||
describe "fix_in_reply_to/2" do
|
||||
clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
|
||||
setup do
|
||||
data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json"))
|
||||
|
|
@ -2145,9 +2139,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
|
||||
describe "set_replies/1" do
|
||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 2)
|
||||
end
|
||||
setup do: clear_config([:activitypub, :note_replies_output_limit], 2)
|
||||
|
||||
test "returns unmodified object if activity doesn't have self-replies" do
|
||||
data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json"))
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
|
|||
end
|
||||
|
||||
describe "note activity's `replies` collection rendering" do
|
||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
||||
end
|
||||
setup do: clear_config([:activitypub, :note_replies_output_limit], 5)
|
||||
|
||||
test "renders `replies` collection for a note activity" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
||||
Config.put([:auth, :enforce_oauth_admin_scope_usage], true)
|
||||
end
|
||||
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], true)
|
||||
|
||||
test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
||||
%{admin: admin} do
|
||||
|
|
@ -93,9 +91,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
||||
Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||
end
|
||||
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||
|
||||
test "GET /api/pleroma/admin/users/:nickname requires " <>
|
||||
"read:accounts or admin:read:accounts or broader scope",
|
||||
|
|
@ -581,13 +577,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/email_invite, with valid config" do
|
||||
clear_config([:instance, :registrations_open]) do
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
end
|
||||
|
||||
clear_config([:instance, :invites_enabled]) do
|
||||
Config.put([:instance, :invites_enabled], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :registrations_open], false)
|
||||
setup do: clear_config([:instance, :invites_enabled], true)
|
||||
|
||||
test "sends invitation and returns 204", %{admin: admin, conn: conn} do
|
||||
recipient_email = "foo@bar.com"
|
||||
|
|
@ -638,8 +629,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/users/email_invite, with invalid config" do
|
||||
clear_config([:instance, :registrations_open])
|
||||
clear_config([:instance, :invites_enabled])
|
||||
setup do: clear_config([:instance, :registrations_open])
|
||||
setup do: clear_config([:instance, :invites_enabled])
|
||||
|
||||
test "it returns 500 if `invites_enabled` is not enabled", %{conn: conn} do
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
|
|
@ -1888,9 +1879,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/config" do
|
||||
clear_config(:configurable_from_database) do
|
||||
Config.put(:configurable_from_database, true)
|
||||
end
|
||||
setup do: clear_config(:configurable_from_database, true)
|
||||
|
||||
test "when configuration from database is off", %{conn: conn} do
|
||||
Config.put(:configurable_from_database, false)
|
||||
|
|
@ -2041,9 +2030,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end)
|
||||
end
|
||||
|
||||
clear_config(:configurable_from_database) do
|
||||
Config.put(:configurable_from_database, true)
|
||||
end
|
||||
setup do: clear_config(:configurable_from_database, true)
|
||||
|
||||
@tag capture_log: true
|
||||
test "create new config setting in db", %{conn: conn} do
|
||||
|
|
@ -3052,9 +3039,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/restart" do
|
||||
clear_config(:configurable_from_database) do
|
||||
Config.put(:configurable_from_database, true)
|
||||
end
|
||||
setup do: clear_config(:configurable_from_database, true)
|
||||
|
||||
test "pleroma restarts", %{conn: conn} do
|
||||
capture_log(fn ->
|
||||
|
|
@ -3389,6 +3374,75 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /users/:nickname/credentials" do
|
||||
test "gets the user credentials", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
|
||||
response = assert json_response(conn, 200)
|
||||
assert response["email"] == user.email
|
||||
end
|
||||
|
||||
test "returns 403 if requested by a non-admin" do
|
||||
user = insert(:user)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
|
||||
assert json_response(conn, :forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /users/:nickname/credentials" do
|
||||
test "changes password and email", %{conn: conn, admin: admin} do
|
||||
user = insert(:user)
|
||||
assert user.password_reset_pending == false
|
||||
|
||||
conn =
|
||||
patch(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
"password" => "new_password",
|
||||
"email" => "new_email@example.com",
|
||||
"name" => "new_name"
|
||||
})
|
||||
|
||||
assert json_response(conn, 200) == %{"status" => "success"}
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
updated_user = User.get_by_id(user.id)
|
||||
|
||||
assert updated_user.email == "new_email@example.com"
|
||||
assert updated_user.name == "new_name"
|
||||
assert updated_user.password_hash != user.password_hash
|
||||
assert updated_user.password_reset_pending == true
|
||||
|
||||
[log_entry2, log_entry1] = ModerationLog |> Repo.all() |> Enum.sort()
|
||||
|
||||
assert ModerationLog.get_log_entry_message(log_entry1) ==
|
||||
"@#{admin.nickname} updated users: @#{user.nickname}"
|
||||
|
||||
assert ModerationLog.get_log_entry_message(log_entry2) ==
|
||||
"@#{admin.nickname} forced password reset for users: @#{user.nickname}"
|
||||
end
|
||||
|
||||
test "returns 403 if requested by a non-admin" do
|
||||
user = insert(:user)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> patch("/api/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
"password" => "new_password",
|
||||
"email" => "new_email@example.com",
|
||||
"name" => "new_name"
|
||||
})
|
||||
|
||||
assert json_response(conn, :forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /users/:nickname/force_password_reset" do
|
||||
test "sets password_reset_pending to true", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.ChatChannelTest do
|
|||
end
|
||||
|
||||
describe "message lengths" do
|
||||
clear_config([:instance, :chat_limit])
|
||||
setup do: clear_config([:instance, :chat_limit])
|
||||
|
||||
test "it ignores messages of length zero", %{socket: socket} do
|
||||
push(socket, "new_msg", %{"text" => ""})
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
require Pleroma.Constants
|
||||
|
||||
clear_config([:instance, :safe_dm_mentions])
|
||||
clear_config([:instance, :limit])
|
||||
clear_config([:instance, :max_pinned_statuses])
|
||||
setup do: clear_config([:instance, :safe_dm_mentions])
|
||||
setup do: clear_config([:instance, :limit])
|
||||
setup do: clear_config([:instance, :max_pinned_statuses])
|
||||
|
||||
test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -21,13 +21,10 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all([:instance, :federating]) do
|
||||
Pleroma.Config.put([:instance, :federating], true)
|
||||
end
|
||||
|
||||
clear_config([:instance, :allow_relay])
|
||||
clear_config([:instance, :rewrite_policy])
|
||||
clear_config([:mrf_keyword])
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
setup do: clear_config([:instance, :allow_relay])
|
||||
setup do: clear_config([:instance, :rewrite_policy])
|
||||
setup do: clear_config([:mrf_keyword])
|
||||
|
||||
describe "Publish an activity" do
|
||||
setup do
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
import Pleroma.Factory
|
||||
import SweetXml
|
||||
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Feed.FeedView
|
||||
|
||||
clear_config([:feed])
|
||||
setup do: clear_config([:feed])
|
||||
|
||||
test "gets a feed (ATOM)", %{conn: conn} do
|
||||
Pleroma.Config.put(
|
||||
|
|
@ -19,9 +21,9 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, activity1} = Pleroma.Web.CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
|
||||
{:ok, activity1} = CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
|
||||
|
||||
object = Pleroma.Object.normalize(activity1)
|
||||
object = Object.normalize(activity1)
|
||||
|
||||
object_data =
|
||||
Map.put(object.data, "attachment", [
|
||||
|
|
@ -41,14 +43,13 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|> Ecto.Changeset.change(data: object_data)
|
||||
|> Pleroma.Repo.update()
|
||||
|
||||
{:ok, _activity2} =
|
||||
Pleroma.Web.CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
|
||||
{:ok, activity2} = CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
|
||||
|
||||
{:ok, _activity3} = Pleroma.Web.CommonAPI.post(user, %{"status" => "This is :moominmamma"})
|
||||
{:ok, _activity3} = CommonAPI.post(user, %{"status" => "This is :moominmamma"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> put_req_header("accept", "application/atom+xml")
|
||||
|> get(tag_feed_path(conn, :feed, "pleromaart.atom"))
|
||||
|> response(200)
|
||||
|
||||
|
|
@ -63,6 +64,21 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|
||||
assert xpath(xml, ~x"//feed/entry/author/name/text()"ls) == [user.nickname, user.nickname]
|
||||
assert xpath(xml, ~x"//feed/entry/author/id/text()"ls) == [user.ap_id, user.ap_id]
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/atom+xml")
|
||||
|> get("/tags/pleromaart.atom", %{"max_id" => activity2.id})
|
||||
|
||||
assert get_resp_header(conn, "content-type") == ["application/atom+xml; charset=utf-8"]
|
||||
resp = response(conn, 200)
|
||||
xml = parse(resp)
|
||||
|
||||
assert xpath(xml, ~x"//feed/title/text()") == '#pleromaart'
|
||||
|
||||
assert xpath(xml, ~x"//feed/entry/title/text()"l) == [
|
||||
'yeah #PleromaArt'
|
||||
]
|
||||
end
|
||||
|
||||
test "gets a feed (RSS)", %{conn: conn} do
|
||||
|
|
@ -72,9 +88,9 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, activity1} = Pleroma.Web.CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
|
||||
{:ok, activity1} = CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
|
||||
|
||||
object = Pleroma.Object.normalize(activity1)
|
||||
object = Object.normalize(activity1)
|
||||
|
||||
object_data =
|
||||
Map.put(object.data, "attachment", [
|
||||
|
|
@ -94,14 +110,13 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|> Ecto.Changeset.change(data: object_data)
|
||||
|> Pleroma.Repo.update()
|
||||
|
||||
{:ok, activity2} =
|
||||
Pleroma.Web.CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
|
||||
{:ok, activity2} = CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
|
||||
|
||||
{:ok, _activity3} = Pleroma.Web.CommonAPI.post(user, %{"status" => "This is :moominmamma"})
|
||||
{:ok, _activity3} = CommonAPI.post(user, %{"status" => "This is :moominmamma"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/rss+xml")
|
||||
|> put_req_header("accept", "application/rss+xml")
|
||||
|> get(tag_feed_path(conn, :feed, "pleromaart.rss"))
|
||||
|> response(200)
|
||||
|
||||
|
|
@ -131,8 +146,8 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
"https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4"
|
||||
]
|
||||
|
||||
obj1 = Pleroma.Object.normalize(activity1)
|
||||
obj2 = Pleroma.Object.normalize(activity2)
|
||||
obj1 = Object.normalize(activity1)
|
||||
obj2 = Object.normalize(activity2)
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
|
||||
HtmlEntities.decode(FeedView.activity_content(obj2)),
|
||||
|
|
@ -141,7 +156,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> put_req_header("accept", "application/rss+xml")
|
||||
|> get(tag_feed_path(conn, :feed, "pleromaart"))
|
||||
|> response(200)
|
||||
|
||||
|
|
@ -150,5 +165,20 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|
||||
assert xpath(xml, ~x"//channel/description/text()"s) ==
|
||||
"These are public toots tagged with #pleromaart. You can interact with them if you have an account anywhere in the fediverse."
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/rss+xml")
|
||||
|> get("/tags/pleromaart.rss", %{"max_id" => activity2.id})
|
||||
|
||||
assert get_resp_header(conn, "content-type") == ["application/rss+xml; charset=utf-8"]
|
||||
resp = response(conn, 200)
|
||||
xml = parse(resp)
|
||||
|
||||
assert xpath(xml, ~x"//channel/title/text()") == '#pleromaart'
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/title/text()"l) == [
|
||||
'yeah #PleromaArt'
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
alias Pleroma.Object
|
||||
alias Pleroma.User
|
||||
|
||||
clear_config([:instance, :federating]) do
|
||||
Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
describe "feed" do
|
||||
clear_config([:feed])
|
||||
setup do: clear_config([:feed])
|
||||
|
||||
test "gets a feed", %{conn: conn} do
|
||||
Config.put(
|
||||
|
|
@ -54,12 +52,12 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
}
|
||||
)
|
||||
|
||||
_note_activity2 = insert(:note_activity, note: note2)
|
||||
note_activity2 = insert(:note_activity, note: note2)
|
||||
object = Object.normalize(note_activity)
|
||||
|
||||
resp =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> put_req_header("accept", "application/atom+xml")
|
||||
|> get(user_feed_path(conn, :feed, user.nickname))
|
||||
|> response(200)
|
||||
|
||||
|
|
@ -70,12 +68,91 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|
||||
assert activity_titles == ['42 This...', 'This is...']
|
||||
assert resp =~ object.data["content"]
|
||||
|
||||
resp =
|
||||
conn
|
||||
|> put_req_header("accept", "application/atom+xml")
|
||||
|> get("/users/#{user.nickname}/feed", %{"max_id" => note_activity2.id})
|
||||
|> response(200)
|
||||
|
||||
activity_titles =
|
||||
resp
|
||||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//entry/title/text()"l)
|
||||
|
||||
assert activity_titles == ['This is...']
|
||||
end
|
||||
|
||||
test "gets a rss feed", %{conn: conn} do
|
||||
Pleroma.Config.put(
|
||||
[:feed, :post_title],
|
||||
%{max_length: 10, omission: "..."}
|
||||
)
|
||||
|
||||
activity = insert(:note_activity)
|
||||
|
||||
note =
|
||||
insert(:note,
|
||||
data: %{
|
||||
"content" => "This is :moominmamma: note ",
|
||||
"attachment" => [
|
||||
%{
|
||||
"url" => [
|
||||
%{"mediaType" => "image/png", "href" => "https://pleroma.gov/image.png"}
|
||||
]
|
||||
}
|
||||
],
|
||||
"inReplyTo" => activity.data["id"]
|
||||
}
|
||||
)
|
||||
|
||||
note_activity = insert(:note_activity, note: note)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
|
||||
note2 =
|
||||
insert(:note,
|
||||
user: user,
|
||||
data: %{
|
||||
"content" => "42 This is :moominmamma: note ",
|
||||
"inReplyTo" => activity.data["id"]
|
||||
}
|
||||
)
|
||||
|
||||
note_activity2 = insert(:note_activity, note: note2)
|
||||
object = Object.normalize(note_activity)
|
||||
|
||||
resp =
|
||||
conn
|
||||
|> put_req_header("accept", "application/rss+xml")
|
||||
|> get("/users/#{user.nickname}/feed.rss")
|
||||
|> response(200)
|
||||
|
||||
activity_titles =
|
||||
resp
|
||||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//item/title/text()"l)
|
||||
|
||||
assert activity_titles == ['42 This...', 'This is...']
|
||||
assert resp =~ object.data["content"]
|
||||
|
||||
resp =
|
||||
conn
|
||||
|> put_req_header("accept", "application/rss+xml")
|
||||
|> get("/users/#{user.nickname}/feed.rss", %{"max_id" => note_activity2.id})
|
||||
|> response(200)
|
||||
|
||||
activity_titles =
|
||||
resp
|
||||
|> SweetXml.parse()
|
||||
|> SweetXml.xpath(~x"//item/title/text()"l)
|
||||
|
||||
assert activity_titles == ['This is...']
|
||||
end
|
||||
|
||||
test "returns 404 for a missing feed", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> put_req_header("accept", "application/atom+xml")
|
||||
|> get(user_feed_path(conn, :feed, "nonexisting"))
|
||||
|
||||
assert response(conn, 404)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ defmodule Pleroma.Instances.InstanceTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config_all([:instance, :federation_reachability_timeout_days]) do
|
||||
Pleroma.Config.put([:instance, :federation_reachability_timeout_days], 1)
|
||||
end
|
||||
setup_all do: clear_config([:instance, :federation_reachability_timeout_days], 1)
|
||||
|
||||
describe "set_reachable/1" do
|
||||
test "clears `unreachable_since` of existing matching Instance record having non-nil `unreachable_since`" do
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ defmodule Pleroma.InstancesTest do
|
|||
|
||||
use Pleroma.DataCase
|
||||
|
||||
clear_config_all([:instance, :federation_reachability_timeout_days]) do
|
||||
Pleroma.Config.put([:instance, :federation_reachability_timeout_days], 1)
|
||||
end
|
||||
setup_all do: clear_config([:instance, :federation_reachability_timeout_days], 1)
|
||||
|
||||
describe "reachable?/1" do
|
||||
test "returns `true` for host / url with unknown reachability status" do
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([:instance, :public])
|
||||
setup do: clear_config([:instance, :public])
|
||||
|
||||
test "put settings", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
|
||||
import Pleroma.Factory
|
||||
clear_config([:instance, :max_account_fields])
|
||||
|
||||
setup do: clear_config([:instance, :max_account_fields])
|
||||
|
||||
describe "updating credentials" do
|
||||
setup do: oauth_access(["write:accounts"])
|
||||
|
|
@ -75,7 +76,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
|
||||
conn =
|
||||
patch(conn, "/api/v1/accounts/update_credentials", %{
|
||||
"note" => "I drink #cofe with @#{user2.nickname}"
|
||||
"note" => "I drink #cofe with @#{user2.nickname}\n\nsuya.."
|
||||
})
|
||||
|
||||
assert user_data = json_response(conn, 200)
|
||||
|
|
@ -83,7 +84,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
assert user_data["note"] ==
|
||||
~s(I drink <a class="hashtag" data-tag="cofe" href="http://localhost:4001/tag/cofe">#cofe</a> with <span class="h-card"><a data-user="#{
|
||||
user2.id
|
||||
}" class="u-url mention" href="#{user2.ap_id}" rel="ugc">@<span>#{user2.nickname}</span></a></span>)
|
||||
}" class="u-url mention" href="#{user2.ap_id}" rel="ugc">@<span>#{user2.nickname}</span></a></span><br/><br/>suya..)
|
||||
end
|
||||
|
||||
test "updates the user's locking status", %{conn: conn} do
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
|
|
@ -15,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
import Pleroma.Factory
|
||||
|
||||
describe "account fetching" do
|
||||
clear_config([:instance, :limit_to_local_content])
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "works by id" do
|
||||
user = insert(:user)
|
||||
|
|
@ -46,7 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
test "works by nickname for remote users" do
|
||||
Pleroma.Config.put([:instance, :limit_to_local_content], false)
|
||||
Config.put([:instance, :limit_to_local_content], false)
|
||||
user = insert(:user, nickname: "user@example.com", local: false)
|
||||
|
||||
conn =
|
||||
|
|
@ -58,7 +59,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
test "respects limit_to_local_content == :all for remote user nicknames" do
|
||||
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
|
||||
Config.put([:instance, :limit_to_local_content], :all)
|
||||
|
||||
user = insert(:user, nickname: "user@example.com", local: false)
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
test "respects limit_to_local_content == :unauthenticated for remote user nicknames" do
|
||||
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
||||
Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
||||
|
||||
user = insert(:user, nickname: "user@example.com", local: false)
|
||||
reading_user = insert(:user)
|
||||
|
|
@ -140,6 +141,98 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
defp local_and_remote_users do
|
||||
local = insert(:user)
|
||||
remote = insert(:user, local: false)
|
||||
{:ok, local: local, remote: remote}
|
||||
end
|
||||
|
||||
describe "user fetching with restrict unauthenticated profiles for local and remote" do
|
||||
setup do: local_and_remote_users()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "user fetching with restrict unauthenticated profiles for local" do
|
||||
setup do: local_and_remote_users()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "user fetching with restrict unauthenticated profiles for remote" do
|
||||
setup do: local_and_remote_users()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "user timelines" do
|
||||
setup do: oauth_access(["read:statuses"])
|
||||
|
||||
|
|
@ -293,6 +386,102 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
defp local_and_remote_activities(%{local: local, remote: remote}) do
|
||||
insert(:note_activity, user: local)
|
||||
insert(:note_activity, user: remote, local: false)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
describe "statuses with restrict unauthenticated profiles for local and remote" do
|
||||
setup do: local_and_remote_users()
|
||||
setup :local_and_remote_activities
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}/statuses")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "statuses with restrict unauthenticated profiles for local" do
|
||||
setup do: local_and_remote_users()
|
||||
setup :local_and_remote_activities
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "statuses with restrict unauthenticated profiles for remote" do
|
||||
setup do: local_and_remote_users()
|
||||
setup :local_and_remote_activities
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}/statuses")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Can't find user"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/accounts/#{remote.id}/statuses")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "followers" do
|
||||
setup do: oauth_access(["read:accounts"])
|
||||
|
||||
|
|
@ -601,7 +790,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
[valid_params: valid_params]
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "Account registration via Application", %{conn: conn} do
|
||||
conn =
|
||||
|
|
@ -699,7 +888,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end)
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "returns bad_request if missing email params when :account_activation_required is enabled",
|
||||
%{conn: conn, valid_params: valid_params} do
|
||||
|
|
@ -756,9 +945,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
describe "create account by app / rate limit" do
|
||||
clear_config([:rate_limit, :app_account_creation]) do
|
||||
Pleroma.Config.put([:rate_limit, :app_account_creation], {10_000, 2})
|
||||
end
|
||||
setup do: clear_config([:rate_limit, :app_account_creation], {10_000, 2})
|
||||
|
||||
test "respects rate limit setting", %{conn: conn} do
|
||||
app_token = insert(:oauth_token, user: nil)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
[image: image]
|
||||
end
|
||||
|
||||
clear_config([:media_proxy])
|
||||
clear_config([Pleroma.Upload])
|
||||
setup do: clear_config([:media_proxy])
|
||||
setup do: clear_config([Pleroma.Upload])
|
||||
|
||||
test "returns uploaded image", %{conn: conn, image: image} do
|
||||
desc = "Description of the image"
|
||||
|
|
|
|||
|
|
@ -304,6 +304,51 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
assert [%{"id" => ^reblog_notification_id}] = json_response(conn_res, 200)
|
||||
end
|
||||
|
||||
test "filters notifications using include_types" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, favorite_activity, _} = CommonAPI.favorite(create_activity.id, other_user)
|
||||
{:ok, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
mention_notification_id = get_notification_id_by_activity(mention_activity)
|
||||
favorite_notification_id = get_notification_id_by_activity(favorite_activity)
|
||||
reblog_notification_id = get_notification_id_by_activity(reblog_activity)
|
||||
follow_notification_id = get_notification_id_by_activity(follow_activity)
|
||||
|
||||
conn_res = get(conn, "/api/v1/notifications", %{include_types: ["follow"]})
|
||||
|
||||
assert [%{"id" => ^follow_notification_id}] = json_response(conn_res, 200)
|
||||
|
||||
conn_res = get(conn, "/api/v1/notifications", %{include_types: ["mention"]})
|
||||
|
||||
assert [%{"id" => ^mention_notification_id}] = json_response(conn_res, 200)
|
||||
|
||||
conn_res = get(conn, "/api/v1/notifications", %{include_types: ["favourite"]})
|
||||
|
||||
assert [%{"id" => ^favorite_notification_id}] = json_response(conn_res, 200)
|
||||
|
||||
conn_res = get(conn, "/api/v1/notifications", %{include_types: ["reblog"]})
|
||||
|
||||
assert [%{"id" => ^reblog_notification_id}] = json_response(conn_res, 200)
|
||||
|
||||
result = conn |> get("/api/v1/notifications") |> json_response(200)
|
||||
|
||||
assert length(result) == 4
|
||||
|
||||
result =
|
||||
conn
|
||||
|> get("/api/v1/notifications", %{
|
||||
include_types: ["follow", "mention", "favourite", "reblog"]
|
||||
})
|
||||
|> json_response(200)
|
||||
|
||||
assert length(result) == 4
|
||||
end
|
||||
|
||||
test "destroy multiple" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:notifications", "write:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do
|
|||
import Pleroma.Factory
|
||||
import Ecto.Query
|
||||
|
||||
clear_config([ScheduledActivity, :enabled])
|
||||
setup do: clear_config([ScheduledActivity, :enabled])
|
||||
|
||||
test "shows scheduled activities" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:statuses"])
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([:instance, :federating])
|
||||
clear_config([:instance, :allow_relay])
|
||||
clear_config([:rich_media, :enabled])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :allow_relay])
|
||||
setup do: clear_config([:rich_media, :enabled])
|
||||
|
||||
describe "posting statuses" do
|
||||
setup do: oauth_access(["write:statuses"])
|
||||
|
|
@ -476,6 +476,95 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
assert id == to_string(activity.id)
|
||||
end
|
||||
|
||||
defp local_and_remote_activities do
|
||||
local = insert(:note_activity)
|
||||
remote = insert(:note_activity, local: false)
|
||||
{:ok, local: local, remote: remote}
|
||||
end
|
||||
|
||||
describe "status with restrict unauthenticated activities for local and remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Record not found"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Record not found"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "status with restrict unauthenticated activities for local" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Record not found"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "status with restrict unauthenticated activities for remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
|
||||
|
||||
assert json_response(res_conn, :not_found) == %{
|
||||
"error" => "Record not found"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
|
||||
assert %{"id" => _} = json_response(res_conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
test "getting a status that doesn't exist returns 404" do
|
||||
%{conn: conn} = oauth_access(["read:statuses"])
|
||||
activity = insert(:note_activity)
|
||||
|
|
@ -514,6 +603,70 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
assert [%{"id" => ^id1}, %{"id" => ^id2}] = Enum.sort_by(json_response(conn, :ok), & &1["id"])
|
||||
end
|
||||
|
||||
describe "getting statuses by ids with restricted unauthenticated for local and remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
||||
assert json_response(res_conn, 200) == []
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting statuses by ids with restricted unauthenticated for local" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
||||
remote_id = remote.id
|
||||
assert [%{"id" => ^remote_id}] = json_response(res_conn, 200)
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting statuses by ids with restricted unauthenticated for remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
||||
local_id = local.id
|
||||
assert [%{"id" => ^local_id}] = json_response(res_conn, 200)
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{local: local, remote: remote} do
|
||||
%{conn: conn} = oauth_access(["read"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "deleting a status" do
|
||||
test "when you created it" do
|
||||
%{user: author, conn: conn} = oauth_access(["write:statuses"])
|
||||
|
|
@ -739,9 +892,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
%{activity: activity}
|
||||
end
|
||||
|
||||
clear_config([:instance, :max_pinned_statuses]) do
|
||||
Config.put([:instance, :max_pinned_statuses], 1)
|
||||
end
|
||||
setup do: clear_config([:instance, :max_pinned_statuses], 1)
|
||||
|
||||
test "pin status", %{conn: conn, user: user, activity: activity} do
|
||||
id_str = to_string(activity.id)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
clear_config([:instance, :public])
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
|
|
@ -80,15 +78,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
assert [%{"content" => "test"}] = json_response(conn, :ok)
|
||||
end
|
||||
|
||||
test "the public timeline when public is set to false", %{conn: conn} do
|
||||
Config.put([:instance, :public], false)
|
||||
|
||||
assert %{"error" => "This resource requires authentication."} ==
|
||||
conn
|
||||
|> get("/api/v1/timelines/public", %{"local" => "False"})
|
||||
|> json_response(:forbidden)
|
||||
end
|
||||
|
||||
test "the public timeline includes only public statuses for an authenticated user" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:statuses"])
|
||||
|
||||
|
|
@ -102,6 +91,98 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
defp local_and_remote_activities do
|
||||
insert(:note_activity)
|
||||
insert(:note_activity, local: false)
|
||||
:ok
|
||||
end
|
||||
|
||||
describe "public with restrict unauthenticated timeline for local and federated timelines" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn} do
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
|
||||
assert json_response(res_conn, :unauthorized) == %{
|
||||
"error" => "authorization required for timeline view"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
|
||||
|
||||
assert json_response(res_conn, :unauthorized) == %{
|
||||
"error" => "authorization required for timeline view"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated" do
|
||||
%{conn: conn} = oauth_access(["read:statuses"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "public with restrict unauthenticated timeline for local" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn} do
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
|
||||
assert json_response(res_conn, :unauthorized) == %{
|
||||
"error" => "authorization required for timeline view"
|
||||
}
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{conn: _conn} do
|
||||
%{conn: conn} = oauth_access(["read:statuses"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "public with restrict unauthenticated timeline for remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn} do
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
|
||||
|
||||
assert json_response(res_conn, :unauthorized) == %{
|
||||
"error" => "authorization required for timeline view"
|
||||
}
|
||||
end
|
||||
|
||||
test "if user is authenticated", %{conn: _conn} do
|
||||
%{conn: conn} = oauth_access(["read:statuses"])
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "direct" do
|
||||
test "direct timeline", %{conn: conn} do
|
||||
user_one = insert(:user)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
background: background_image,
|
||||
nickname: "shp@shitposter.club",
|
||||
name: ":karjalanpiirakka: shp",
|
||||
bio: "<script src=\"invalid-html\"></script><span>valid html</span>",
|
||||
bio:
|
||||
"<script src=\"invalid-html\"></script><span>valid html</span>. a<br>b<br/>c<br >d<br />f",
|
||||
inserted_at: ~N[2017-08-15 15:47:06.597036]
|
||||
})
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
followers_count: 3,
|
||||
following_count: 0,
|
||||
statuses_count: 5,
|
||||
note: "<span>valid html</span>",
|
||||
note: "<span>valid html</span>. a<br/>b<br/>c<br/>d<br/>f",
|
||||
url: user.ap_id,
|
||||
avatar: "http://localhost:4001/images/avi.png",
|
||||
avatar_static: "http://localhost:4001/images/avi.png",
|
||||
|
|
@ -63,7 +64,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
fields: [],
|
||||
bot: false,
|
||||
source: %{
|
||||
note: "valid html",
|
||||
note: "valid html. a\nb\nc\nd\nf",
|
||||
sensitive: false,
|
||||
pleroma: %{
|
||||
actor_type: "Person",
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
|||
import Mock
|
||||
alias Pleroma.Config
|
||||
|
||||
clear_config(:media_proxy)
|
||||
clear_config([Pleroma.Web.Endpoint, :secret_key_base])
|
||||
setup do: clear_config(:media_proxy)
|
||||
setup do: clear_config([Pleroma.Web.Endpoint, :secret_key_base])
|
||||
|
||||
test "it returns 404 when MediaProxy disabled", %{conn: conn} do
|
||||
Config.put([:media_proxy, :enabled], false)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ defmodule Pleroma.Web.MediaProxyTest do
|
|||
import Pleroma.Web.MediaProxy
|
||||
alias Pleroma.Web.MediaProxy.MediaProxyController
|
||||
|
||||
clear_config([:media_proxy, :enabled])
|
||||
clear_config(Pleroma.Upload)
|
||||
setup do: clear_config([:media_proxy, :enabled])
|
||||
setup do: clear_config(Pleroma.Upload)
|
||||
|
||||
describe "when enabled" do
|
||||
setup do
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
|
|||
import Pleroma.Factory
|
||||
alias Pleroma.Web.Metadata.Providers.OpenGraph
|
||||
|
||||
clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
|
||||
setup do: clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
|
||||
|
||||
test "it renders all supported types of attachments and skips unknown types" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
|
|||
alias Pleroma.Web.Metadata.Utils
|
||||
alias Pleroma.Web.Router
|
||||
|
||||
clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
|
||||
setup do: clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
|
||||
|
||||
test "it renders twitter card for user info" do
|
||||
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([:mrf_simple])
|
||||
clear_config(:instance)
|
||||
setup do: clear_config([:mrf_simple])
|
||||
setup do: clear_config(:instance)
|
||||
|
||||
test "GET /.well-known/nodeinfo", %{conn: conn} do
|
||||
links =
|
||||
|
|
@ -105,7 +105,7 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
end
|
||||
|
||||
describe "`metadata/federation/enabled`" do
|
||||
clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
|
||||
test "it shows if federation is enabled/disabled", %{conn: conn} do
|
||||
Pleroma.Config.put([:instance, :federating], true)
|
||||
|
|
|
|||
|
|
@ -12,13 +12,9 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
|
|||
|
||||
@skip if !Code.ensure_loaded?(:eldap), do: :skip
|
||||
|
||||
clear_config_all([:ldap, :enabled]) do
|
||||
Pleroma.Config.put([:ldap, :enabled], true)
|
||||
end
|
||||
setup_all do: clear_config([:ldap, :enabled], true)
|
||||
|
||||
clear_config_all(Pleroma.Web.Auth.Authenticator) do
|
||||
Pleroma.Config.put(Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.LDAPAuthenticator)
|
||||
end
|
||||
setup_all do: clear_config(Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.LDAPAuthenticator)
|
||||
|
||||
@tag @skip
|
||||
test "authorizes the existing user using LDAP credentials" do
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
|||
key: "_test",
|
||||
signing_salt: "cooldude"
|
||||
]
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
describe "in OAuth consumer mode, " do
|
||||
setup do
|
||||
|
|
@ -31,12 +30,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
|||
]
|
||||
end
|
||||
|
||||
clear_config([:auth, :oauth_consumer_strategies]) do
|
||||
Pleroma.Config.put(
|
||||
[:auth, :oauth_consumer_strategies],
|
||||
~w(twitter facebook)
|
||||
)
|
||||
end
|
||||
setup do: clear_config([:auth, :oauth_consumer_strategies], ~w(twitter facebook))
|
||||
|
||||
test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{
|
||||
app: app,
|
||||
|
|
@ -944,7 +938,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
|||
end
|
||||
|
||||
describe "POST /oauth/token - refresh token" do
|
||||
clear_config([:oauth2, :issue_new_refresh_token])
|
||||
setup do: clear_config([:oauth2, :issue_new_refresh_token])
|
||||
|
||||
test "issues a new access token with keep fresh token" do
|
||||
Pleroma.Config.put([:oauth2, :issue_new_refresh_token], true)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance, :federating]) do
|
||||
Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
# Note: see ActivityPubControllerTest for JSON format tests
|
||||
describe "GET /objects/:uuid (text/html)" do
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
[user: user]
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required]) do
|
||||
Config.put([:instance, :account_activation_required], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :account_activation_required], true)
|
||||
|
||||
test "resend account confirmation email", %{conn: conn, user: user} do
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
Pleroma.Config.get!([:instance, :static_dir]),
|
||||
"emoji"
|
||||
)
|
||||
|
||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
||||
Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||
end
|
||||
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||
|
||||
test "shared & non-shared pack information in list_packs is ok" do
|
||||
conn = build_conn()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
defmodule Pleroma.Web.FederatingPlugTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
|
||||
test "returns and halt the conn when federating is disabled" do
|
||||
Pleroma.Config.put([:instance, :federating], false)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:rich_media, :enabled])
|
||||
setup do: clear_config([:rich_media, :enabled])
|
||||
|
||||
test "refuses to crawl incomplete URLs" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -8,13 +8,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config_all([:static_fe, :enabled]) do
|
||||
Config.put([:static_fe, :enabled], true)
|
||||
end
|
||||
|
||||
clear_config([:instance, :federating]) do
|
||||
Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup_all do: clear_config([:static_fe, :enabled], true)
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
setup %{conn: conn} do
|
||||
conn = put_req_header(conn, "accept", "text/html")
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
@streamer_timeout 150
|
||||
@streamer_start_wait 10
|
||||
|
||||
clear_config([:instance, :skip_thread_containment])
|
||||
setup do: clear_config([:instance, :skip_thread_containment])
|
||||
|
||||
describe "user streams" do
|
||||
setup do
|
||||
|
|
|
|||
|
|
@ -17,13 +17,10 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all([:instance, :federating]) do
|
||||
Config.put([:instance, :federating], true)
|
||||
end
|
||||
|
||||
clear_config([:instance])
|
||||
clear_config([:frontend_configurations, :pleroma_fe])
|
||||
clear_config([:user, :deny_follow_blocked])
|
||||
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
|
||||
|
|
|
|||
|
|
@ -117,9 +117,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
end
|
||||
|
||||
describe "register with one time token" do
|
||||
clear_config([:instance, :registrations_open]) do
|
||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||
end
|
||||
setup do: clear_config([:instance, :registrations_open], false)
|
||||
|
||||
test "returns user on success" do
|
||||
{:ok, invite} = UserInviteToken.create_invite()
|
||||
|
|
@ -184,9 +182,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
end
|
||||
|
||||
describe "registers with date limited token" do
|
||||
clear_config([:instance, :registrations_open]) do
|
||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||
end
|
||||
setup do: clear_config([:instance, :registrations_open], false)
|
||||
|
||||
setup do
|
||||
data = %{
|
||||
|
|
@ -246,9 +242,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
end
|
||||
|
||||
describe "registers with reusable token" do
|
||||
clear_config([:instance, :registrations_open]) do
|
||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||
end
|
||||
setup do: clear_config([:instance, :registrations_open], false)
|
||||
|
||||
test "returns user on success, after him registration fails" do
|
||||
{:ok, invite} = UserInviteToken.create_invite(%{max_use: 100})
|
||||
|
|
@ -292,9 +286,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
end
|
||||
|
||||
describe "registers with reusable date limited token" do
|
||||
clear_config([:instance, :registrations_open]) do
|
||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||
end
|
||||
setup do: clear_config([:instance, :registrations_open], false)
|
||||
|
||||
test "returns user on success" do
|
||||
{:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100})
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance])
|
||||
clear_config([:frontend_configurations, :pleroma_fe])
|
||||
setup do: clear_config([:instance])
|
||||
setup do: clear_config([:frontend_configurations, :pleroma_fe])
|
||||
|
||||
describe "POST /api/pleroma/follow_import" do
|
||||
setup do: oauth_access(["follow"])
|
||||
|
|
@ -318,7 +318,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
|
||||
describe "GET /api/pleroma/healthcheck" do
|
||||
clear_config([:instance, :healthcheck])
|
||||
setup do: clear_config([:instance, :healthcheck])
|
||||
|
||||
test "returns 503 when healthcheck disabled", %{conn: conn} do
|
||||
Config.put([:instance, :healthcheck], false)
|
||||
|
|
@ -427,9 +427,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
|
||||
describe "POST /main/ostatus - remote_subscribe/2" do
|
||||
clear_config([:instance, :federating]) do
|
||||
Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "renders subscribe form", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all([:instance, :federating]) do
|
||||
Pleroma.Config.put([:instance, :federating], true)
|
||||
end
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "GET host-meta" do
|
||||
response =
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Workers.Cron.ClearOauthTokenWorkerTest do
|
|||
import Pleroma.Factory
|
||||
alias Pleroma.Workers.Cron.ClearOauthTokenWorker
|
||||
|
||||
clear_config([:oauth2, :clean_expired_tokens])
|
||||
setup do: clear_config([:oauth2, :clean_expired_tokens])
|
||||
|
||||
test "deletes expired tokens" do
|
||||
insert(:oauth_token,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorkerTest do
|
|||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
clear_config([:email_notifications, :digest])
|
||||
setup do: clear_config([:email_notifications, :digest])
|
||||
|
||||
setup do
|
||||
Pleroma.Config.put([:email_notifications, :digest], %{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Workers.Cron.PurgeExpiredActivitiesWorkerTest do
|
|||
import Pleroma.Factory
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
clear_config([ActivityExpiration, :enabled])
|
||||
setup do: clear_config([ActivityExpiration, :enabled])
|
||||
|
||||
test "deletes an expiration activity" do
|
||||
Pleroma.Config.put([ActivityExpiration, :enabled], true)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Workers.ScheduledActivityWorkerTest do
|
|||
import Pleroma.Factory
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
clear_config([ScheduledActivity, :enabled])
|
||||
setup do: clear_config([ScheduledActivity, :enabled])
|
||||
|
||||
test "creates a status from the scheduled activity" do
|
||||
Pleroma.Config.put([ScheduledActivity, :enabled], true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue