projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'features/validators-apc2s' into 'develop'
[akkoma]
/
test
/
pleroma
/
web
/
o_status
/
o_status_controller_test.exs
diff --git
a/test/pleroma/web/o_status/o_status_controller_test.exs
b/test/pleroma/web/o_status/o_status_controller_test.exs
index ee498f4b555ea10022ac07dbe91f2f6713f88900..81d66983763b1f879775d0ab1aaeafaaddc5f68f 100644
(file)
--- a/
test/pleroma/web/o_status/o_status_controller_test.exs
+++ b/
test/pleroma/web/o_status/o_status_controller_test.exs
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
@@
-7,7
+7,6
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
import Pleroma.Factory
import Pleroma.Factory
- alias Pleroma.Config
alias Pleroma.Object
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Object
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
@@
-21,7
+20,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
:ok
end
:ok
end
- setup do: clear_config([:
instance, :federating], tru
e)
+ setup do: clear_config([:
static_fe, :enabled], fals
e)
describe "Mastodon compatibility routes" do
setup %{conn: conn} do
describe "Mastodon compatibility routes" do
setup %{conn: conn} do
@@
-73,7
+72,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
test "redirects to /notice/id for html format", %{conn: conn} do
note_activity = insert(:note_activity)
test "redirects to /notice/id for html format", %{conn: conn} do
note_activity = insert(:note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity
, fetch: false
)
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"]))
url = "/objects/#{uuid}"
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"]))
url = "/objects/#{uuid}"
@@
-83,7
+82,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
test "404s on private objects", %{conn: conn} do
note_activity = insert(:direct_note_activity)
test "404s on private objects", %{conn: conn} do
note_activity = insert(:direct_note_activity)
- object = Object.normalize(note_activity)
+ object = Object.normalize(note_activity
, fetch: false
)
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"]))
conn
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"]))
conn
@@
-134,7
+133,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
conn: conn
} do
note_activity = insert(:note_activity)
conn: conn
} do
note_activity = insert(:note_activity)
- expected_redirect_url = Object.normalize(note_activity).data["id"]
+ expected_redirect_url = Object.normalize(note_activity
, fetch: false
).data["id"]
redirect_url =
conn
redirect_url =
conn
@@
-145,13
+144,19
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert redirect_url == expected_redirect_url
end
assert redirect_url == expected_redirect_url
end
- test "returns a 404 on remote notice when json requested", %{conn: conn} do
+ test "redirects to a proper object URL when json requested and the object is remote", %{
+ conn: conn
+ } do
note_activity = insert(:note_activity, local: false)
note_activity = insert(:note_activity, local: false)
+ expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
- conn
- |> put_req_header("accept", "application/activity+json")
- |> get("/notice/#{note_activity.id}")
- |> response(404)
+ redirect_url =
+ conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get("/notice/#{note_activity.id}")
+ |> redirected_to()
+
+ assert redirect_url == expected_redirect_url
end
test "500s when actor not found", %{conn: conn} do
end
test "500s when actor not found", %{conn: conn} do
@@
-177,7
+182,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|> response(200)
assert resp =~
|> response(200)
assert resp =~
- "<meta content=\"#{Pleroma.Web.
base_
url()}/notice/#{note_activity.id}\" property=\"og:url\">"
+ "<meta content=\"#{Pleroma.Web.
Endpoint.
url()}/notice/#{note_activity.id}\" property=\"og:url\">"
user = insert(:user)
user = insert(:user)
@@
-215,22
+220,23
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert response(conn, 404)
end
assert response(conn, 404)
end
- test "
it requires authentication if instance is NOT federating
", %{
+ test "
does not require authentication on non-federating instances
", %{
conn: conn
} do
conn: conn
} do
-
user = insert(:user
)
+
clear_config([:instance, :federating], false
)
note_activity = insert(:note_activity)
note_activity = insert(:note_activity)
- conn = put_req_header(conn, "accept", "text/html")
-
- ensure_federating_or_authenticated(conn, "/notice/#{note_activity.id}", user)
+ conn
+ |> put_req_header("accept", "text/html")
+ |> get("/notice/#{note_activity.id}")
+ |> response(200)
end
end
describe "GET /notice/:id/embed_player" do
setup do
note_activity = insert(:note_activity)
end
end
describe "GET /notice/:id/embed_player" do
setup do
note_activity = insert(:note_activity)
- object = Pleroma.Object.normalize(note_activity)
+ object = Pleroma.Object.normalize(note_activity
, fetch: false
)
object_data =
Map.put(object.data, "attachment", [
object_data =
Map.put(object.data, "attachment", [
@@
-287,7
+293,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
test "404s when attachment is empty", %{conn: conn} do
note_activity = insert(:note_activity)
test "404s when attachment is empty", %{conn: conn} do
note_activity = insert(:note_activity)
- object = Pleroma.Object.normalize(note_activity)
+ object = Pleroma.Object.normalize(note_activity
, fetch: false
)
object_data = Map.put(object.data, "attachment", [])
object
object_data = Map.put(object.data, "attachment", [])
object
@@
-301,7
+307,7
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
test "404s when attachment isn't audio or video", %{conn: conn} do
note_activity = insert(:note_activity)
test "404s when attachment isn't audio or video", %{conn: conn} do
note_activity = insert(:note_activity)
- object = Pleroma.Object.normalize(note_activity)
+ object = Pleroma.Object.normalize(note_activity
, fetch: false
)
object_data =
Map.put(object.data, "attachment", [
object_data =
Map.put(object.data, "attachment", [
@@
-325,14
+331,16
@@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|> response(404)
end
|> response(404)
end
- test "
it requires authentication if instance is NOT federating
", %{
+ test "
does not require authentication on non-federating instances
", %{
conn: conn,
note_activity: note_activity
} do
conn: conn,
note_activity: note_activity
} do
- user = insert(:user)
- conn = put_req_header(conn, "accept", "text/html")
+ clear_config([:instance, :federating], false)
- ensure_federating_or_authenticated(conn, "/notice/#{note_activity.id}/embed_player", user)
+ conn
+ |> put_req_header("accept", "text/html")
+ |> get("/notice/#{note_activity.id}/embed_player")
+ |> response(200)
end
end
end
end
end
end