aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/support/conn_case.ex9
-rw-r--r--test/web/static_fe/static_fe_controller_test.exs14
2 files changed, 21 insertions, 2 deletions
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index d6595f971..064874201 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -26,6 +26,8 @@ defmodule Pleroma.Web.ConnCase do
use Pleroma.Tests.Helpers
import Pleroma.Web.Router.Helpers
+ alias Pleroma.Config
+
# The default endpoint for testing
@endpoint Pleroma.Web.Endpoint
@@ -50,7 +52,10 @@ defmodule Pleroma.Web.ConnCase do
end
defp ensure_federating_or_authenticated(conn, url, user) do
- Pleroma.Config.put([:instance, :federating], false)
+ initial_setting = Config.get([:instance, :federating])
+ on_exit(fn -> Config.put([:instance, :federating], initial_setting) end)
+
+ Config.put([:instance, :federating], false)
conn
|> get(url)
@@ -61,7 +66,7 @@ defmodule Pleroma.Web.ConnCase do
|> get(url)
|> response(200)
- Pleroma.Config.put([:instance, :federating], true)
+ Config.put([:instance, :federating], true)
conn
|> get(url)
diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs
index 11facab99..a072cc78f 100644
--- a/test/web/static_fe/static_fe_controller_test.exs
+++ b/test/web/static_fe/static_fe_controller_test.exs
@@ -12,6 +12,10 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
Config.put([:static_fe, :enabled], true)
end
+ clear_config([:instance, :federating]) do
+ Config.put([:instance, :federating], true)
+ end
+
setup %{conn: conn} do
conn = put_req_header(conn, "accept", "text/html")
user = insert(:user)
@@ -70,6 +74,10 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
refute html =~ ">test20<"
refute html =~ ">test29<"
end
+
+ test "it requires authentication if instance is NOT federating", %{conn: conn, user: user} do
+ ensure_federating_or_authenticated(conn, "/users/#{user.nickname}", user)
+ end
end
describe "notice html" do
@@ -153,5 +161,11 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
assert html_response(conn, 302) =~ "redirected"
end
+
+ test "it requires authentication if instance is NOT federating", %{conn: conn, user: user} do
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
+
+ ensure_federating_or_authenticated(conn, "/notice/#{activity.id}", user)
+ end
end
end