forked from AkkomaGang/akkoma
Merge branch 'tests-clear-config-tweaks' into 'develop'
Tweaks to `clear_config` calls in tests See merge request pleroma/pleroma!2209
This commit is contained in:
commit
cf4ecffcea
31 changed files with 87 additions and 117 deletions
|
@ -138,6 +138,8 @@ test "when association is not loaded" do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clear_config([:instance, :limit_to_local_content])
|
||||||
|
|
||||||
test "finds utf8 text in statuses", %{
|
test "finds utf8 text in statuses", %{
|
||||||
japanese_activity: japanese_activity,
|
japanese_activity: japanese_activity,
|
||||||
user: user
|
user: user
|
||||||
|
@ -165,7 +167,6 @@ test "find only local statuses for unauthenticated users when `limit_to_local_c
|
||||||
%{local_activity: local_activity} do
|
%{local_activity: local_activity} do
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
|
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
|
||||||
assert [^local_activity] = Activity.search(nil, "find me")
|
assert [^local_activity] = Activity.search(nil, "find me")
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "find all statuses for unauthenticated users when `limit_to_local_content` is `false`",
|
test "find all statuses for unauthenticated users when `limit_to_local_content` is `false`",
|
||||||
|
@ -178,8 +179,6 @@ test "find all statuses for unauthenticated users when `limit_to_local_content`
|
||||||
activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id)
|
activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id)
|
||||||
|
|
||||||
assert [^local_activity, ^remote_activity] = activities
|
assert [^local_activity, ^remote_activity] = activities
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.HTTP.RequestBuilderTest do
|
||||||
|
|
||||||
describe "headers/2" do
|
describe "headers/2" do
|
||||||
clear_config([:http, :send_user_agent])
|
clear_config([:http, :send_user_agent])
|
||||||
|
clear_config([:http, :user_agent])
|
||||||
|
|
||||||
test "don't send pleroma user agent" do
|
test "don't send pleroma user agent" do
|
||||||
assert RequestBuilder.headers(%{}, []) == %{headers: []}
|
assert RequestBuilder.headers(%{}, []) == %{headers: []}
|
||||||
|
|
|
@ -75,6 +75,7 @@ test "ensures cache is cleared for the object" do
|
||||||
|
|
||||||
describe "delete attachments" do
|
describe "delete attachments" do
|
||||||
clear_config([Pleroma.Upload])
|
clear_config([Pleroma.Upload])
|
||||||
|
clear_config([:instance, :cleanup_attachments])
|
||||||
|
|
||||||
test "Disabled via config" do
|
test "Disabled via config" do
|
||||||
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||||
|
|
|
@ -23,6 +23,8 @@ test "does nothing if a user is assigned", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when secret set it assigns an admin user" do
|
describe "when secret set it assigns an admin user" do
|
||||||
|
clear_config([:admin_token])
|
||||||
|
|
||||||
test "with `admin_token` query parameter", %{conn: conn} do
|
test "with `admin_token` query parameter", %{conn: conn} do
|
||||||
Pleroma.Config.put(:admin_token, "password123")
|
Pleroma.Config.put(:admin_token, "password123")
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.Plugs.HTTPSecurityPlugTest do
|
||||||
|
|
||||||
clear_config([:http_securiy, :enabled])
|
clear_config([:http_securiy, :enabled])
|
||||||
clear_config([:http_security, :sts])
|
clear_config([:http_security, :sts])
|
||||||
|
clear_config([:http_security, :referrer_policy])
|
||||||
|
|
||||||
describe "http security enabled" do
|
describe "http security enabled" do
|
||||||
setup do
|
setup do
|
||||||
|
|
|
@ -8,6 +8,10 @@ defmodule Pleroma.Plugs.RemoteIpTest do
|
||||||
|
|
||||||
alias Pleroma.Plugs.RemoteIp
|
alias Pleroma.Plugs.RemoteIp
|
||||||
|
|
||||||
|
import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2]
|
||||||
|
|
||||||
|
clear_config(RemoteIp)
|
||||||
|
|
||||||
test "disabled" do
|
test "disabled" do
|
||||||
Pleroma.Config.put(RemoteIp, enabled: false)
|
Pleroma.Config.put(RemoteIp, enabled: false)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ defmodule Pleroma.Plugs.UserEnabledPlugTest do
|
||||||
alias Pleroma.Plugs.UserEnabledPlug
|
alias Pleroma.Plugs.UserEnabledPlug
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
clear_config([:instance, :account_activation_required])
|
||||||
|
|
||||||
test "doesn't do anything if the user isn't set", %{conn: conn} do
|
test "doesn't do anything if the user isn't set", %{conn: conn} do
|
||||||
ret_conn =
|
ret_conn =
|
||||||
conn
|
conn
|
||||||
|
@ -18,7 +20,6 @@ test "doesn't do anything if the user isn't set", %{conn: conn} do
|
||||||
|
|
||||||
test "with a user that's not confirmed and a config requiring confirmation, it removes that user",
|
test "with a user that's not confirmed and a config requiring confirmation, it removes that user",
|
||||||
%{conn: conn} do
|
%{conn: conn} do
|
||||||
old = Pleroma.Config.get([:instance, :account_activation_required])
|
|
||||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
user = insert(:user, confirmation_pending: true)
|
user = insert(:user, confirmation_pending: true)
|
||||||
|
@ -29,8 +30,6 @@ test "with a user that's not confirmed and a config requiring confirmation, it r
|
||||||
|> UserEnabledPlug.call(%{})
|
|> UserEnabledPlug.call(%{})
|
||||||
|
|
||||||
assert conn.assigns.user == nil
|
assert conn.assigns.user == nil
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :account_activation_required], old)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with a user that is deactivated, it removes that user", %{conn: conn} do
|
test "with a user that is deactivated, it removes that user", %{conn: conn} do
|
||||||
|
|
|
@ -67,6 +67,8 @@ test "return error if has not assoc " do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check])
|
||||||
|
|
||||||
test "raises if it detects unapplied migrations" do
|
test "raises if it detects unapplied migrations" do
|
||||||
assert_raise Pleroma.Repo.UnappliedMigrationsError, fn ->
|
assert_raise Pleroma.Repo.UnappliedMigrationsError, fn ->
|
||||||
capture_log(&Repo.check_migrations_applied!/0)
|
capture_log(&Repo.check_migrations_applied!/0)
|
||||||
|
@ -74,18 +76,8 @@ test "raises if it detects unapplied migrations" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "doesn't do anything if disabled" do
|
test "doesn't do anything if disabled" do
|
||||||
disable_migration_check =
|
|
||||||
Pleroma.Config.get([:i_am_aware_this_may_cause_data_loss, :disable_migration_check])
|
|
||||||
|
|
||||||
Pleroma.Config.put([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true)
|
Pleroma.Config.put([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true)
|
||||||
|
|
||||||
on_exit(fn ->
|
|
||||||
Pleroma.Config.put(
|
|
||||||
[:i_am_aware_this_may_cause_data_loss, :disable_migration_check],
|
|
||||||
disable_migration_check
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
|
|
||||||
assert :ok == Repo.check_migrations_applied!()
|
assert :ok == Repo.check_migrations_applied!()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,7 @@ defmacro clear_config(config_path, do: yield) do
|
||||||
end
|
end
|
||||||
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_all(config_path) do
|
||||||
quote do
|
quote do
|
||||||
clear_config_all(unquote(config_path)) do
|
clear_config_all(unquote(config_path)) do
|
||||||
|
@ -33,6 +34,11 @@ defmacro clear_config_all(config_path) do
|
||||||
end
|
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
|
defmacro clear_config_all(config_path, do: yield) do
|
||||||
quote do
|
quote do
|
||||||
setup_all do
|
setup_all do
|
||||||
|
|
|
@ -15,6 +15,8 @@ defmodule Pleroma.UserSearchTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "User.search" do
|
describe "User.search" do
|
||||||
|
clear_config([:instance, :limit_to_local_content])
|
||||||
|
|
||||||
test "excluded invisible users from results" do
|
test "excluded invisible users from results" do
|
||||||
user = insert(:user, %{nickname: "john t1000"})
|
user = insert(:user, %{nickname: "john t1000"})
|
||||||
insert(:user, %{invisible: true, nickname: "john t800"})
|
insert(:user, %{invisible: true, nickname: "john t800"})
|
||||||
|
@ -127,8 +129,6 @@ test "find only local users for authenticated users when `limit_to_local_content
|
||||||
insert(:user, %{nickname: "lain@pleroma.soykaf.com", local: false})
|
insert(:user, %{nickname: "lain@pleroma.soykaf.com", local: false})
|
||||||
|
|
||||||
assert [%{id: ^id}] = User.search("lain")
|
assert [%{id: ^id}] = User.search("lain")
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "find all users for unauthenticated users when `limit_to_local_content` is `false`" do
|
test "find all users for unauthenticated users when `limit_to_local_content` is `false`" do
|
||||||
|
@ -145,8 +145,6 @@ test "find all users for unauthenticated users when `limit_to_local_content` is
|
||||||
|> Enum.sort()
|
|> Enum.sort()
|
||||||
|
|
||||||
assert [u1.id, u2.id, u3.id] == results
|
assert [u1.id, u2.id, u3.id] == results
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does not yield false-positive matches" do
|
test "does not yield false-positive matches" do
|
||||||
|
|
|
@ -297,15 +297,7 @@ test "local users do not automatically follow local locked accounts" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "unfollow/2" do
|
describe "unfollow/2" do
|
||||||
setup do
|
clear_config([:instance, :external_user_synchronization])
|
||||||
setting = Pleroma.Config.get([:instance, :external_user_synchronization])
|
|
||||||
|
|
||||||
on_exit(fn ->
|
|
||||||
Pleroma.Config.put([:instance, :external_user_synchronization], setting)
|
|
||||||
end)
|
|
||||||
|
|
||||||
:ok
|
|
||||||
end
|
|
||||||
|
|
||||||
test "unfollow with syncronizes external user" do
|
test "unfollow with syncronizes external user" do
|
||||||
Pleroma.Config.put([:instance, :external_user_synchronization], true)
|
Pleroma.Config.put([:instance, :external_user_synchronization], true)
|
||||||
|
@ -383,6 +375,7 @@ test "fetches correct profile for nickname beginning with number" do
|
||||||
password_confirmation: "test",
|
password_confirmation: "test",
|
||||||
email: "email@example.com"
|
email: "email@example.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_config([:instance, :autofollowed_nicknames])
|
clear_config([:instance, :autofollowed_nicknames])
|
||||||
clear_config([:instance, :welcome_message])
|
clear_config([:instance, :welcome_message])
|
||||||
clear_config([:instance, :welcome_user_nickname])
|
clear_config([:instance, :welcome_user_nickname])
|
||||||
|
@ -1754,17 +1747,14 @@ test "changes email", %{user: user} do
|
||||||
|
|
||||||
describe "get_cached_by_nickname_or_id" do
|
describe "get_cached_by_nickname_or_id" do
|
||||||
setup do
|
setup do
|
||||||
limit_to_local_content = Pleroma.Config.get([:instance, :limit_to_local_content])
|
|
||||||
local_user = insert(:user)
|
local_user = insert(:user)
|
||||||
remote_user = insert(:user, nickname: "nickname@example.com", local: false)
|
remote_user = insert(:user, nickname: "nickname@example.com", local: false)
|
||||||
|
|
||||||
on_exit(fn ->
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local_content)
|
|
||||||
end)
|
|
||||||
|
|
||||||
[local_user: local_user, remote_user: remote_user]
|
[local_user: local_user, remote_user: remote_user]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clear_config([:instance, :limit_to_local_content])
|
||||||
|
|
||||||
test "allows getting remote users by id no matter what :limit_to_local_content is set to", %{
|
test "allows getting remote users by id no matter what :limit_to_local_content is set to", %{
|
||||||
remote_user: remote_user
|
remote_user: remote_user
|
||||||
} do
|
} do
|
||||||
|
|
|
@ -1224,6 +1224,8 @@ test "creates an undo activity for the last block" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "deletion" do
|
describe "deletion" do
|
||||||
|
clear_config([:instance, :rewrite_policy])
|
||||||
|
|
||||||
test "it creates a delete activity and deletes the original object" do
|
test "it creates a delete activity and deletes the original object" do
|
||||||
note = insert(:note_activity)
|
note = insert(:note_activity)
|
||||||
object = Object.normalize(note)
|
object = Object.normalize(note)
|
||||||
|
@ -1327,11 +1329,8 @@ test "decreases reply count" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it passes delete activity through MRF before deleting the object" do
|
test "it passes delete activity through MRF before deleting the object" do
|
||||||
rewrite_policy = Pleroma.Config.get([:instance, :rewrite_policy])
|
|
||||||
Pleroma.Config.put([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.DropPolicy)
|
Pleroma.Config.put([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.DropPolicy)
|
||||||
|
|
||||||
on_exit(fn -> Pleroma.Config.put([:instance, :rewrite_policy], rewrite_policy) end)
|
|
||||||
|
|
||||||
note = insert(:note_activity)
|
note = insert(:note_activity)
|
||||||
object = Object.normalize(note)
|
object = Object.normalize(note)
|
||||||
|
|
||||||
|
@ -1396,6 +1395,8 @@ test "it filters broken threads" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update" do
|
describe "update" do
|
||||||
|
clear_config([:instance, :max_pinned_statuses])
|
||||||
|
|
||||||
test "it creates an update activity with the new user data" do
|
test "it creates an update activity with the new user data" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, user} = User.ensure_keys_present(user)
|
{:ok, user} = User.ensure_keys_present(user)
|
||||||
|
|
|
@ -26,6 +26,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
|
||||||
[user: user, message: message]
|
[user: user, message: message]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clear_config(:mrf_hellthread)
|
||||||
|
|
||||||
describe "reject" do
|
describe "reject" do
|
||||||
test "rejects the message if the recipient count is above reject_threshold", %{
|
test "rejects the message if the recipient count is above reject_threshold", %{
|
||||||
message: message
|
message: message
|
||||||
|
|
|
@ -7,6 +7,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
|
||||||
|
|
||||||
alias Pleroma.Web.ActivityPub.MRF.KeywordPolicy
|
alias Pleroma.Web.ActivityPub.MRF.KeywordPolicy
|
||||||
|
|
||||||
|
clear_config(:mrf_keyword)
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []})
|
Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []})
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
|
||||||
|
|
||||||
alias Pleroma.Web.ActivityPub.MRF.MentionPolicy
|
alias Pleroma.Web.ActivityPub.MRF.MentionPolicy
|
||||||
|
|
||||||
|
clear_config(:mrf_mention)
|
||||||
|
|
||||||
test "pass filter if allow list is empty" do
|
test "pass filter if allow list is empty" do
|
||||||
Pleroma.Config.delete([:mrf_mention])
|
Pleroma.Config.delete([:mrf_mention])
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicyTest do
|
||||||
"object" => %{"content" => "hi"}
|
"object" => %{"content" => "hi"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear_config([:mrf_subchain, :match_actor])
|
||||||
|
|
||||||
test "it matches and processes subchains when the actor matches a configured target" do
|
test "it matches and processes subchains when the actor matches a configured target" do
|
||||||
Pleroma.Config.put([:mrf_subchain, :match_actor], %{
|
Pleroma.Config.put([:mrf_subchain, :match_actor], %{
|
||||||
~r/^https:\/\/banned.com/s => [DropPolicy]
|
~r/^https:\/\/banned.com/s => [DropPolicy]
|
||||||
|
|
|
@ -19,6 +19,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "handle_incoming" do
|
describe "handle_incoming" do
|
||||||
|
clear_config([:user, :deny_follow_blocked])
|
||||||
|
|
||||||
test "it works for osada follow request" do
|
test "it works for osada follow request" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
|
@ -1893,9 +1893,7 @@ test "returns error when status is not exist", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "when configuration from database is off", %{conn: conn} do
|
test "when configuration from database is off", %{conn: conn} do
|
||||||
initial = Config.get(:configurable_from_database)
|
|
||||||
Config.put(:configurable_from_database, false)
|
Config.put(:configurable_from_database, false)
|
||||||
on_exit(fn -> Config.put(:configurable_from_database, initial) end)
|
|
||||||
conn = get(conn, "/api/pleroma/admin/config")
|
conn = get(conn, "/api/pleroma/admin/config")
|
||||||
|
|
||||||
assert json_response(conn, 400) ==
|
assert json_response(conn, 400) ==
|
||||||
|
|
|
@ -68,6 +68,7 @@ test "with the safe_dm_mention option set, it does not mention people beyond the
|
||||||
har = insert(:user)
|
har = insert(:user)
|
||||||
jafnhar = insert(:user)
|
jafnhar = insert(:user)
|
||||||
tridi = insert(:user)
|
tridi = insert(:user)
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :safe_dm_mentions], true)
|
Pleroma.Config.put([:instance, :safe_dm_mentions], true)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
|
|
@ -15,6 +15,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
describe "account fetching" do
|
describe "account fetching" do
|
||||||
|
clear_config([:instance, :limit_to_local_content])
|
||||||
|
|
||||||
test "works by id" do
|
test "works by id" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
@ -44,7 +46,6 @@ test "works by nickname" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "works by nickname for remote users" do
|
test "works by nickname for remote users" do
|
||||||
limit_to_local = Pleroma.Config.get([:instance, :limit_to_local_content])
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], false)
|
Pleroma.Config.put([:instance, :limit_to_local_content], false)
|
||||||
user = insert(:user, nickname: "user@example.com", local: false)
|
user = insert(:user, nickname: "user@example.com", local: false)
|
||||||
|
|
||||||
|
@ -52,13 +53,11 @@ test "works by nickname for remote users" do
|
||||||
build_conn()
|
build_conn()
|
||||||
|> get("/api/v1/accounts/#{user.nickname}")
|
|> get("/api/v1/accounts/#{user.nickname}")
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)
|
|
||||||
assert %{"id" => id} = json_response(conn, 200)
|
assert %{"id" => id} = json_response(conn, 200)
|
||||||
assert id == user.id
|
assert id == user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "respects limit_to_local_content == :all for remote user nicknames" do
|
test "respects limit_to_local_content == :all for remote user nicknames" do
|
||||||
limit_to_local = Pleroma.Config.get([:instance, :limit_to_local_content])
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
|
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
|
||||||
|
|
||||||
user = insert(:user, nickname: "user@example.com", local: false)
|
user = insert(:user, nickname: "user@example.com", local: false)
|
||||||
|
@ -67,12 +66,10 @@ test "respects limit_to_local_content == :all for remote user nicknames" do
|
||||||
build_conn()
|
build_conn()
|
||||||
|> get("/api/v1/accounts/#{user.nickname}")
|
|> get("/api/v1/accounts/#{user.nickname}")
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)
|
|
||||||
assert json_response(conn, 404)
|
assert json_response(conn, 404)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "respects limit_to_local_content == :unauthenticated for remote user nicknames" do
|
test "respects limit_to_local_content == :unauthenticated for remote user nicknames" do
|
||||||
limit_to_local = Pleroma.Config.get([:instance, :limit_to_local_content])
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
|
||||||
|
|
||||||
user = insert(:user, nickname: "user@example.com", local: false)
|
user = insert(:user, nickname: "user@example.com", local: false)
|
||||||
|
@ -90,7 +87,6 @@ test "respects limit_to_local_content == :unauthenticated for remote user nickna
|
||||||
|> assign(:token, insert(:oauth_token, user: reading_user, scopes: ["read:accounts"]))
|
|> assign(:token, insert(:oauth_token, user: reading_user, scopes: ["read:accounts"]))
|
||||||
|> get("/api/v1/accounts/#{user.nickname}")
|
|> get("/api/v1/accounts/#{user.nickname}")
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)
|
|
||||||
assert %{"id" => id} = json_response(conn, 200)
|
assert %{"id" => id} = json_response(conn, 200)
|
||||||
assert id == user.id
|
assert id == user.id
|
||||||
end
|
end
|
||||||
|
@ -677,6 +673,8 @@ test "returns error when user already registred", %{conn: conn, valid_params: va
|
||||||
assert json_response(res, 400) == %{"error" => "{\"email\":[\"has already been taken\"]}"}
|
assert json_response(res, 400) == %{"error" => "{\"email\":[\"has already been taken\"]}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clear_config([Pleroma.Plugs.RemoteIp, :enabled])
|
||||||
|
|
||||||
test "rate limit", %{conn: conn} do
|
test "rate limit", %{conn: conn} do
|
||||||
Pleroma.Config.put([Pleroma.Plugs.RemoteIp, :enabled], true)
|
Pleroma.Config.put([Pleroma.Plugs.RemoteIp, :enabled], true)
|
||||||
app_token = insert(:oauth_token, user: nil)
|
app_token = insert(:oauth_token, user: nil)
|
||||||
|
|
|
@ -21,6 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
|
|
||||||
clear_config([:instance, :federating])
|
clear_config([:instance, :federating])
|
||||||
clear_config([:instance, :allow_relay])
|
clear_config([:instance, :allow_relay])
|
||||||
|
clear_config([:rich_media, :enabled])
|
||||||
|
|
||||||
describe "posting statuses" do
|
describe "posting statuses" do
|
||||||
setup do: oauth_access(["write:statuses"])
|
setup do: oauth_access(["write:statuses"])
|
||||||
|
|
|
@ -7,11 +7,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
||||||
import Mock
|
import Mock
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
|
||||||
setup do
|
clear_config(:media_proxy)
|
||||||
media_proxy_config = Config.get([:media_proxy]) || []
|
clear_config([Pleroma.Web.Endpoint, :secret_key_base])
|
||||||
on_exit(fn -> Config.put([:media_proxy], media_proxy_config) end)
|
|
||||||
:ok
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it returns 404 when MediaProxy disabled", %{conn: conn} do
|
test "it returns 404 when MediaProxy disabled", %{conn: conn} do
|
||||||
Config.put([:media_proxy, :enabled], false)
|
Config.put([:media_proxy, :enabled], false)
|
||||||
|
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.MediaProxyTest do
|
||||||
alias Pleroma.Web.MediaProxy.MediaProxyController
|
alias Pleroma.Web.MediaProxy.MediaProxyController
|
||||||
|
|
||||||
clear_config([:media_proxy, :enabled])
|
clear_config([:media_proxy, :enabled])
|
||||||
|
clear_config(Pleroma.Upload)
|
||||||
|
|
||||||
describe "when enabled" do
|
describe "when enabled" do
|
||||||
setup do
|
setup do
|
||||||
|
@ -224,7 +225,6 @@ test "does not change whitelisted urls" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "ensure Pleroma.Upload base_url is always whitelisted" do
|
test "ensure Pleroma.Upload base_url is always whitelisted" do
|
||||||
upload_config = Pleroma.Config.get([Pleroma.Upload])
|
|
||||||
media_url = "https://media.pleroma.social"
|
media_url = "https://media.pleroma.social"
|
||||||
Pleroma.Config.put([Pleroma.Upload, :base_url], media_url)
|
Pleroma.Config.put([Pleroma.Upload, :base_url], media_url)
|
||||||
|
|
||||||
|
@ -232,8 +232,6 @@ test "ensure Pleroma.Upload base_url is always whitelisted" do
|
||||||
encoded = url(url)
|
encoded = url(url)
|
||||||
|
|
||||||
assert String.starts_with?(encoded, media_url)
|
assert String.starts_with?(encoded, media_url)
|
||||||
|
|
||||||
Pleroma.Config.put([Pleroma.Upload], upload_config)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,8 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
alias Pleroma.Web.Metadata.Providers.OpenGraph
|
alias Pleroma.Web.Metadata.Providers.OpenGraph
|
||||||
|
|
||||||
|
clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
|
||||||
|
|
||||||
test "it renders all supported types of attachments and skips unknown types" do
|
test "it renders all supported types of attachments and skips unknown types" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
|
||||||
alias Pleroma.Web.Metadata.Utils
|
alias Pleroma.Web.Metadata.Utils
|
||||||
alias Pleroma.Web.Router
|
alias Pleroma.Web.Router
|
||||||
|
|
||||||
|
clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
|
||||||
|
|
||||||
test "it renders twitter card for user info" do
|
test "it renders twitter card for user info" do
|
||||||
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
|
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
|
||||||
avatar_url = Utils.attachment_url(User.avatar_url(user))
|
avatar_url = Utils.attachment_url(User.avatar_url(user))
|
||||||
|
|
|
@ -6,7 +6,9 @@ defmodule Pleroma.Web.NodeInfoTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
clear_config([:mrf_simple])
|
clear_config([:mrf_simple])
|
||||||
|
clear_config(:instance)
|
||||||
|
|
||||||
test "GET /.well-known/nodeinfo", %{conn: conn} do
|
test "GET /.well-known/nodeinfo", %{conn: conn} do
|
||||||
links =
|
links =
|
||||||
|
@ -63,11 +65,6 @@ test "returns software.repository field in nodeinfo 2.1", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns fieldsLimits field", %{conn: conn} do
|
test "returns fieldsLimits field", %{conn: conn} do
|
||||||
max_account_fields = Pleroma.Config.get([:instance, :max_account_fields])
|
|
||||||
max_remote_account_fields = Pleroma.Config.get([:instance, :max_remote_account_fields])
|
|
||||||
account_field_name_length = Pleroma.Config.get([:instance, :account_field_name_length])
|
|
||||||
account_field_value_length = Pleroma.Config.get([:instance, :account_field_value_length])
|
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :max_account_fields], 10)
|
Pleroma.Config.put([:instance, :max_account_fields], 10)
|
||||||
Pleroma.Config.put([:instance, :max_remote_account_fields], 15)
|
Pleroma.Config.put([:instance, :max_remote_account_fields], 15)
|
||||||
Pleroma.Config.put([:instance, :account_field_name_length], 255)
|
Pleroma.Config.put([:instance, :account_field_name_length], 255)
|
||||||
|
@ -82,11 +79,6 @@ test "returns fieldsLimits field", %{conn: conn} do
|
||||||
assert response["metadata"]["fieldsLimits"]["maxRemoteFields"] == 15
|
assert response["metadata"]["fieldsLimits"]["maxRemoteFields"] == 15
|
||||||
assert response["metadata"]["fieldsLimits"]["nameLength"] == 255
|
assert response["metadata"]["fieldsLimits"]["nameLength"] == 255
|
||||||
assert response["metadata"]["fieldsLimits"]["valueLength"] == 2048
|
assert response["metadata"]["fieldsLimits"]["valueLength"] == 2048
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :max_account_fields], max_account_fields)
|
|
||||||
Pleroma.Config.put([:instance, :max_remote_account_fields], max_remote_account_fields)
|
|
||||||
Pleroma.Config.put([:instance, :account_field_name_length], account_field_name_length)
|
|
||||||
Pleroma.Config.put([:instance, :account_field_value_length], account_field_value_length)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do
|
test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do
|
||||||
|
@ -112,9 +104,10 @@ test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do
|
||||||
Pleroma.Config.put([:instance, :safe_dm_mentions], option)
|
Pleroma.Config.put([:instance, :safe_dm_mentions], option)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it shows if federation is enabled/disabled", %{conn: conn} do
|
describe "`metadata/federation/enabled`" do
|
||||||
original = Pleroma.Config.get([:instance, :federating])
|
clear_config([:instance, :federating])
|
||||||
|
|
||||||
|
test "it shows if federation is enabled/disabled", %{conn: conn} do
|
||||||
Pleroma.Config.put([:instance, :federating], true)
|
Pleroma.Config.put([:instance, :federating], true)
|
||||||
|
|
||||||
response =
|
response =
|
||||||
|
@ -132,8 +125,7 @@ test "it shows if federation is enabled/disabled", %{conn: conn} do
|
||||||
|> json_response(:ok)
|
|> json_response(:ok)
|
||||||
|
|
||||||
assert response["metadata"]["federation"]["enabled"] == false
|
assert response["metadata"]["federation"]["enabled"] == false
|
||||||
|
end
|
||||||
Pleroma.Config.put([:instance, :federating], original)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it shows MRF transparency data if enabled", %{conn: conn} do
|
test "it shows MRF transparency data if enabled", %{conn: conn} do
|
||||||
|
|
|
@ -17,7 +17,8 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
||||||
key: "_test",
|
key: "_test",
|
||||||
signing_salt: "cooldude"
|
signing_salt: "cooldude"
|
||||||
]
|
]
|
||||||
clear_config_all([:instance, :account_activation_required])
|
|
||||||
|
clear_config([:instance, :account_activation_required])
|
||||||
|
|
||||||
describe "in OAuth consumer mode, " do
|
describe "in OAuth consumer mode, " do
|
||||||
setup do
|
setup do
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.FederatingPlugTest do
|
defmodule Pleroma.Web.FederatingPlugTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
clear_config_all([:instance, :federating])
|
|
||||||
|
clear_config([:instance, :federating])
|
||||||
|
|
||||||
test "returns and halt the conn when federating is disabled" do
|
test "returns and halt the conn when federating is disabled" do
|
||||||
Pleroma.Config.put([:instance, :federating], false)
|
Pleroma.Config.put([:instance, :federating], false)
|
||||||
|
|
|
@ -20,7 +20,7 @@ defmodule Pleroma.Web.StreamerTest do
|
||||||
@streamer_timeout 150
|
@streamer_timeout 150
|
||||||
@streamer_start_wait 10
|
@streamer_start_wait 10
|
||||||
|
|
||||||
clear_config_all([:instance, :skip_thread_containment])
|
clear_config([:instance, :skip_thread_containment])
|
||||||
|
|
||||||
describe "user streams" do
|
describe "user streams" do
|
||||||
setup do
|
setup do
|
||||||
|
|
|
@ -117,15 +117,8 @@ test "it registers a new user and parses mentions in the bio" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "register with one time token" do
|
describe "register with one time token" do
|
||||||
setup do
|
clear_config([:instance, :registrations_open]) do
|
||||||
setting = Pleroma.Config.get([:instance, :registrations_open])
|
|
||||||
|
|
||||||
if setting do
|
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||||
on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
|
|
||||||
end
|
|
||||||
|
|
||||||
:ok
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns user on success" do
|
test "returns user on success" do
|
||||||
|
@ -191,14 +184,11 @@ test "returns error on expired token" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "registers with date limited token" do
|
describe "registers with date limited token" do
|
||||||
setup do
|
clear_config([:instance, :registrations_open]) do
|
||||||
setting = Pleroma.Config.get([:instance, :registrations_open])
|
|
||||||
|
|
||||||
if setting do
|
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||||
on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
setup do
|
||||||
data = %{
|
data = %{
|
||||||
"nickname" => "vinny",
|
"nickname" => "vinny",
|
||||||
"email" => "pasta@pizza.vs",
|
"email" => "pasta@pizza.vs",
|
||||||
|
@ -256,15 +246,8 @@ test "returns an error on overdue date", %{data: data} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "registers with reusable token" do
|
describe "registers with reusable token" do
|
||||||
setup do
|
clear_config([:instance, :registrations_open]) do
|
||||||
setting = Pleroma.Config.get([:instance, :registrations_open])
|
|
||||||
|
|
||||||
if setting do
|
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||||
on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
|
|
||||||
end
|
|
||||||
|
|
||||||
:ok
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns user on success, after him registration fails" do
|
test "returns user on success, after him registration fails" do
|
||||||
|
@ -309,15 +292,8 @@ test "returns user on success, after him registration fails" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "registers with reusable date limited token" do
|
describe "registers with reusable date limited token" do
|
||||||
setup do
|
clear_config([:instance, :registrations_open]) do
|
||||||
setting = Pleroma.Config.get([:instance, :registrations_open])
|
|
||||||
|
|
||||||
if setting do
|
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
Pleroma.Config.put([:instance, :registrations_open], false)
|
||||||
on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
|
|
||||||
end
|
|
||||||
|
|
||||||
:ok
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns user on success" do
|
test "returns user on success" do
|
||||||
|
|
|
@ -19,7 +19,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||||
|
|
||||||
clear_config([:instance])
|
clear_config([:instance])
|
||||||
clear_config([:frontend_configurations, :pleroma_fe])
|
clear_config([:frontend_configurations, :pleroma_fe])
|
||||||
clear_config([:user, :deny_follow_blocked])
|
|
||||||
|
|
||||||
describe "POST /api/pleroma/follow_import" do
|
describe "POST /api/pleroma/follow_import" do
|
||||||
setup do: oauth_access(["follow"])
|
setup do: oauth_access(["follow"])
|
||||||
|
|
Loading…
Reference in a new issue