Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into follow-pipeline
This commit is contained in:
commit
7d0e2b3fdd
137 changed files with 1522 additions and 737 deletions
|
|
@ -507,6 +507,33 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activities = ActivityPub.fetch_activities_for_context("2hu", %{blocking_user: user})
|
||||
assert activities == [activity_two, activity]
|
||||
end
|
||||
|
||||
test "doesn't return activities with filtered words" do
|
||||
user = insert(:user)
|
||||
user_two = insert(:user)
|
||||
insert(:filter, user: user, phrase: "test", hide: true)
|
||||
|
||||
{:ok, %{id: id1, data: %{"context" => context}}} = CommonAPI.post(user, %{status: "1"})
|
||||
|
||||
{:ok, %{id: id2}} = CommonAPI.post(user_two, %{status: "2", in_reply_to_status_id: id1})
|
||||
|
||||
{:ok, %{id: id3} = user_activity} =
|
||||
CommonAPI.post(user, %{status: "3 test?", in_reply_to_status_id: id2})
|
||||
|
||||
{:ok, %{id: id4} = filtered_activity} =
|
||||
CommonAPI.post(user_two, %{status: "4 test!", in_reply_to_status_id: id3})
|
||||
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "5", in_reply_to_status_id: id4})
|
||||
|
||||
activities =
|
||||
context
|
||||
|> ActivityPub.fetch_activities_for_context(%{user: user})
|
||||
|> Enum.map(& &1.id)
|
||||
|
||||
assert length(activities) == 4
|
||||
assert user_activity.id in activities
|
||||
refute filtered_activity.id in activities
|
||||
end
|
||||
end
|
||||
|
||||
test "doesn't return blocked activities" do
|
||||
|
|
@ -785,6 +812,75 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert activity == expected_activity
|
||||
end
|
||||
|
||||
describe "irreversible filters" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
user_two = insert(:user)
|
||||
|
||||
insert(:filter, user: user_two, phrase: "cofe", hide: true)
|
||||
insert(:filter, user: user_two, phrase: "ok boomer", hide: true)
|
||||
insert(:filter, user: user_two, phrase: "test", hide: false)
|
||||
|
||||
params = %{
|
||||
type: ["Create", "Announce"],
|
||||
user: user_two
|
||||
}
|
||||
|
||||
{:ok, %{user: user, user_two: user_two, params: params}}
|
||||
end
|
||||
|
||||
test "it returns statuses if they don't contain exact filter words", %{
|
||||
user: user,
|
||||
params: params
|
||||
} do
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "got cofefe?"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "I am not a boomer"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "ok boomers"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "ccofee is not a word"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "this is a test"})
|
||||
|
||||
activities = ActivityPub.fetch_activities([], params)
|
||||
|
||||
assert Enum.count(activities) == 6
|
||||
end
|
||||
|
||||
test "it does not filter user's own statuses", %{user_two: user_two, params: params} do
|
||||
{:ok, _} = CommonAPI.post(user_two, %{status: "Give me some cofe!"})
|
||||
{:ok, _} = CommonAPI.post(user_two, %{status: "ok boomer"})
|
||||
|
||||
activities = ActivityPub.fetch_activities([], params)
|
||||
|
||||
assert Enum.count(activities) == 2
|
||||
end
|
||||
|
||||
test "it excludes statuses with filter words", %{user: user, params: params} do
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "Give me some cofe!"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "ok boomer"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "is it a cOfE?"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "cofe is all I need"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "— ok BOOMER\n"})
|
||||
|
||||
activities = ActivityPub.fetch_activities([], params)
|
||||
|
||||
assert Enum.empty?(activities)
|
||||
end
|
||||
|
||||
test "it returns all statuses if user does not have any filters" do
|
||||
another_user = insert(:user)
|
||||
{:ok, _} = CommonAPI.post(another_user, %{status: "got cofe?"})
|
||||
{:ok, _} = CommonAPI.post(another_user, %{status: "test!"})
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{
|
||||
type: ["Create", "Announce"],
|
||||
user: another_user
|
||||
})
|
||||
|
||||
assert Enum.count(activities) == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "public fetch activities" do
|
||||
test "doesn't retrieve unlisted activities" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -659,22 +659,44 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
"https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
|
||||
)
|
||||
|
||||
attachment = %{
|
||||
"type" => "Link",
|
||||
"mediaType" => "video/mp4",
|
||||
"url" => [
|
||||
%{
|
||||
"href" =>
|
||||
"https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4",
|
||||
"mediaType" => "video/mp4"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
assert object.data["url"] ==
|
||||
"https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
|
||||
|
||||
assert object.data["attachment"] == [attachment]
|
||||
assert object.data["attachment"] == [
|
||||
%{
|
||||
"type" => "Link",
|
||||
"mediaType" => "video/mp4",
|
||||
"url" => [
|
||||
%{
|
||||
"href" =>
|
||||
"https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4",
|
||||
"mediaType" => "video/mp4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
{:ok, object} =
|
||||
Fetcher.fetch_object_from_id(
|
||||
"https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206"
|
||||
)
|
||||
|
||||
assert object.data["attachment"] == [
|
||||
%{
|
||||
"type" => "Link",
|
||||
"mediaType" => "video/mp4",
|
||||
"url" => [
|
||||
%{
|
||||
"href" =>
|
||||
"https://framatube.org/static/webseed/6050732a-8a7a-43d4-a6cd-809525a1d206-1080.mp4",
|
||||
"mediaType" => "video/mp4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
assert object.data["url"] ==
|
||||
"https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206"
|
||||
end
|
||||
|
||||
test "it accepts Flag activities" do
|
||||
|
|
|
|||
|
|
@ -216,10 +216,21 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
|
||||
assert user.avatar == %{}
|
||||
|
||||
assert user_response = json_response_and_validate_schema(conn, 200)
|
||||
res = patch(conn, "/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response["avatar"] != User.avatar_url(user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
refute user.avatar == %{}
|
||||
|
||||
# Also resets it
|
||||
_res = patch(conn, "/api/v1/accounts/update_credentials", %{"avatar" => ""})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.avatar == nil
|
||||
end
|
||||
|
||||
test "updates the user's banner", %{user: user, conn: conn} do
|
||||
|
|
@ -229,26 +240,39 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"header" => new_header})
|
||||
res = patch(conn, "/api/v1/accounts/update_credentials", %{"header" => new_header})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(conn, 200)
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response["header"] != User.banner_url(user)
|
||||
|
||||
# Also resets it
|
||||
_res = patch(conn, "/api/v1/accounts/update_credentials", %{"header" => ""})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.banner == nil
|
||||
end
|
||||
|
||||
test "updates the user's background", %{conn: conn} do
|
||||
test "updates the user's background", %{conn: conn, user: user} do
|
||||
new_header = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
conn =
|
||||
res =
|
||||
patch(conn, "/api/v1/accounts/update_credentials", %{
|
||||
"pleroma_background_image" => new_header
|
||||
})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(conn, 200)
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response["pleroma"]["background_image"]
|
||||
#
|
||||
# Also resets it
|
||||
_res =
|
||||
patch(conn, "/api/v1/accounts/update_credentials", %{"pleroma_background_image" => ""})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.background == nil
|
||||
end
|
||||
|
||||
test "requires 'write:accounts' permission" do
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
"avatar_upload_limit" => _,
|
||||
"background_upload_limit" => _,
|
||||
"banner_upload_limit" => _,
|
||||
"background_image" => _
|
||||
"background_image" => _,
|
||||
"chat_limit" => _,
|
||||
"description_limit" => _
|
||||
} = result
|
||||
|
||||
assert result["pleroma"]["metadata"]["account_activation_required"] != nil
|
||||
|
|
|
|||
|
|
@ -418,4 +418,78 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
assert [status_none] == json_response_and_validate_schema(all_test, :ok)
|
||||
end
|
||||
end
|
||||
|
||||
describe "hashtag timeline handling of :restrict_unauthenticated setting" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, activity1} = CommonAPI.post(user, %{status: "test #tag1"})
|
||||
{:ok, _activity2} = CommonAPI.post(user, %{status: "test #tag1"})
|
||||
|
||||
activity1
|
||||
|> Ecto.Changeset.change(%{local: false})
|
||||
|> Pleroma.Repo.update()
|
||||
|
||||
base_uri = "/api/v1/timelines/tag/tag1"
|
||||
error_response = %{"error" => "authorization required for timeline view"}
|
||||
|
||||
%{base_uri: base_uri, error_response: error_response}
|
||||
end
|
||||
|
||||
defp ensure_authenticated_access(base_uri) do
|
||||
%{conn: auth_conn} = oauth_access(["read:statuses"])
|
||||
|
||||
res_conn = get(auth_conn, "#{base_uri}?local=true")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(auth_conn, "#{base_uri}?local=false")
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
end
|
||||
|
||||
test "with `%{local: true, federated: true}`, returns 403 for unauthenticated users", %{
|
||||
conn: conn,
|
||||
base_uri: base_uri,
|
||||
error_response: error_response
|
||||
} do
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local], true)
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
|
||||
for local <- [true, false] do
|
||||
res_conn = get(conn, "#{base_uri}?local=#{local}")
|
||||
|
||||
assert json_response(res_conn, :unauthorized) == error_response
|
||||
end
|
||||
|
||||
ensure_authenticated_access(base_uri)
|
||||
end
|
||||
|
||||
test "with `%{local: false, federated: true}`, forbids unauthenticated access to federated timeline",
|
||||
%{conn: conn, base_uri: base_uri, error_response: error_response} do
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local], false)
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
|
||||
res_conn = get(conn, "#{base_uri}?local=true")
|
||||
assert length(json_response(res_conn, 200)) == 1
|
||||
|
||||
res_conn = get(conn, "#{base_uri}?local=false")
|
||||
assert json_response(res_conn, :unauthorized) == error_response
|
||||
|
||||
ensure_authenticated_access(base_uri)
|
||||
end
|
||||
|
||||
test "with `%{local: true, federated: false}`, forbids unauthenticated access to public timeline" <>
|
||||
"(but not to local public activities which are delivered as part of federated timeline)",
|
||||
%{conn: conn, base_uri: base_uri, error_response: error_response} do
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local], true)
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated], false)
|
||||
|
||||
res_conn = get(conn, "#{base_uri}?local=true")
|
||||
assert json_response(res_conn, :unauthorized) == error_response
|
||||
|
||||
# Note: local activities get delivered as part of federated timeline
|
||||
res_conn = get(conn, "#{base_uri}?local=false")
|
||||
assert length(json_response(res_conn, 200)) == 2
|
||||
|
||||
ensure_authenticated_access(base_uri)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
import Pleroma.Factory
|
||||
import Swoosh.TestAssertions
|
||||
|
||||
@image "data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"
|
||||
|
||||
describe "POST /api/v1/pleroma/accounts/confirmation_resend" do
|
||||
setup do
|
||||
{:ok, user} =
|
||||
|
|
@ -68,103 +66,6 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/v1/pleroma/accounts/update_avatar" do
|
||||
setup do: oauth_access(["write:accounts"])
|
||||
|
||||
test "user avatar can be set", %{user: user, conn: conn} do
|
||||
avatar_image = File.read!("test/fixtures/avatar_data_uri")
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/v1/pleroma/accounts/update_avatar", %{img: avatar_image})
|
||||
|
||||
user = refresh_record(user)
|
||||
|
||||
assert %{
|
||||
"name" => _,
|
||||
"type" => _,
|
||||
"url" => [
|
||||
%{
|
||||
"href" => _,
|
||||
"mediaType" => _,
|
||||
"type" => _
|
||||
}
|
||||
]
|
||||
} = user.avatar
|
||||
|
||||
assert %{"url" => _} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "user avatar can be reset", %{user: user, conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/v1/pleroma/accounts/update_avatar", %{img: ""})
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert user.avatar == nil
|
||||
|
||||
assert %{"url" => nil} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/v1/pleroma/accounts/update_banner" do
|
||||
setup do: oauth_access(["write:accounts"])
|
||||
|
||||
test "can set profile banner", %{user: user, conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/v1/pleroma/accounts/update_banner", %{"banner" => @image})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.banner["type"] == "Image"
|
||||
|
||||
assert %{"url" => _} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "can reset profile banner", %{user: user, conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/v1/pleroma/accounts/update_banner", %{"banner" => ""})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.banner == %{}
|
||||
|
||||
assert %{"url" => nil} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/v1/pleroma/accounts/update_background" do
|
||||
setup do: oauth_access(["write:accounts"])
|
||||
|
||||
test "background image can be set", %{user: user, conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/v1/pleroma/accounts/update_background", %{"img" => @image})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.background["type"] == "Image"
|
||||
# assert %{"url" => _} = json_response(conn, 200)
|
||||
assert %{"url" => _} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "background image can be reset", %{user: user, conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/v1/pleroma/accounts/update_background", %{"img" => ""})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.background == %{}
|
||||
assert %{"url" => nil} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting favorites timeline of specified user" do
|
||||
setup do
|
||||
[current_user, user] = insert_pair(:user, hide_favorites: false)
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Preload.Providers.StatusNetTest do
|
||||
use Pleroma.DataCase
|
||||
alias Pleroma.Web.Preload.Providers.StatusNet
|
||||
|
||||
setup do: {:ok, StatusNet.generate_terms(nil)}
|
||||
|
||||
test "it renders the info", %{"/api/statusnet/config.json" => info} do
|
||||
assert {:ok, res} = Jason.decode(info)
|
||||
assert res["site"]
|
||||
end
|
||||
end
|
||||
|
|
@ -87,6 +87,20 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
assert html =~ "testing a thing!"
|
||||
end
|
||||
|
||||
test "redirects to json if requested", %{conn: conn, user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "testing a thing!"})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header(
|
||||
"accept",
|
||||
"Accept: application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\", text/html"
|
||||
)
|
||||
|> get("/notice/#{activity.id}")
|
||||
|
||||
assert redirected_to(conn, 302) =~ activity.data["object"]
|
||||
end
|
||||
|
||||
test "filters HTML tags", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "<script>alert('xss')</script>"})
|
||||
|
|
|
|||
|
|
@ -224,105 +224,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/statusnet/config" do
|
||||
test "it returns config in xml format", %{conn: conn} do
|
||||
instance = Config.get(:instance)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("accept", "application/xml")
|
||||
|> get("/api/statusnet/config")
|
||||
|> response(:ok)
|
||||
|
||||
assert response ==
|
||||
"<config>\n<site>\n<name>#{Keyword.get(instance, :name)}</name>\n<site>#{
|
||||
Pleroma.Web.base_url()
|
||||
}</site>\n<textlimit>#{Keyword.get(instance, :limit)}</textlimit>\n<closed>#{
|
||||
!Keyword.get(instance, :registrations_open)
|
||||
}</closed>\n</site>\n</config>\n"
|
||||
end
|
||||
|
||||
test "it returns config in json format", %{conn: conn} do
|
||||
instance = Config.get(:instance)
|
||||
Config.put([:instance, :managed_config], true)
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
Config.put([:instance, :invites_enabled], true)
|
||||
Config.put([:instance, :public], false)
|
||||
Config.put([:frontend_configurations, :pleroma_fe], %{theme: "asuka-hospital"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> get("/api/statusnet/config")
|
||||
|> json_response(:ok)
|
||||
|
||||
expected_data = %{
|
||||
"site" => %{
|
||||
"accountActivationRequired" => "0",
|
||||
"closed" => "1",
|
||||
"description" => Keyword.get(instance, :description),
|
||||
"invitesEnabled" => "1",
|
||||
"name" => Keyword.get(instance, :name),
|
||||
"pleromafe" => %{"theme" => "asuka-hospital"},
|
||||
"private" => "1",
|
||||
"safeDMMentionsEnabled" => "0",
|
||||
"server" => Pleroma.Web.base_url(),
|
||||
"textlimit" => to_string(Keyword.get(instance, :limit)),
|
||||
"uploadlimit" => %{
|
||||
"avatarlimit" => to_string(Keyword.get(instance, :avatar_upload_limit)),
|
||||
"backgroundlimit" => to_string(Keyword.get(instance, :background_upload_limit)),
|
||||
"bannerlimit" => to_string(Keyword.get(instance, :banner_upload_limit)),
|
||||
"uploadlimit" => to_string(Keyword.get(instance, :upload_limit))
|
||||
},
|
||||
"vapidPublicKey" => Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
||||
}
|
||||
}
|
||||
|
||||
assert response == expected_data
|
||||
end
|
||||
|
||||
test "returns the state of safe_dm_mentions flag", %{conn: conn} do
|
||||
Config.put([:instance, :safe_dm_mentions], true)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/statusnet/config.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["site"]["safeDMMentionsEnabled"] == "1"
|
||||
|
||||
Config.put([:instance, :safe_dm_mentions], false)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/statusnet/config.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["site"]["safeDMMentionsEnabled"] == "0"
|
||||
end
|
||||
|
||||
test "it returns the managed config", %{conn: conn} do
|
||||
Config.put([:instance, :managed_config], false)
|
||||
Config.put([:frontend_configurations, :pleroma_fe], %{theme: "asuka-hospital"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/statusnet/config.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
refute response["site"]["pleromafe"]
|
||||
|
||||
Config.put([:instance, :managed_config], true)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/statusnet/config.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["site"]["pleromafe"] == %{"theme" => "asuka-hospital"}
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/frontend_configurations" do
|
||||
test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} do
|
||||
config = [
|
||||
|
|
@ -451,28 +352,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/statusnet/version" do
|
||||
test "it returns version in xml format", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("accept", "application/xml")
|
||||
|> get("/api/statusnet/version")
|
||||
|> response(:ok)
|
||||
|
||||
assert response == "<version>#{Pleroma.Application.named_version()}</version>"
|
||||
end
|
||||
|
||||
test "it returns version in json format", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> get("/api/statusnet/version")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response == "#{Pleroma.Application.named_version()}"
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /main/ostatus - remote_subscribe/2" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue