aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2019-11-04 20:44:24 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2019-11-04 20:44:24 +0300
commit4b7c11e3f928befaa13daf142a2405284b0d07e5 (patch)
treeea4d36a050c26c60b177a5f2acc7471db753287f /test
parentfee127696308dbec9cff6b2a9b399cf2877cf445 (diff)
downloadpleroma-4b7c11e3f928befaa13daf142a2405284b0d07e5.tar.gz
excluded invisible actors from gets /api/v1/accounts/:id
Diffstat (limited to 'test')
-rw-r--r--test/user_test.exs19
-rw-r--r--test/web/mastodon_api/controllers/account_controller_test.exs23
2 files changed, 42 insertions, 0 deletions
diff --git a/test/user_test.exs b/test/user_test.exs
index 6b1b24ce5..485106b75 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -25,6 +25,25 @@ defmodule Pleroma.UserTest do
clear_config([:instance, :account_activation_required])
+ describe "service actors" do
+ test "returns invisible actor" do
+ uri = "#{Pleroma.Web.Endpoint.url()}/internal/fetch-test"
+ followers_uri = "#{uri}/followers"
+ user = User.get_or_create_service_actor_by_ap_id(uri, "internal.fetch-test")
+
+ assert %User{
+ nickname: "internal.fetch-test",
+ invisible: true,
+ local: true,
+ ap_id: ^uri,
+ follower_address: ^followers_uri
+ } = user
+
+ user2 = User.get_or_create_service_actor_by_ap_id(uri, "internal.fetch-test")
+ assert user.id == user2.id
+ end
+ end
+
describe "when tags are nil" do
test "tagging a user" do
user = insert(:user, %{tags: nil})
diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs
index 8fc2d9300..585cb8a9e 100644
--- a/test/web/mastodon_api/controllers/account_controller_test.exs
+++ b/test/web/mastodon_api/controllers/account_controller_test.exs
@@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Web.ActivityPub.InternalFetchActor
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OAuth.Token
@@ -118,6 +119,28 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
refute acc_one == acc_two
assert acc_two == acc_three
end
+
+ test "returns 404 when user is invisible", %{conn: conn} do
+ user = insert(:user, %{invisible: true})
+
+ resp =
+ conn
+ |> get("/api/v1/accounts/#{user.nickname}")
+ |> json_response(404)
+
+ assert %{"error" => "Can't find user"} = resp
+ end
+
+ test "returns 404 for internal.fetch actor", %{conn: conn} do
+ %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
+
+ resp =
+ conn
+ |> get("/api/v1/accounts/internal.fetch")
+ |> json_response(404)
+
+ assert %{"error" => "Can't find user"} = resp
+ end
end
describe "user timelines" do