Merge branch 'develop' into admin-be
This commit is contained in:
commit
70c7a26de8
33 changed files with 716 additions and 446 deletions
|
|
@ -125,9 +125,10 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
test "it marks a participation as read" do
|
||||
participation = insert(:participation, %{read: false})
|
||||
{:ok, participation} = Participation.mark_as_read(participation)
|
||||
{:ok, updated_participation} = Participation.mark_as_read(participation)
|
||||
|
||||
assert participation.read
|
||||
assert updated_participation.read
|
||||
assert updated_participation.updated_at == participation.updated_at
|
||||
end
|
||||
|
||||
test "it marks a participation as unread" do
|
||||
|
|
|
|||
|
|
@ -71,6 +71,74 @@ defmodule Pleroma.ObjectTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "delete attachments" do
|
||||
clear_config([Pleroma.Upload])
|
||||
|
||||
test "in subdirectories" do
|
||||
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, %Object{} = attachment} =
|
||||
Pleroma.Web.ActivityPub.ActivityPub.upload(file, actor: user.ap_id)
|
||||
|
||||
%{data: %{"attachment" => [%{"url" => [%{"href" => href}]}]}} =
|
||||
note = insert(:note, %{user: user, data: %{"attachment" => [attachment.data]}})
|
||||
|
||||
uploads_dir = Pleroma.Config.get!([Pleroma.Uploaders.Local, :uploads])
|
||||
|
||||
path = href |> Path.dirname() |> Path.basename()
|
||||
|
||||
assert {:ok, ["an_image.jpg"]} == File.ls("#{uploads_dir}/#{path}")
|
||||
|
||||
Object.delete(note)
|
||||
|
||||
assert Object.get_by_id(attachment.id) == nil
|
||||
|
||||
assert {:ok, []} == File.ls("#{uploads_dir}/#{path}")
|
||||
end
|
||||
|
||||
test "with dedupe enabled" do
|
||||
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||
Pleroma.Config.put([Pleroma.Upload, :filters], [Pleroma.Upload.Filter.Dedupe])
|
||||
|
||||
uploads_dir = Pleroma.Config.get!([Pleroma.Uploaders.Local, :uploads])
|
||||
|
||||
File.mkdir_p!(uploads_dir)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, %Object{} = attachment} =
|
||||
Pleroma.Web.ActivityPub.ActivityPub.upload(file, actor: user.ap_id)
|
||||
|
||||
%{data: %{"attachment" => [%{"url" => [%{"href" => href}]}]}} =
|
||||
note = insert(:note, %{user: user, data: %{"attachment" => [attachment.data]}})
|
||||
|
||||
filename = Path.basename(href)
|
||||
|
||||
assert {:ok, files} = File.ls(uploads_dir)
|
||||
assert filename in files
|
||||
|
||||
Object.delete(note)
|
||||
|
||||
assert Object.get_by_id(attachment.id) == nil
|
||||
assert {:ok, files} = File.ls(uploads_dir)
|
||||
refute filename in files
|
||||
end
|
||||
end
|
||||
|
||||
describe "normalizer" do
|
||||
test "fetches unknown objects by default" do
|
||||
%Object{} =
|
||||
|
|
|
|||
|
|
@ -29,4 +29,25 @@ defmodule Pleroma.Uploaders.LocalTest do
|
|||
|> File.exists?()
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete_file/1" do
|
||||
test "deletes local file" do
|
||||
file_path = "local_upload/files/image.jpg"
|
||||
|
||||
file = %Pleroma.Upload{
|
||||
name: "image.jpg",
|
||||
content_type: "image/jpg",
|
||||
path: file_path,
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
||||
:ok = Local.put_file(file)
|
||||
local_path = Path.join([Local.upload_path(), file_path])
|
||||
assert File.exists?(local_path)
|
||||
|
||||
Local.delete_file(file_path)
|
||||
|
||||
refute File.exists?(local_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Uploaders.MDIITest do
|
||||
use Pleroma.DataCase
|
||||
alias Pleroma.Uploaders.MDII
|
||||
import Tesla.Mock
|
||||
|
||||
describe "get_file/1" do
|
||||
test "it returns path to local folder for files" do
|
||||
assert MDII.get_file("") == {:ok, {:static_dir, "test/uploads"}}
|
||||
end
|
||||
end
|
||||
|
||||
describe "put_file/1" do
|
||||
setup do
|
||||
file_upload = %Pleroma.Upload{
|
||||
name: "mdii-image.jpg",
|
||||
content_type: "image/jpg",
|
||||
path: "test_folder/mdii-image.jpg",
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
||||
[file_upload: file_upload]
|
||||
end
|
||||
|
||||
test "save file", %{file_upload: file_upload} do
|
||||
mock(fn
|
||||
%{method: :post, url: "https://mdii.sakura.ne.jp/mdii-post.cgi?jpg"} ->
|
||||
%Tesla.Env{status: 200, body: "mdii-image"}
|
||||
end)
|
||||
|
||||
assert MDII.put_file(file_upload) ==
|
||||
{:ok, {:url, "https://mdii.sakura.ne.jp/mdii-image.jpg"}}
|
||||
end
|
||||
|
||||
test "save file to local if MDII isn`t available", %{file_upload: file_upload} do
|
||||
mock(fn
|
||||
%{method: :post, url: "https://mdii.sakura.ne.jp/mdii-post.cgi?jpg"} ->
|
||||
%Tesla.Env{status: 500}
|
||||
end)
|
||||
|
||||
assert MDII.put_file(file_upload) == :ok
|
||||
|
||||
assert Path.join([Pleroma.Uploaders.Local.upload_path(), file_upload.path])
|
||||
|> File.exists?()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -79,4 +79,11 @@ defmodule Pleroma.Uploaders.S3Test do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete_file/1" do
|
||||
test_with_mock "deletes file", ExAws, request: fn _req -> {:ok, %{status_code: 204}} end do
|
||||
assert :ok = S3.delete_file("image.jpg")
|
||||
assert_called(ExAws.request(:_))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,6 +23,27 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
describe "gather_webfinger_links/1" do
|
||||
test "it returns links" do
|
||||
user = insert(:user)
|
||||
|
||||
expected_links = [
|
||||
%{"href" => user.ap_id, "rel" => "self", "type" => "application/activity+json"},
|
||||
%{
|
||||
"href" => user.ap_id,
|
||||
"rel" => "self",
|
||||
"type" => "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
|
||||
},
|
||||
%{
|
||||
"rel" => "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template" => "#{Pleroma.Web.base_url()}/ostatus_subscribe?acct={uri}"
|
||||
}
|
||||
]
|
||||
|
||||
assert expected_links == Publisher.gather_webfinger_links(user)
|
||||
end
|
||||
end
|
||||
|
||||
describe "determine_inbox/2" do
|
||||
test "it returns sharedInbox for messages involving as:Public in to" do
|
||||
user =
|
||||
|
|
|
|||
32
test/web/metadata/utils_test.exs
Normal file
32
test/web/metadata/utils_test.exs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Metadata.UtilsTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
alias Pleroma.Web.Metadata.Utils
|
||||
|
||||
describe "scrub_html_and_truncate/1" do
|
||||
test "it returns text without encode HTML" do
|
||||
user = insert(:user)
|
||||
|
||||
note =
|
||||
insert(:note, %{
|
||||
data: %{
|
||||
"actor" => user.ap_id,
|
||||
"id" => "https://pleroma.gov/objects/whatever",
|
||||
"content" => "Pleroma's really cool!"
|
||||
}
|
||||
})
|
||||
|
||||
assert Utils.scrub_html_and_truncate(note) == "Pleroma's really cool!"
|
||||
end
|
||||
end
|
||||
|
||||
describe "scrub_html_and_truncate/2" do
|
||||
test "it returns text without encode HTML" do
|
||||
assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!"
|
||||
end
|
||||
end
|
||||
end
|
||||
235
test/web/twitter_api/remote_follow_controller_test.exs
Normal file
235
test/web/twitter_api/remote_follow_controller_test.exs
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
import ExUnit.CaptureLog
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
clear_config([:instance])
|
||||
clear_config([:frontend_configurations, :pleroma_fe])
|
||||
clear_config([:user, :deny_follow_blocked])
|
||||
|
||||
describe "GET /ostatus_subscribe - remote_follow/2" do
|
||||
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
|
||||
assert conn
|
||||
|> get(
|
||||
remote_follow_path(conn, :follow, %{
|
||||
acct: "https://mastodon.social/users/emelie/statuses/101849165031453009"
|
||||
})
|
||||
)
|
||||
|> redirected_to() =~ "/notice/"
|
||||
end
|
||||
|
||||
test "show follow account page if the `acct` is a account link", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||
|> html_response(200)
|
||||
|
||||
assert response =~ "Log in to follow"
|
||||
end
|
||||
|
||||
test "show follow page if the `acct` is a account link", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||
|> html_response(200)
|
||||
|
||||
assert response =~ "Remote follow"
|
||||
end
|
||||
|
||||
test "show follow page with error when user cannot fecth by `acct` link", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
assert capture_log(fn ->
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get(
|
||||
remote_follow_path(conn, :follow, %{
|
||||
acct: "https://mastodon.social/users/not_found"
|
||||
})
|
||||
)
|
||||
|> html_response(200)
|
||||
|
||||
assert response =~ "Error fetching user"
|
||||
end) =~ "Object has been deleted"
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /ostatus_subscribe - do_follow/2 with assigned user " do
|
||||
test "required `follow | write:follows` scope", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
read_token = insert(:oauth_token, user: user, scopes: ["read"])
|
||||
|
||||
assert capture_log(fn ->
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> assign(:token, read_token)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end) =~ "Insufficient permissions: follow | write:follows."
|
||||
end
|
||||
|
||||
test "follows user", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> assign(:token, insert(:oauth_token, user: user, scopes: ["write:follows"]))
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
test "returns error when user is deactivated", %{conn: conn} do
|
||||
user = insert(:user, deactivated: true)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns error when user is blocked", %{conn: conn} do
|
||||
Pleroma.Config.put([:user, :deny_follow_blocked], true)
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, _user_block} = Pleroma.User.block(user2, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns error when followee not found", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => "jimm"}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns success result when user already in followers", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, refresh_record(user))
|
||||
|> assign(:token, insert(:oauth_token, user: user, scopes: ["write:follows"]))
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /ostatus_subscribe - follow/2 without assigned user " do
|
||||
test "follows", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
test "returns error when followee not found", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => "jimm"}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns error when login invalid", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => "jimm", "password" => "test", "id" => user.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Wrong username or password"
|
||||
end
|
||||
|
||||
test "returns error when password invalid", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "42", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Wrong username or password"
|
||||
end
|
||||
|
||||
test "returns error when user is blocked", %{conn: conn} do
|
||||
Pleroma.Config.put([:user, :deny_follow_blocked], true)
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, _user_block} = Pleroma.User.block(user2, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -319,204 +319,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /ostatus_subscribe - remote_follow/2" do
|
||||
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
|
||||
conn =
|
||||
get(
|
||||
conn,
|
||||
"/ostatus_subscribe?acct=https://mastodon.social/users/emelie/statuses/101849165031453009"
|
||||
)
|
||||
|
||||
assert redirected_to(conn) =~ "/notice/"
|
||||
end
|
||||
|
||||
test "show follow account page if the `acct` is a account link", %{conn: conn} do
|
||||
response =
|
||||
get(
|
||||
conn,
|
||||
"/ostatus_subscribe?acct=https://mastodon.social/users/emelie"
|
||||
)
|
||||
|
||||
assert html_response(response, 200) =~ "Log in to follow"
|
||||
end
|
||||
|
||||
test "show follow page if the `acct` is a account link", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/ostatus_subscribe?acct=https://mastodon.social/users/emelie")
|
||||
|
||||
assert html_response(response, 200) =~ "Remote follow"
|
||||
end
|
||||
|
||||
test "show follow page with error when user cannot fecth by `acct` link", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
assert capture_log(fn ->
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/ostatus_subscribe?acct=https://mastodon.social/users/not_found")
|
||||
|
||||
assert html_response(response, 200) =~ "Error fetching user"
|
||||
end) =~ "Object has been deleted"
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /ostatus_subscribe - do_remote_follow/2 with assigned user" do
|
||||
setup do: oauth_access(["follow"])
|
||||
|
||||
test "follows user", %{user: user, conn: conn} do
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
test "returns error when user is deactivated" do
|
||||
user = insert(:user, deactivated: true)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> assign(:token, insert(:oauth_token, user: user, scopes: ["follow"]))
|
||||
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns error when user is blocked", %{user: user, conn: conn} do
|
||||
Pleroma.Config.put([:user, :deny_follow_blocked], true)
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, _user_block} = Pleroma.User.block(user2, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns error on insufficient permissions", %{user: user, conn: conn} do
|
||||
user2 = insert(:user)
|
||||
|
||||
for token <- [nil, insert(:oauth_token, user: user, scopes: ["read"])] do
|
||||
response =
|
||||
conn
|
||||
|> assign(:token, token)
|
||||
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
end
|
||||
|
||||
test "returns error when followee not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{"user" => %{"id" => "jimm"}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns success result when user already in followers", %{user: user, conn: conn} do
|
||||
user2 = insert(:user)
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /ostatus_subscribe - do_remote_follow/2 without assigned user" do
|
||||
test "follows", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
test "returns error when followee not found", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => "jimm"}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
|
||||
test "returns error when login invalid", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{
|
||||
"authorization" => %{"name" => "jimm", "password" => "test", "id" => user.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Wrong username or password"
|
||||
end
|
||||
|
||||
test "returns error when password invalid", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "42", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Wrong username or password"
|
||||
end
|
||||
|
||||
test "returns error when user is blocked", %{conn: conn} do
|
||||
Pleroma.Config.put([:user, :deny_follow_blocked], true)
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, _user_block} = Pleroma.User.block(user2, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/ostatus_subscribe", %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/healthcheck" do
|
||||
clear_config([:instance, :healthcheck])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue