forked from AkkomaGang/akkoma
Improved in-test config management functions.
This commit is contained in:
parent
69341cbcba
commit
ec3719f539
32 changed files with 89 additions and 155 deletions
|
@ -10,9 +10,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
||||||
alias Pleroma.Config.TransferTask
|
alias Pleroma.Config.TransferTask
|
||||||
alias Pleroma.ConfigDB
|
alias Pleroma.ConfigDB
|
||||||
|
|
||||||
clear_config(:configurable_from_database) do
|
clear_config(:configurable_from_database, true)
|
||||||
Pleroma.Config.put(:configurable_from_database, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "transfer config values from db to env" do
|
test "transfer config values from db to env" do
|
||||||
refute Application.get_env(:pleroma, :test_key)
|
refute Application.get_env(:pleroma, :test_key)
|
||||||
|
|
|
@ -11,9 +11,7 @@ defmodule Pleroma.ConversationTest do
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
clear_config_all([:instance, :federating]) do
|
clear_config_all([:instance, :federating], true)
|
||||||
Pleroma.Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it goes through old direct conversations" do
|
test "it goes through old direct conversations" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
|
@ -12,9 +12,7 @@ defmodule Pleroma.Web.RuntimeStaticPlugTest do
|
||||||
on_exit(fn -> File.rm_rf(@dir) end)
|
on_exit(fn -> File.rm_rf(@dir) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config([:instance, :static_dir]) do
|
clear_config([:instance, :static_dir], @dir)
|
||||||
Pleroma.Config.put([:instance, :static_dir], @dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "overrides index" do
|
test "overrides index" do
|
||||||
bundled_index = get(build_conn(), "/")
|
bundled_index = get(build_conn(), "/")
|
||||||
|
|
|
@ -9,9 +9,7 @@ defmodule Pleroma.Plugs.UserIsAdminPlugTest do
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
|
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||||
Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "accepts a user that is an admin" do
|
test "accepts a user that is an admin" do
|
||||||
user = insert(:user, is_admin: true)
|
user = insert(:user, is_admin: true)
|
||||||
|
@ -42,9 +40,7 @@ test "denies when a user isn't set" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
|
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
clear_config([:auth, :enforce_oauth_admin_scope_usage], true)
|
||||||
Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
admin_user = insert(:user, is_admin: true)
|
admin_user = insert(:user, is_admin: true)
|
||||||
|
|
|
@ -26,6 +26,25 @@ defmacro clear_config(config_path, do: yield) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defmacro clear_config(config_path, temp_setting) do
|
||||||
|
quote do
|
||||||
|
clear_config(unquote(config_path)) do
|
||||||
|
Config.put(unquote(config_path), unquote(temp_setting))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
From _within a test case_, sets config to provided value and restores initial value on exit.
|
||||||
|
For multi-case setup use `clear_config/2` instead.
|
||||||
|
"""
|
||||||
|
def set_config(config_path, temp_setting) do
|
||||||
|
initial_setting = Config.get(config_path)
|
||||||
|
Config.put(config_path, temp_setting)
|
||||||
|
|
||||||
|
ExUnit.Callbacks.on_exit(fn -> Config.put(config_path, initial_setting) end)
|
||||||
|
end
|
||||||
|
|
||||||
@doc "Stores initial config value and restores it after *all* test examples are executed."
|
@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
|
||||||
|
@ -50,6 +69,14 @@ defmacro clear_config_all(config_path, do: yield) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defmacro clear_config_all(config_path, temp_setting) do
|
||||||
|
quote do
|
||||||
|
clear_config_all(unquote(config_path)) do
|
||||||
|
Config.put(unquote(config_path), unquote(temp_setting))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defmacro __using__(_opts) do
|
defmacro __using__(_opts) do
|
||||||
quote do
|
quote do
|
||||||
import Pleroma.Tests.Helpers,
|
import Pleroma.Tests.Helpers,
|
||||||
|
@ -57,7 +84,8 @@ defmacro __using__(_opts) do
|
||||||
clear_config: 1,
|
clear_config: 1,
|
||||||
clear_config: 2,
|
clear_config: 2,
|
||||||
clear_config_all: 1,
|
clear_config_all: 1,
|
||||||
clear_config_all: 2
|
clear_config_all: 2,
|
||||||
|
set_config: 2
|
||||||
]
|
]
|
||||||
|
|
||||||
def to_datetime(naive_datetime) do
|
def to_datetime(naive_datetime) do
|
||||||
|
|
|
@ -20,9 +20,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config_all(:configurable_from_database) do
|
clear_config_all(:configurable_from_database, true)
|
||||||
Pleroma.Config.put(:configurable_from_database, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "error if file with custom settings doesn't exist" do
|
test "error if file with custom settings doesn't exist" do
|
||||||
Mix.Tasks.Pleroma.Config.migrate_to_db("config/not_existance_config_file.exs")
|
Mix.Tasks.Pleroma.Config.migrate_to_db("config/not_existance_config_file.exs")
|
||||||
|
|
|
@ -250,9 +250,7 @@ test "escapes reserved uri characters" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Setting a custom base_url for uploaded media" do
|
describe "Setting a custom base_url for uploaded media" do
|
||||||
clear_config([Pleroma.Upload, :base_url]) do
|
clear_config([Pleroma.Upload, :base_url], "https://cache.pleroma.social")
|
||||||
Pleroma.Config.put([Pleroma.Upload, :base_url], "https://cache.pleroma.social")
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns a media url with configured base_url" do
|
test "returns a media url with configured base_url" do
|
||||||
base_url = Pleroma.Config.get([Pleroma.Upload, :base_url])
|
base_url = Pleroma.Config.get([Pleroma.Upload, :base_url])
|
||||||
|
|
|
@ -11,12 +11,10 @@ defmodule Pleroma.Uploaders.S3Test do
|
||||||
import Mock
|
import Mock
|
||||||
import ExUnit.CaptureLog
|
import ExUnit.CaptureLog
|
||||||
|
|
||||||
clear_config([Pleroma.Uploaders.S3]) do
|
clear_config(Pleroma.Uploaders.S3,
|
||||||
Config.put([Pleroma.Uploaders.S3],
|
|
||||||
bucket: "test_bucket",
|
bucket: "test_bucket",
|
||||||
public_endpoint: "https://s3.amazonaws.com"
|
public_endpoint: "https://s3.amazonaws.com"
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
describe "get_file/1" do
|
describe "get_file/1" do
|
||||||
test "it returns path to local folder for files" do
|
test "it returns path to local folder for files" do
|
||||||
|
|
|
@ -476,9 +476,7 @@ test "it sets the password_hash and ap_id" do
|
||||||
email: "email@example.com"
|
email: "email@example.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_config([:instance, :account_activation_required]) do
|
clear_config([:instance, :account_activation_required], true)
|
||||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it creates unconfirmed user" do
|
test "it creates unconfirmed user" do
|
||||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||||
|
|
|
@ -26,9 +26,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config([:instance, :federating]) do
|
clear_config([:instance, :federating], true)
|
||||||
Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "/relay" do
|
describe "/relay" do
|
||||||
clear_config([:instance, :allow_relay])
|
clear_config([:instance, :allow_relay])
|
||||||
|
|
|
@ -9,12 +9,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
|
||||||
alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy
|
alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy
|
||||||
alias Pleroma.Web.ActivityPub.Visibility
|
alias Pleroma.Web.ActivityPub.Visibility
|
||||||
|
|
||||||
clear_config([:mrf_object_age]) do
|
clear_config(:mrf_object_age,
|
||||||
Config.put(:mrf_object_age,
|
|
||||||
threshold: 172_800,
|
threshold: 172_800,
|
||||||
actions: [:delist, :strip_followers]
|
actions: [:delist, :strip_followers]
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
|
@ -8,8 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
|
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
|
||||||
|
|
||||||
clear_config([:mrf_simple]) do
|
clear_config(:mrf_simple,
|
||||||
Config.put(:mrf_simple,
|
|
||||||
media_removal: [],
|
media_removal: [],
|
||||||
media_nsfw: [],
|
media_nsfw: [],
|
||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
|
@ -19,7 +18,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
||||||
avatar_removal: [],
|
avatar_removal: [],
|
||||||
banner_removal: []
|
banner_removal: []
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
describe "when :media_removal" do
|
describe "when :media_removal" do
|
||||||
test "is empty" do
|
test "is empty" do
|
||||||
|
|
|
@ -23,9 +23,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config_all([:instance, :federating]) do
|
clear_config_all([:instance, :federating], true)
|
||||||
Pleroma.Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "gather_webfinger_links/1" do
|
describe "gather_webfinger_links/1" do
|
||||||
test "it returns links" do
|
test "it returns links" do
|
||||||
|
|
|
@ -1351,9 +1351,7 @@ test "it accepts Move activities" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "`handle_incoming/2`, Mastodon format `replies` handling" do
|
describe "`handle_incoming/2`, Mastodon format `replies` handling" do
|
||||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
clear_config([:activitypub, :note_replies_output_limit], 5)
|
||||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
|
||||||
end
|
|
||||||
|
|
||||||
clear_config([:instance, :federation_incoming_replies_max_depth])
|
clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||||
|
|
||||||
|
@ -1394,9 +1392,7 @@ test "does NOT schedule background fetching of `replies` beyond max thread depth
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "`handle_incoming/2`, Pleroma format `replies` handling" do
|
describe "`handle_incoming/2`, Pleroma format `replies` handling" do
|
||||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
clear_config([:activitypub, :note_replies_output_limit], 5)
|
||||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
|
||||||
end
|
|
||||||
|
|
||||||
clear_config([:instance, :federation_incoming_replies_max_depth])
|
clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||||
|
|
||||||
|
@ -2145,9 +2141,7 @@ test "returns object with emoji when object contains map tag" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "set_replies/1" do
|
describe "set_replies/1" do
|
||||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
clear_config([:activitypub, :note_replies_output_limit], 2)
|
||||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns unmodified object if activity doesn't have self-replies" do
|
test "returns unmodified object if activity doesn't have self-replies" do
|
||||||
data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json"))
|
data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json"))
|
||||||
|
|
|
@ -37,9 +37,7 @@ test "renders a note activity" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "note activity's `replies` collection rendering" do
|
describe "note activity's `replies` collection rendering" do
|
||||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
clear_config([:activitypub, :note_replies_output_limit], 5)
|
||||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "renders `replies` collection for a note activity" do
|
test "renders `replies` collection for a note activity" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
|
@ -43,9 +43,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
|
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
clear_config([:auth, :enforce_oauth_admin_scope_usage], true)
|
||||||
Config.put([:auth, :enforce_oauth_admin_scope_usage], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
||||||
%{admin: admin} do
|
%{admin: admin} do
|
||||||
|
@ -93,9 +91,7 @@ test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or bro
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
|
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
|
||||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||||
Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /api/pleroma/admin/users/:nickname requires " <>
|
test "GET /api/pleroma/admin/users/:nickname requires " <>
|
||||||
"read:accounts or admin:read:accounts or broader scope",
|
"read:accounts or admin:read:accounts or broader scope",
|
||||||
|
@ -581,13 +577,8 @@ test "/:right DELETE, can remove from a permission group (multiple)", %{
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /api/pleroma/admin/email_invite, with valid config" do
|
describe "POST /api/pleroma/admin/email_invite, with valid config" do
|
||||||
clear_config([:instance, :registrations_open]) do
|
clear_config([:instance, :registrations_open], false)
|
||||||
Config.put([:instance, :registrations_open], false)
|
clear_config([:instance, :invites_enabled], true)
|
||||||
end
|
|
||||||
|
|
||||||
clear_config([:instance, :invites_enabled]) do
|
|
||||||
Config.put([:instance, :invites_enabled], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "sends invitation and returns 204", %{admin: admin, conn: conn} do
|
test "sends invitation and returns 204", %{admin: admin, conn: conn} do
|
||||||
recipient_email = "foo@bar.com"
|
recipient_email = "foo@bar.com"
|
||||||
|
@ -1888,9 +1879,7 @@ test "returns 404 when the status does not exist", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/pleroma/admin/config" do
|
describe "GET /api/pleroma/admin/config" do
|
||||||
clear_config(:configurable_from_database) do
|
clear_config(:configurable_from_database, true)
|
||||||
Config.put(:configurable_from_database, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "when configuration from database is off", %{conn: conn} do
|
test "when configuration from database is off", %{conn: conn} do
|
||||||
Config.put(:configurable_from_database, false)
|
Config.put(:configurable_from_database, false)
|
||||||
|
@ -2041,9 +2030,7 @@ test "POST /api/pleroma/admin/config error", %{conn: conn} do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config(:configurable_from_database) do
|
clear_config(:configurable_from_database, true)
|
||||||
Config.put(:configurable_from_database, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
@tag capture_log: true
|
@tag capture_log: true
|
||||||
test "create new config setting in db", %{conn: conn} do
|
test "create new config setting in db", %{conn: conn} do
|
||||||
|
@ -3052,9 +3039,7 @@ test "proxy tuple ip", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/pleroma/admin/restart" do
|
describe "GET /api/pleroma/admin/restart" do
|
||||||
clear_config(:configurable_from_database) do
|
clear_config(:configurable_from_database, true)
|
||||||
Config.put(:configurable_from_database, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "pleroma restarts", %{conn: conn} do
|
test "pleroma restarts", %{conn: conn} do
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
|
|
|
@ -21,9 +21,7 @@ defmodule Pleroma.Web.FederatorTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config_all([:instance, :federating]) do
|
clear_config_all([:instance, :federating], true)
|
||||||
Pleroma.Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
clear_config([:instance, :allow_relay])
|
clear_config([:instance, :allow_relay])
|
||||||
clear_config([:instance, :rewrite_policy])
|
clear_config([:instance, :rewrite_policy])
|
||||||
|
|
|
@ -12,9 +12,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
clear_config([:instance, :federating]) do
|
clear_config([:instance, :federating], true)
|
||||||
Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "feed" do
|
describe "feed" do
|
||||||
clear_config([:feed])
|
clear_config([:feed])
|
||||||
|
|
|
@ -10,9 +10,7 @@ defmodule Pleroma.Instances.InstanceTest do
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
clear_config_all([:instance, :federation_reachability_timeout_days]) do
|
clear_config_all([:instance, :federation_reachability_timeout_days], 1)
|
||||||
Pleroma.Config.put([:instance, :federation_reachability_timeout_days], 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "set_reachable/1" do
|
describe "set_reachable/1" do
|
||||||
test "clears `unreachable_since` of existing matching Instance record having non-nil `unreachable_since`" 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
|
use Pleroma.DataCase
|
||||||
|
|
||||||
clear_config_all([:instance, :federation_reachability_timeout_days]) do
|
clear_config_all([:instance, :federation_reachability_timeout_days], 1)
|
||||||
Pleroma.Config.put([:instance, :federation_reachability_timeout_days], 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "reachable?/1" do
|
describe "reachable?/1" do
|
||||||
test "returns `true` for host / url with unknown reachability status" do
|
test "returns `true` for host / url with unknown reachability status" do
|
||||||
|
|
|
@ -756,9 +756,7 @@ test "returns forbidden if token is invalid", %{conn: conn, valid_params: valid_
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "create account by app / rate limit" do
|
describe "create account by app / rate limit" do
|
||||||
clear_config([:rate_limit, :app_account_creation]) do
|
clear_config([:rate_limit, :app_account_creation], {10_000, 2})
|
||||||
Pleroma.Config.put([:rate_limit, :app_account_creation], {10_000, 2})
|
|
||||||
end
|
|
||||||
|
|
||||||
test "respects rate limit setting", %{conn: conn} do
|
test "respects rate limit setting", %{conn: conn} do
|
||||||
app_token = insert(:oauth_token, user: nil)
|
app_token = insert(:oauth_token, user: nil)
|
||||||
|
|
|
@ -739,9 +739,7 @@ test "returns 404 error for a wrong id", %{conn: conn} do
|
||||||
%{activity: activity}
|
%{activity: activity}
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config([:instance, :max_pinned_statuses]) do
|
clear_config([:instance, :max_pinned_statuses], 1)
|
||||||
Config.put([:instance, :max_pinned_statuses], 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "pin status", %{conn: conn, user: user, activity: activity} do
|
test "pin status", %{conn: conn, user: user, activity: activity} do
|
||||||
id_str = to_string(activity.id)
|
id_str = to_string(activity.id)
|
||||||
|
|
|
@ -12,13 +12,9 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
|
||||||
|
|
||||||
@skip if !Code.ensure_loaded?(:eldap), do: :skip
|
@skip if !Code.ensure_loaded?(:eldap), do: :skip
|
||||||
|
|
||||||
clear_config_all([:ldap, :enabled]) do
|
clear_config_all([:ldap, :enabled], true)
|
||||||
Pleroma.Config.put([:ldap, :enabled], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
clear_config_all(Pleroma.Web.Auth.Authenticator) do
|
clear_config_all(Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.LDAPAuthenticator)
|
||||||
Pleroma.Config.put(Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.LDAPAuthenticator)
|
|
||||||
end
|
|
||||||
|
|
||||||
@tag @skip
|
@tag @skip
|
||||||
test "authorizes the existing user using LDAP credentials" do
|
test "authorizes the existing user using LDAP credentials" do
|
||||||
|
|
|
@ -31,12 +31,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config([:auth, :oauth_consumer_strategies]) do
|
clear_config([:auth, :oauth_consumer_strategies], ~w(twitter facebook))
|
||||||
Pleroma.Config.put(
|
|
||||||
[:auth, :oauth_consumer_strategies],
|
|
||||||
~w(twitter facebook)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{
|
test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{
|
||||||
app: app,
|
app: app,
|
||||||
|
|
|
@ -17,9 +17,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config([:instance, :federating]) do
|
clear_config([:instance, :federating], true)
|
||||||
Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Note: see ActivityPubControllerTest for JSON format tests
|
# Note: see ActivityPubControllerTest for JSON format tests
|
||||||
describe "GET /objects/:uuid (text/html)" do
|
describe "GET /objects/:uuid (text/html)" do
|
||||||
|
|
|
@ -27,9 +27,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
||||||
[user: user]
|
[user: user]
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config([:instance, :account_activation_required]) do
|
clear_config([:instance, :account_activation_required], true)
|
||||||
Config.put([:instance, :account_activation_required], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "resend account confirmation email", %{conn: conn, user: user} do
|
test "resend account confirmation email", %{conn: conn, user: user} do
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -13,9 +13,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
||||||
"emoji"
|
"emoji"
|
||||||
)
|
)
|
||||||
|
|
||||||
clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
|
clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
|
||||||
Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "shared & non-shared pack information in list_packs is ok" do
|
test "shared & non-shared pack information in list_packs is ok" do
|
||||||
conn = build_conn()
|
conn = build_conn()
|
||||||
|
|
|
@ -8,13 +8,9 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
clear_config_all([:static_fe, :enabled]) do
|
clear_config_all([:static_fe, :enabled], true)
|
||||||
Config.put([:static_fe, :enabled], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
clear_config([:instance, :federating]) do
|
clear_config([:instance, :federating], true)
|
||||||
Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
conn = put_req_header(conn, "accept", "text/html")
|
conn = put_req_header(conn, "accept", "text/html")
|
||||||
|
|
|
@ -17,9 +17,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config_all([:instance, :federating]) do
|
clear_config_all([:instance, :federating], true)
|
||||||
Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
clear_config([:instance])
|
clear_config([:instance])
|
||||||
clear_config([:frontend_configurations, :pleroma_fe])
|
clear_config([:frontend_configurations, :pleroma_fe])
|
||||||
|
|
|
@ -117,9 +117,7 @@ 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
|
||||||
clear_config([:instance, :registrations_open]) do
|
clear_config([:instance, :registrations_open], false)
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns user on success" do
|
test "returns user on success" do
|
||||||
{:ok, invite} = UserInviteToken.create_invite()
|
{:ok, invite} = UserInviteToken.create_invite()
|
||||||
|
@ -184,9 +182,7 @@ test "returns error on expired token" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "registers with date limited token" do
|
describe "registers with date limited token" do
|
||||||
clear_config([:instance, :registrations_open]) do
|
clear_config([:instance, :registrations_open], false)
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
data = %{
|
data = %{
|
||||||
|
@ -246,9 +242,7 @@ test "returns an error on overdue date", %{data: data} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "registers with reusable token" do
|
describe "registers with reusable token" do
|
||||||
clear_config([:instance, :registrations_open]) do
|
clear_config([:instance, :registrations_open], false)
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns user on success, after him registration fails" do
|
test "returns user on success, after him registration fails" do
|
||||||
{:ok, invite} = UserInviteToken.create_invite(%{max_use: 100})
|
{:ok, invite} = UserInviteToken.create_invite(%{max_use: 100})
|
||||||
|
@ -292,9 +286,7 @@ 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
|
||||||
clear_config([:instance, :registrations_open]) do
|
clear_config([:instance, :registrations_open], false)
|
||||||
Pleroma.Config.put([:instance, :registrations_open], false)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns user on success" do
|
test "returns user on success" do
|
||||||
{:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100})
|
{:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100})
|
||||||
|
|
|
@ -427,9 +427,7 @@ test "it returns version in json format", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /main/ostatus - remote_subscribe/2" do
|
describe "POST /main/ostatus - remote_subscribe/2" do
|
||||||
clear_config([:instance, :federating]) do
|
clear_config([:instance, :federating], true)
|
||||||
Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "renders subscribe form", %{conn: conn} do
|
test "renders subscribe form", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
|
@ -14,9 +14,7 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_config_all([:instance, :federating]) do
|
clear_config_all([:instance, :federating], true)
|
||||||
Pleroma.Config.put([:instance, :federating], true)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET host-meta" do
|
test "GET host-meta" do
|
||||||
response =
|
response =
|
||||||
|
|
Loading…
Reference in a new issue