summaryrefslogtreecommitdiff
path: root/test/web
diff options
context:
space:
mode:
Diffstat (limited to 'test/web')
-rw-r--r--test/web/activity_pub/activity_pub_test.exs7
-rw-r--r--test/web/activity_pub/mrf/hellthread_policy_test.exs2
-rw-r--r--test/web/activity_pub/mrf/keyword_policy_test.exs2
-rw-r--r--test/web/activity_pub/mrf/mention_policy_test.exs2
-rw-r--r--test/web/activity_pub/mrf/subchain_policy_test.exs2
-rw-r--r--test/web/activity_pub/transmogrifier/follow_handling_test.exs2
-rw-r--r--test/web/admin_api/admin_api_controller_test.exs2
-rw-r--r--test/web/common_api/common_api_test.exs1
-rw-r--r--test/web/mastodon_api/controllers/account_controller_test.exs10
-rw-r--r--test/web/mastodon_api/controllers/status_controller_test.exs1
-rw-r--r--test/web/media_proxy/media_proxy_controller_test.exs7
-rw-r--r--test/web/media_proxy/media_proxy_test.exs4
-rw-r--r--test/web/metadata/opengraph_test.exs2
-rw-r--r--test/web/metadata/twitter_card_test.exs2
-rw-r--r--test/web/node_info_test.exs44
-rw-r--r--test/web/oauth/oauth_controller_test.exs3
-rw-r--r--test/web/plugs/federating_plug_test.exs3
-rw-r--r--test/web/streamer/streamer_test.exs2
-rw-r--r--test/web/twitter_api/twitter_api_test.exs44
-rw-r--r--test/web/twitter_api/util_controller_test.exs1
20 files changed, 60 insertions, 83 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index ce68e7d0e..9b7cfee63 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -1224,6 +1224,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
describe "deletion" do
+ clear_config([:instance, :rewrite_policy])
+
test "it creates a delete activity and deletes the original object" do
note = insert(:note_activity)
object = Object.normalize(note)
@@ -1327,11 +1329,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
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)
- on_exit(fn -> Pleroma.Config.put([:instance, :rewrite_policy], rewrite_policy) end)
-
note = insert(:note_activity)
object = Object.normalize(note)
@@ -1396,6 +1395,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
describe "update" do
+ clear_config([:instance, :max_pinned_statuses])
+
test "it creates an update activity with the new user data" do
user = insert(:user)
{:ok, user} = User.ensure_keys_present(user)
diff --git a/test/web/activity_pub/mrf/hellthread_policy_test.exs b/test/web/activity_pub/mrf/hellthread_policy_test.exs
index eb6ee4d04..a78752a12 100644
--- a/test/web/activity_pub/mrf/hellthread_policy_test.exs
+++ b/test/web/activity_pub/mrf/hellthread_policy_test.exs
@@ -26,6 +26,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
[user: user, message: message]
end
+ clear_config(:mrf_hellthread)
+
describe "reject" do
test "rejects the message if the recipient count is above reject_threshold", %{
message: message
diff --git a/test/web/activity_pub/mrf/keyword_policy_test.exs b/test/web/activity_pub/mrf/keyword_policy_test.exs
index 602892a37..d950ddd56 100644
--- a/test/web/activity_pub/mrf/keyword_policy_test.exs
+++ b/test/web/activity_pub/mrf/keyword_policy_test.exs
@@ -7,6 +7,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
alias Pleroma.Web.ActivityPub.MRF.KeywordPolicy
+ clear_config(:mrf_keyword)
+
setup do
Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []})
end
diff --git a/test/web/activity_pub/mrf/mention_policy_test.exs b/test/web/activity_pub/mrf/mention_policy_test.exs
index 9fd9c31df..93a55850f 100644
--- a/test/web/activity_pub/mrf/mention_policy_test.exs
+++ b/test/web/activity_pub/mrf/mention_policy_test.exs
@@ -7,6 +7,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
alias Pleroma.Web.ActivityPub.MRF.MentionPolicy
+ clear_config(:mrf_mention)
+
test "pass filter if allow list is empty" do
Pleroma.Config.delete([:mrf_mention])
diff --git a/test/web/activity_pub/mrf/subchain_policy_test.exs b/test/web/activity_pub/mrf/subchain_policy_test.exs
index f7cbcad48..29065f612 100644
--- a/test/web/activity_pub/mrf/subchain_policy_test.exs
+++ b/test/web/activity_pub/mrf/subchain_policy_test.exs
@@ -14,6 +14,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicyTest do
"object" => %{"content" => "hi"}
}
+ 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], %{
~r/^https:\/\/banned.com/s => [DropPolicy]
diff --git a/test/web/activity_pub/transmogrifier/follow_handling_test.exs b/test/web/activity_pub/transmogrifier/follow_handling_test.exs
index 1c88b05c2..fd771ac54 100644
--- a/test/web/activity_pub/transmogrifier/follow_handling_test.exs
+++ b/test/web/activity_pub/transmogrifier/follow_handling_test.exs
@@ -19,6 +19,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
end
describe "handle_incoming" do
+ clear_config([:user, :deny_follow_blocked])
+
test "it works for osada follow request" do
user = insert(:user)
diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs
index 5fbdf96f6..ddfb9a5f5 100644
--- a/test/web/admin_api/admin_api_controller_test.exs
+++ b/test/web/admin_api/admin_api_controller_test.exs
@@ -1890,9 +1890,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
end
test "when configuration from database is off", %{conn: conn} do
- initial = Pleroma.Config.get(:configurable_from_database)
Pleroma.Config.put(:configurable_from_database, false)
- on_exit(fn -> Pleroma.Config.put(:configurable_from_database, initial) end)
conn = get(conn, "/api/pleroma/admin/config")
assert json_response(conn, 400) ==
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 11f7c068f..601c32954 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -68,6 +68,7 @@ defmodule Pleroma.Web.CommonAPITest do
har = insert(:user)
jafnhar = insert(:user)
tridi = insert(:user)
+
Pleroma.Config.put([:instance, :safe_dm_mentions], true)
{:ok, activity} =
diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs
index e2abcd7c5..8625bb9cf 100644
--- a/test/web/mastodon_api/controllers/account_controller_test.exs
+++ b/test/web/mastodon_api/controllers/account_controller_test.exs
@@ -15,6 +15,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
import Pleroma.Factory
describe "account fetching" do
+ clear_config([:instance, :limit_to_local_content])
+
test "works by id" do
user = insert(:user)
@@ -44,7 +46,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
end
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)
user = insert(:user, nickname: "user@example.com", local: false)
@@ -52,13 +53,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
build_conn()
|> 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 == user.id
end
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)
user = insert(:user, nickname: "user@example.com", local: false)
@@ -67,12 +66,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
build_conn()
|> get("/api/v1/accounts/#{user.nickname}")
- Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)
assert json_response(conn, 404)
end
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)
user = insert(:user, nickname: "user@example.com", local: false)
@@ -90,7 +87,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|> assign(:token, insert(:oauth_token, user: reading_user, scopes: ["read:accounts"]))
|> 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 == user.id
end
@@ -677,6 +673,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
assert json_response(res, 400) == %{"error" => "{\"email\":[\"has already been taken\"]}"}
end
+ clear_config([Pleroma.Plugs.RemoteIp, :enabled])
+
test "rate limit", %{conn: conn} do
Pleroma.Config.put([Pleroma.Plugs.RemoteIp, :enabled], true)
app_token = insert(:oauth_token, user: nil)
diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs
index 810f371cb..4f467ac11 100644
--- a/test/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/web/mastodon_api/controllers/status_controller_test.exs
@@ -21,6 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
clear_config([:instance, :federating])
clear_config([:instance, :allow_relay])
+ clear_config([:rich_media, :enabled])
describe "posting statuses" do
setup do: oauth_access(["write:statuses"])
diff --git a/test/web/media_proxy/media_proxy_controller_test.exs b/test/web/media_proxy/media_proxy_controller_test.exs
index fdfdb5ec6..8c0c2a0e2 100644
--- a/test/web/media_proxy/media_proxy_controller_test.exs
+++ b/test/web/media_proxy/media_proxy_controller_test.exs
@@ -7,11 +7,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
import Mock
alias Pleroma.Config
- setup do
- media_proxy_config = Config.get([:media_proxy]) || []
- on_exit(fn -> Config.put([:media_proxy], media_proxy_config) end)
- :ok
- end
+ clear_config(:media_proxy)
+ clear_config([Pleroma.Web.Endpoint, :secret_key_base])
test "it returns 404 when MediaProxy disabled", %{conn: conn} do
Config.put([:media_proxy, :enabled], false)
diff --git a/test/web/media_proxy/media_proxy_test.exs b/test/web/media_proxy/media_proxy_test.exs
index 96bdde219..2be5c9de0 100644
--- a/test/web/media_proxy/media_proxy_test.exs
+++ b/test/web/media_proxy/media_proxy_test.exs
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.MediaProxyTest do
alias Pleroma.Web.MediaProxy.MediaProxyController
clear_config([:media_proxy, :enabled])
+ clear_config(Pleroma.Upload)
describe "when enabled" do
setup do
@@ -224,7 +225,6 @@ defmodule Pleroma.Web.MediaProxyTest do
end
test "ensure Pleroma.Upload base_url is always whitelisted" do
- upload_config = Pleroma.Config.get([Pleroma.Upload])
media_url = "https://media.pleroma.social"
Pleroma.Config.put([Pleroma.Upload, :base_url], media_url)
@@ -232,8 +232,6 @@ defmodule Pleroma.Web.MediaProxyTest do
encoded = url(url)
assert String.starts_with?(encoded, media_url)
-
- Pleroma.Config.put([Pleroma.Upload], upload_config)
end
end
end
diff --git a/test/web/metadata/opengraph_test.exs b/test/web/metadata/opengraph_test.exs
index 4283f72cd..0d47b1cb8 100644
--- a/test/web/metadata/opengraph_test.exs
+++ b/test/web/metadata/opengraph_test.exs
@@ -7,6 +7,8 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
import Pleroma.Factory
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
user = insert(:user)
diff --git a/test/web/metadata/twitter_card_test.exs b/test/web/metadata/twitter_card_test.exs
index 85a654f52..faf347cc6 100644
--- a/test/web/metadata/twitter_card_test.exs
+++ b/test/web/metadata/twitter_card_test.exs
@@ -13,6 +13,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
alias Pleroma.Web.Metadata.Utils
alias Pleroma.Web.Router
+ 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")
avatar_url = Utils.attachment_url(User.avatar_url(user))
diff --git a/test/web/node_info_test.exs b/test/web/node_info_test.exs
index 39dd72cec..d1d7a3ce8 100644
--- a/test/web/node_info_test.exs
+++ b/test/web/node_info_test.exs
@@ -6,7 +6,9 @@ defmodule Pleroma.Web.NodeInfoTest do
use Pleroma.Web.ConnCase
import Pleroma.Factory
+
clear_config([:mrf_simple])
+ clear_config(:instance)
test "GET /.well-known/nodeinfo", %{conn: conn} do
links =
@@ -63,11 +65,6 @@ defmodule Pleroma.Web.NodeInfoTest do
end
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_remote_account_fields], 15)
Pleroma.Config.put([:instance, :account_field_name_length], 255)
@@ -82,11 +79,6 @@ defmodule Pleroma.Web.NodeInfoTest do
assert response["metadata"]["fieldsLimits"]["maxRemoteFields"] == 15
assert response["metadata"]["fieldsLimits"]["nameLength"] == 255
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
test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do
@@ -112,28 +104,28 @@ defmodule Pleroma.Web.NodeInfoTest do
Pleroma.Config.put([:instance, :safe_dm_mentions], option)
end
- test "it shows if federation is enabled/disabled", %{conn: conn} do
- original = Pleroma.Config.get([:instance, :federating])
+ describe "`metadata/federation/enabled`" do
+ clear_config([:instance, :federating])
- Pleroma.Config.put([:instance, :federating], true)
-
- response =
- conn
- |> get("/nodeinfo/2.1.json")
- |> json_response(:ok)
+ test "it shows if federation is enabled/disabled", %{conn: conn} do
+ Pleroma.Config.put([:instance, :federating], true)
- assert response["metadata"]["federation"]["enabled"] == true
+ response =
+ conn
+ |> get("/nodeinfo/2.1.json")
+ |> json_response(:ok)
- Pleroma.Config.put([:instance, :federating], false)
+ assert response["metadata"]["federation"]["enabled"] == true
- response =
- conn
- |> get("/nodeinfo/2.1.json")
- |> json_response(:ok)
+ Pleroma.Config.put([:instance, :federating], false)
- assert response["metadata"]["federation"]["enabled"] == false
+ response =
+ conn
+ |> get("/nodeinfo/2.1.json")
+ |> json_response(:ok)
- Pleroma.Config.put([:instance, :federating], original)
+ assert response["metadata"]["federation"]["enabled"] == false
+ end
end
test "it shows MRF transparency data if enabled", %{conn: conn} do
diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs
index adeff8e25..89fcf8c36 100644
--- a/test/web/oauth/oauth_controller_test.exs
+++ b/test/web/oauth/oauth_controller_test.exs
@@ -17,7 +17,8 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
key: "_test",
signing_salt: "cooldude"
]
- clear_config_all([:instance, :account_activation_required])
+
+ clear_config([:instance, :account_activation_required])
describe "in OAuth consumer mode, " do
setup do
diff --git a/test/web/plugs/federating_plug_test.exs b/test/web/plugs/federating_plug_test.exs
index 9dcab93da..c26b487d9 100644
--- a/test/web/plugs/federating_plug_test.exs
+++ b/test/web/plugs/federating_plug_test.exs
@@ -4,7 +4,8 @@
defmodule Pleroma.Web.FederatingPlugTest do
use Pleroma.Web.ConnCase
- clear_config_all([:instance, :federating])
+
+ clear_config([:instance, :federating])
test "returns and halt the conn when federating is disabled" do
Pleroma.Config.put([:instance, :federating], false)
diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs
index 2a7550551..1cf20f1c2 100644
--- a/test/web/streamer/streamer_test.exs
+++ b/test/web/streamer/streamer_test.exs
@@ -20,7 +20,7 @@ defmodule Pleroma.Web.StreamerTest do
@streamer_timeout 150
@streamer_start_wait 10
- clear_config_all([:instance, :skip_thread_containment])
+ clear_config([:instance, :skip_thread_containment])
describe "user streams" do
setup do
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index 85a9be3e0..7650238f2 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -117,15 +117,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end
describe "register with one time token" do
- setup do
- setting = Pleroma.Config.get([:instance, :registrations_open])
-
- if setting do
- Pleroma.Config.put([:instance, :registrations_open], false)
- on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
- end
-
- :ok
+ clear_config([:instance, :registrations_open]) do
+ Pleroma.Config.put([:instance, :registrations_open], false)
end
test "returns user on success" do
@@ -191,14 +184,11 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end
describe "registers with date limited token" do
- setup do
- setting = Pleroma.Config.get([:instance, :registrations_open])
-
- if setting do
- Pleroma.Config.put([:instance, :registrations_open], false)
- on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
- end
+ clear_config([:instance, :registrations_open]) do
+ Pleroma.Config.put([:instance, :registrations_open], false)
+ end
+ setup do
data = %{
"nickname" => "vinny",
"email" => "pasta@pizza.vs",
@@ -256,15 +246,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end
describe "registers with reusable token" do
- setup do
- setting = Pleroma.Config.get([:instance, :registrations_open])
-
- if setting do
- Pleroma.Config.put([:instance, :registrations_open], false)
- on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
- end
-
- :ok
+ clear_config([:instance, :registrations_open]) do
+ Pleroma.Config.put([:instance, :registrations_open], false)
end
test "returns user on success, after him registration fails" do
@@ -309,15 +292,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end
describe "registers with reusable date limited token" do
- setup do
- setting = Pleroma.Config.get([:instance, :registrations_open])
-
- if setting do
- Pleroma.Config.put([:instance, :registrations_open], false)
- on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
- end
-
- :ok
+ clear_config([:instance, :registrations_open]) do
+ Pleroma.Config.put([:instance, :registrations_open], false)
end
test "returns user on success" do
diff --git a/test/web/twitter_api/util_controller_test.exs b/test/web/twitter_api/util_controller_test.exs
index 5d60c0d51..56633ffce 100644
--- a/test/web/twitter_api/util_controller_test.exs
+++ b/test/web/twitter_api/util_controller_test.exs
@@ -19,7 +19,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
clear_config([:instance])
clear_config([:frontend_configurations, :pleroma_fe])
- clear_config([:user, :deny_follow_blocked])
describe "POST /api/pleroma/follow_import" do
setup do: oauth_access(["follow"])