Merge branch 'develop' into exclusive-lists
This commit is contained in:
commit
d1787966a6
61 changed files with 703 additions and 546 deletions
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicyTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#nsfw hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["object"]["sensitive"]
|
||||
end
|
||||
|
|
@ -94,7 +94,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicyTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
refute modified["object"]["sensitive"]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
|||
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
||||
|
||||
{:ok, %{"object" => external_rep}} =
|
||||
Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
||||
Pleroma.Web.ActivityPub.Transmogrifier.prepare_activity(edit.data)
|
||||
|
||||
%{external_rep: external_rep}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
|
|||
user = insert(:user)
|
||||
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
||||
{:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
||||
{:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_activity(edit.data)
|
||||
%{external_rep: external_rep}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
)
|
||||
end
|
||||
|
||||
test "Publishes with the new actor if prepare_outgoing changes the actor." do
|
||||
test "Publishes with the new actor if prepare_activity changes the actor." do
|
||||
mock(fn
|
||||
%{method: :post, url: "https://domain.com/users/nick1/inbox", body: body} ->
|
||||
{:ok, %Tesla.Env{status: 200, body: body}}
|
||||
|
|
@ -281,7 +281,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
)
|
||||
|
||||
Pleroma.Web.ActivityPub.TransmogrifierMock
|
||||
|> Mox.expect(:prepare_outgoing, fn data ->
|
||||
|> Mox.expect(:prepare_activity, fn data ->
|
||||
{:ok, Map.put(data, "actor", replaced_actor.ap_id)}
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
|
|||
|> Kernel.put_in(["object", "to"], user.ap_id)
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert data["object"]["type"] == "Note"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
|||
|
||||
{:ok, activity} = Transmogrifier.handle_incoming(message)
|
||||
|
||||
{:ok, _} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, _} = Transmogrifier.prepare_activity(activity.data)
|
||||
end
|
||||
|
||||
test "successfully reserializes a message with AS2 objects in IR" do
|
||||
|
|
@ -537,7 +537,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
|||
|
||||
{:ok, activity} = Transmogrifier.handle_incoming(message)
|
||||
|
||||
{:ok, _} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, _} = Transmogrifier.prepare_activity(activity.data)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, announce_activity} = CommonAPI.repeat(activity.id, user)
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(announce_activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(announce_activity.data)
|
||||
|
||||
assert modified["object"]["content"] == "hey"
|
||||
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||
|
|
@ -448,7 +448,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
with_mock Pleroma.Notification,
|
||||
get_notified_from_activity: fn _, _ -> [] end do
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
object = modified["object"]
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["@context"] == Utils.make_json_ld_header()["@context"]
|
||||
|
||||
|
|
@ -485,7 +485,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||
end
|
||||
|
|
@ -501,7 +501,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
"name" => "#2hu"
|
||||
}
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["object"]["tag"] == [expected_tag]
|
||||
end
|
||||
|
|
@ -524,7 +524,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
url: "https://pleroma.social"
|
||||
} == activity.object.data["generator"]
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert length(modified["object"]["tag"]) == 2
|
||||
|
||||
|
|
@ -541,7 +541,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it strips internal fields of article" do
|
||||
activity = insert(:article_activity)
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert length(modified["object"]["tag"]) == 2
|
||||
|
||||
|
|
@ -558,13 +558,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "2hu :moominmamma:"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["directMessage"] == false
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "@#{other_user.nickname} :moominmamma:"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["directMessage"] == false
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert modified["directMessage"] == true
|
||||
end
|
||||
|
|
@ -585,7 +585,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert is_nil(modified["bcc"])
|
||||
end
|
||||
|
|
@ -594,7 +594,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
listen_activity = insert(:listen)
|
||||
|
||||
# This has an inlined object as in ObjectView
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(listen_activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(listen_activity.data)
|
||||
|
||||
assert modified["type"] == "Listen"
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
object_type = activity.object.data["type"]
|
||||
|
||||
# This does not have an inlined object
|
||||
{:ok, modified2} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified2} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert match?(
|
||||
%{
|
||||
|
|
@ -640,7 +640,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
||||
|
||||
{:ok, prepared} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, prepared} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert length(prepared["object"]["tag"]) == 1
|
||||
|
||||
|
|
@ -655,7 +655,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
||||
{:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew :blank:"})
|
||||
|
||||
{:ok, prepared} = Transmogrifier.prepare_outgoing(update.data)
|
||||
{:ok, prepared} = Transmogrifier.prepare_activity(update.data)
|
||||
|
||||
assert %{
|
||||
"content" => "mew mew :blank:",
|
||||
|
|
@ -689,7 +689,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user_update_changeset: changeset
|
||||
)
|
||||
|
||||
assert {:ok, prepared} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
assert {:ok, prepared} = Transmogrifier.prepare_activity(activity.data)
|
||||
assert prepared["type"] == "Update"
|
||||
assert prepared["@context"]
|
||||
assert prepared["object"]["type"] == user.actor_type
|
||||
|
|
@ -704,7 +704,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, %Activity{} = block_activity} = CommonAPI.block(blocked, blocker)
|
||||
{:ok, %Activity{} = undo_activity} = CommonAPI.unblock(blocked, blocker)
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(undo_activity.data)
|
||||
{:ok, data} = Transmogrifier.prepare_activity(undo_activity.data)
|
||||
|
||||
block_ap_id = block_activity.data["id"]
|
||||
assert is_binary(block_ap_id)
|
||||
|
|
@ -738,7 +738,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert is_binary(note_ap_id)
|
||||
|
||||
{:ok, react_activity} = CommonAPI.react_with_emoji(note_activity.id, user, "🐈")
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(react_activity.data)
|
||||
{:ok, data} = Transmogrifier.prepare_activity(react_activity.data)
|
||||
|
||||
assert match?(
|
||||
%{
|
||||
|
|
@ -764,7 +764,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
note_activity = insert(:note_activity)
|
||||
|
||||
{:ok, react_activity} = CommonAPI.react_with_emoji(note_activity.id, user, ":dinosaur:")
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(react_activity.data)
|
||||
{:ok, data} = Transmogrifier.prepare_activity(react_activity.data)
|
||||
|
||||
assert length(data["tag"]) == 1
|
||||
|
||||
|
|
@ -781,7 +781,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, quoted_post} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, quote_post} = CommonAPI.post(user, %{status: "hey", quoted_status_id: quoted_post.id})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(quote_post.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(quote_post.data)
|
||||
|
||||
%{data: %{"id" => quote_id}} = Object.normalize(quoted_post)
|
||||
|
||||
|
|
@ -793,7 +793,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Cześć", language: "pl"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.object.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.object.data)
|
||||
|
||||
assert [_, _, %{"@language" => "pl"}] = modified["@context"]
|
||||
end
|
||||
|
|
@ -802,7 +802,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Cześć", language: "pl"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
assert [_, _, %{"@language" => "pl"}] = modified["@context"]
|
||||
end
|
||||
|
|
@ -825,7 +825,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
content: content
|
||||
})
|
||||
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
expected_data =
|
||||
activity.data
|
||||
|
|
@ -859,7 +859,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
clear_config([:activitypub, :anonymize_reporter], true)
|
||||
clear_config([:activitypub, :anonymize_reporter_local_nickname], placeholder.nickname)
|
||||
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||
|
||||
expected_data =
|
||||
activity.data
|
||||
|
|
|
|||
|
|
@ -2096,7 +2096,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
result =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("api/v1/blocks")
|
||||
|> get("/api/v1/blocks")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.TwitterAPI.PasswordControllerTest do
|
||||
defmodule Pleroma.Web.OAuth.PasswordControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Config
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
||||
defmodule Pleroma.Web.OAuth.TokenControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: true
|
||||
|
||||
alias Pleroma.Repo
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||
defmodule Pleroma.Web.PleromaAPI.UtilControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
|
|
@ -182,153 +182,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /main/ostatus - remote_subscribe/2" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "renders subscribe form", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"nickname" => user.nickname, "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find user"
|
||||
assert response =~ "Remotely follow #{user.nickname}"
|
||||
end
|
||||
|
||||
test "renders subscribe form with error when user not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"nickname" => "nickname", "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Could not find user"
|
||||
refute response =~ "Remotely follow"
|
||||
end
|
||||
|
||||
test "it redirect to webfinger url", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> post("/main/ostatus", %{
|
||||
"user" => %{"nickname" => user.nickname, "profile" => user2.ap_id}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) ==
|
||||
"https://social.heldscal.la/main/ostatussub?profile=#{user.ap_id}"
|
||||
end
|
||||
|
||||
test "it renders form with error when user not found", %{conn: conn} do
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"user" => %{"nickname" => "jimm", "profile" => user2.ap_id}})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Something went wrong."
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /main/ostatus - remote_subscribe/2 - with statuses" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "renders subscribe form", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
status = insert(:note_activity, %{user: user})
|
||||
status_id = status.id
|
||||
|
||||
assert is_binary(status_id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"status_id" => status_id, "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find status"
|
||||
assert response =~ "Interacting with"
|
||||
end
|
||||
|
||||
test "renders subscribe form with error when status not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"status_id" => "somerandomid", "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Could not find status"
|
||||
refute response =~ "Interacting with"
|
||||
end
|
||||
|
||||
test "it redirect to webfinger url", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
status = insert(:note_activity, %{user: user})
|
||||
status_id = status.id
|
||||
status_ap_id = status.data["object"]
|
||||
|
||||
assert is_binary(status_id)
|
||||
assert is_binary(status_ap_id)
|
||||
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> post("/main/ostatus", %{
|
||||
"status" => %{"status_id" => status_id, "profile" => user2.ap_id}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) ==
|
||||
"https://social.heldscal.la/main/ostatussub?profile=#{status_ap_id}"
|
||||
end
|
||||
|
||||
test "it renders form with error when status not found", %{conn: conn} do
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{
|
||||
"status" => %{"status_id" => "somerandomid", "profile" => user2.ap_id}
|
||||
})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Something went wrong."
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /main/ostatus - show_subscribe_form/2" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "it works with users", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/main/ostatus", %{"nickname" => user.nickname})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find user"
|
||||
assert response =~ "Remotely follow #{user.nickname}"
|
||||
end
|
||||
|
||||
test "it works with statuses", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
status = insert(:note_activity, %{user: user})
|
||||
status_id = status.id
|
||||
|
||||
assert is_binary(status_id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/main/ostatus", %{"status_id" => status_id})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find status"
|
||||
assert response =~ "Interacting with"
|
||||
end
|
||||
end
|
||||
|
||||
test "it returns new captcha", %{conn: conn} do
|
||||
with_mock Pleroma.Captcha,
|
||||
new: fn -> "test_captcha" end do
|
||||
|
|
@ -2,14 +2,14 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
||||
defmodule Pleroma.Web.RegistrationTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserInviteToken
|
||||
alias Pleroma.Web.TwitterAPI.TwitterAPI
|
||||
alias Pleroma.Web.Registration
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:confirm => "bear"
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
|
||||
assert user == User.get_cached_by_nickname("lain")
|
||||
end
|
||||
|
|
@ -40,7 +40,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:confirm => "bear"
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
|
||||
assert user == User.get_cached_by_nickname("lain")
|
||||
end
|
||||
|
|
@ -57,7 +57,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:confirm => "bear"
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
refute user.is_confirmed
|
||||
|
|
@ -89,7 +89,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:reason => "I love anime"
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
refute user.is_approved
|
||||
|
|
@ -125,7 +125,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:confirm => "bear"
|
||||
}
|
||||
|
||||
{:ok, user1} = TwitterAPI.register_user(data1)
|
||||
{:ok, user1} = Registration.register_user(data1)
|
||||
|
||||
data2 = %{
|
||||
:username => "lain",
|
||||
|
|
@ -136,7 +136,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:confirm => "bear"
|
||||
}
|
||||
|
||||
{:ok, user2} = TwitterAPI.register_user(data2)
|
||||
{:ok, user2} = Registration.register_user(data2)
|
||||
|
||||
expected_text =
|
||||
~s(<span class="h-card"><a class="u-url mention" data-user="#{user1.id}" href="#{user1.ap_id}" rel="ugc">@<span>john</span></a></span> test)
|
||||
|
|
@ -160,7 +160,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
|
||||
assert user == User.get_cached_by_nickname("vinny")
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => "DudeLetMeInImAFairy"
|
||||
}
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Invalid token"
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
|
|
@ -199,7 +199,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
|
|
@ -221,7 +221,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
check_fn = fn invite ->
|
||||
data = Map.put(data, :token, invite.token)
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
|
||||
assert user == User.get_cached_by_nickname("vinny")
|
||||
end
|
||||
|
|
@ -254,7 +254,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
data = Map.put(data, "token", invite.token)
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_cached_by_nickname("vinny")
|
||||
|
|
@ -282,7 +282,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
assert user == User.get_cached_by_nickname("vinny")
|
||||
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
|
@ -298,7 +298,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
|
|
@ -321,7 +321,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
assert user == User.get_cached_by_nickname("vinny")
|
||||
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
|
@ -343,7 +343,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
{:ok, user} = Registration.register_user(data)
|
||||
assert user == User.get_cached_by_nickname("vinny")
|
||||
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
|
@ -359,7 +359,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
|
|
@ -379,7 +379,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
|
|
@ -401,7 +401,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:token => invite.token
|
||||
}
|
||||
|
||||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
{:error, msg} = Registration.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
|
|
@ -416,7 +416,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:bio => "close the world."
|
||||
}
|
||||
|
||||
{:error, error} = TwitterAPI.register_user(data)
|
||||
{:error, error} = Registration.register_user(data)
|
||||
|
||||
assert is_binary(error)
|
||||
refute User.get_cached_by_nickname("lain")
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
||||
defmodule Pleroma.Web.RemoteInteraction.RemoteInteractionControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.MFA
|
||||
|
|
@ -16,6 +16,11 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
import Mox
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
setup do: clear_config([:user, :deny_follow_blocked])
|
||||
|
||||
|
|
@ -49,7 +54,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
assert conn
|
||||
|> get(
|
||||
remote_follow_path(conn, :follow, %{
|
||||
remote_interaction_path(conn, :follow, %{
|
||||
acct: "https://mastodon.social/users/emelie/statuses/101849165031453009"
|
||||
})
|
||||
)
|
||||
|
|
@ -78,7 +83,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||
|> get(remote_interaction_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||
|> html_response(200)
|
||||
|
||||
assert response =~ "Log in to follow"
|
||||
|
|
@ -109,7 +114,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||
|> get(remote_interaction_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||
|> html_response(200)
|
||||
|
||||
assert response =~ "Remote follow"
|
||||
|
|
@ -130,7 +135,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
conn
|
||||
|> assign(:user, user)
|
||||
|> get(
|
||||
remote_follow_path(conn, :follow, %{
|
||||
remote_interaction_path(conn, :follow, %{
|
||||
acct: "https://mastodon.social/users/not_found"
|
||||
})
|
||||
)
|
||||
|
|
@ -152,7 +157,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
conn
|
||||
|> assign(:user, user)
|
||||
|> assign(:token, read_token)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
|
|
@ -167,7 +172,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
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}})
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|
||||
assert redirected_to(conn) == "/users/#{user2.id}"
|
||||
end
|
||||
|
|
@ -179,7 +184,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
|
|
@ -195,7 +200,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
|
|
@ -207,7 +212,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => "jimm"}})
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{"user" => %{"id" => "jimm"}})
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "Error following account"
|
||||
|
|
@ -222,7 +227,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
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}})
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|
||||
|
||||
assert redirected_to(conn) == "/users/#{user2.id}"
|
||||
end
|
||||
|
|
@ -244,7 +249,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
|
@ -272,7 +277,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test1", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
|
@ -300,7 +305,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
conn =
|
||||
conn
|
||||
|> post(
|
||||
remote_follow_path(conn, :do_follow),
|
||||
remote_interaction_path(conn, :do_follow),
|
||||
%{
|
||||
"mfa" => %{"code" => otp_token, "token" => token, "id" => user2.id}
|
||||
}
|
||||
|
|
@ -329,7 +334,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
response =
|
||||
conn
|
||||
|> post(
|
||||
remote_follow_path(conn, :do_follow),
|
||||
remote_interaction_path(conn, :do_follow),
|
||||
%{
|
||||
"mfa" => %{"code" => otp_token, "token" => token, "id" => user2.id}
|
||||
}
|
||||
|
|
@ -348,7 +353,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
conn =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|
||||
|
|
@ -361,7 +366,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => "jimm"}
|
||||
})
|
||||
|> response(200)
|
||||
|
|
@ -374,7 +379,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => "jimm", "password" => "test", "id" => user.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
|
@ -388,7 +393,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "42", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
|
@ -404,7 +409,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> post(remote_follow_path(conn, :do_follow), %{
|
||||
|> post(remote_interaction_path(conn, :do_follow), %{
|
||||
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
|
||||
})
|
||||
|> response(200)
|
||||
|
|
@ -423,7 +428,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
avatar: %{"url" => [%{"href" => "https://remote.org/avatar.png"}]}
|
||||
})
|
||||
|
||||
avatar_url = Pleroma.Web.TwitterAPI.RemoteFollowView.avatar_url(user)
|
||||
avatar_url = Pleroma.Web.RemoteInteraction.RemoteInteractionView.avatar_url(user)
|
||||
|
||||
assert avatar_url == "https://remote.org/avatar.png"
|
||||
end
|
||||
|
|
@ -440,7 +445,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
avatar: %{"url" => [%{"href" => "https://remote.org/avatar.png"}]}
|
||||
})
|
||||
|
||||
avatar_url = Pleroma.Web.TwitterAPI.RemoteFollowView.avatar_url(user)
|
||||
avatar_url = Pleroma.Web.RemoteInteraction.RemoteInteractionView.avatar_url(user)
|
||||
url = Pleroma.Web.Endpoint.url()
|
||||
|
||||
assert String.starts_with?(avatar_url, url)
|
||||
|
|
@ -455,7 +460,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
avatar: %{"url" => [%{"href" => "#{Pleroma.Web.Endpoint.url()}/localuser/avatar.png"}]}
|
||||
})
|
||||
|
||||
avatar_url = Pleroma.Web.TwitterAPI.RemoteFollowView.avatar_url(user)
|
||||
avatar_url = Pleroma.Web.RemoteInteraction.RemoteInteractionView.avatar_url(user)
|
||||
|
||||
assert avatar_url == "#{Pleroma.Web.Endpoint.url()}/localuser/avatar.png"
|
||||
end
|
||||
|
|
@ -485,13 +490,160 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
|||
conn =
|
||||
conn
|
||||
|> get(
|
||||
remote_follow_path(conn, :authorize_interaction, %{
|
||||
remote_interaction_path(conn, :authorize_interaction, %{
|
||||
uri: "https://mastodon.social/users/emelie"
|
||||
})
|
||||
)
|
||||
|
||||
assert redirected_to(conn) ==
|
||||
remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"})
|
||||
remote_interaction_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"})
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /main/ostatus - remote_subscribe/2" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "renders subscribe form", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"nickname" => user.nickname, "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find user"
|
||||
assert response =~ "Remotely follow #{user.nickname}"
|
||||
end
|
||||
|
||||
test "renders subscribe form with error when user not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"nickname" => "nickname", "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Could not find user"
|
||||
refute response =~ "Remotely follow"
|
||||
end
|
||||
|
||||
test "it redirect to webfinger url", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> post("/main/ostatus", %{
|
||||
"user" => %{"nickname" => user.nickname, "profile" => user2.ap_id}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) ==
|
||||
"https://social.heldscal.la/main/ostatussub?profile=#{user.ap_id}"
|
||||
end
|
||||
|
||||
test "it renders form with error when user not found", %{conn: conn} do
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"user" => %{"nickname" => "jimm", "profile" => user2.ap_id}})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Something went wrong."
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /main/ostatus - remote_subscribe/2 - with statuses" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "renders subscribe form", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
status = insert(:note_activity, %{user: user})
|
||||
status_id = status.id
|
||||
|
||||
assert is_binary(status_id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"status_id" => status_id, "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find status"
|
||||
assert response =~ "Interacting with"
|
||||
end
|
||||
|
||||
test "renders subscribe form with error when status not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{"status_id" => "somerandomid", "profile" => ""})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Could not find status"
|
||||
refute response =~ "Interacting with"
|
||||
end
|
||||
|
||||
test "it redirect to webfinger url", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
status = insert(:note_activity, %{user: user})
|
||||
status_id = status.id
|
||||
status_ap_id = status.data["object"]
|
||||
|
||||
assert is_binary(status_id)
|
||||
assert is_binary(status_ap_id)
|
||||
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> post("/main/ostatus", %{
|
||||
"status" => %{"status_id" => status_id, "profile" => user2.ap_id}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) ==
|
||||
"https://social.heldscal.la/main/ostatussub?profile=#{status_ap_id}"
|
||||
end
|
||||
|
||||
test "it renders form with error when status not found", %{conn: conn} do
|
||||
user2 = insert(:user, ap_id: "shp@social.heldscal.la")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/main/ostatus", %{
|
||||
"status" => %{"status_id" => "somerandomid", "profile" => user2.ap_id}
|
||||
})
|
||||
|> response(:ok)
|
||||
|
||||
assert response =~ "Something went wrong."
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /main/ostatus - show_subscribe_form/2" do
|
||||
setup do: clear_config([:instance, :federating], true)
|
||||
|
||||
test "it works with users", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/main/ostatus", %{"nickname" => user.nickname})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find user"
|
||||
assert response =~ "Remotely follow #{user.nickname}"
|
||||
end
|
||||
|
||||
test "it works with statuses", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
status = insert(:note_activity, %{user: user})
|
||||
status_id = status.id
|
||||
|
||||
assert is_binary(status_id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/main/ostatus", %{"status_id" => status_id})
|
||||
|> response(:ok)
|
||||
|
||||
refute response =~ "Could not find status"
|
||||
assert response =~ "Interacting with"
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue