restrict_unauthenticated setting
This commit is contained in:
parent
d63dca8d99
commit
fe15f0ba15
12 changed files with 615 additions and 33 deletions
|
|
@ -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
|
||||
|
|
@ -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,106 @@ 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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
|
||||
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 +394,110 @@ 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
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
|
||||
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"])
|
||||
|
||||
|
|
@ -757,7 +962,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
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})
|
||||
Config.put([:rate_limit, :app_account_creation], {10_000, 2})
|
||||
end
|
||||
|
||||
test "respects rate limit setting", %{conn: conn} do
|
||||
|
|
|
|||
|
|
@ -476,6 +476,103 @@ 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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
|
||||
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 +611,78 @@ 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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
|
||||
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"])
|
||||
|
|
|
|||
|
|
@ -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,106 @@ 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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :local], true)
|
||||
end
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :local], true)
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
end
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue