summaryrefslogtreecommitdiff
path: root/test/web/ostatus
diff options
context:
space:
mode:
Diffstat (limited to 'test/web/ostatus')
-rw-r--r--test/web/ostatus/activity_representer_test.exs6
-rw-r--r--test/web/ostatus/ostatus_controller_test.exs51
-rw-r--r--test/web/ostatus/ostatus_test.exs4
-rw-r--r--test/web/ostatus/user_representer_test.exs1
4 files changed, 57 insertions, 5 deletions
diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs
index 8a0121b37..ed7fdc432 100644
--- a/test/web/ostatus/activity_representer_test.exs
+++ b/test/web/ostatus/activity_representer_test.exs
@@ -36,11 +36,12 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
<updated>#{note_activity.data["object"]["published"]}</updated>
<ostatus:conversation ref="#{note_activity.data["context"]}">#{note_activity.data["context"]}</ostatus:conversation>
<link ref="#{note_activity.data["context"]}" rel="ostatus:conversation" />
+ <summary>#{note_activity.data["object"]["summary"]}</summary>
<link type="application/atom+xml" href="#{note_activity.data["object"]["id"]}" rel="self" />
<link type="text/html" href="#{note_activity.data["object"]["id"]}" rel="alternate" />
<category term="2hu"/>
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
- <link name="moominmamma" rel="emoji" href="#{Pleroma.Web.Endpoint.static_url}/finmoji/128px/moominmamma-128.png" />
+ <link name="2hu" rel="emoji" href="corndog.png" />
"""
tuple = ActivityRepresenter.to_simple_form(note_activity, user)
@@ -74,12 +75,13 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
<updated>#{answer.data["object"]["published"]}</updated>
<ostatus:conversation ref="#{answer.data["context"]}">#{answer.data["context"]}</ostatus:conversation>
<link ref="#{answer.data["context"]}" rel="ostatus:conversation" />
+ <summary>2hu</summary>
<link type="application/atom+xml" href="#{answer.data["object"]["id"]}" rel="self" />
<link type="text/html" href="#{answer.data["object"]["id"]}" rel="alternate" />
<category term="2hu"/>
<thr:in-reply-to ref="#{note.data["object"]["id"]}" href="someurl" />
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
- <link name="moominmamma" rel="emoji" href="#{Pleroma.Web.Endpoint.static_url}/finmoji/128px/moominmamma-128.png" />
+ <link name="2hu" rel="emoji" href="corndog.png" />
"""
tuple = ActivityRepresenter.to_simple_form(answer, user)
diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs
index 77bc202fe..9c945e35b 100644
--- a/test/web/ostatus/ostatus_controller_test.exs
+++ b/test/web/ostatus/ostatus_controller_test.exs
@@ -1,9 +1,41 @@
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
use Pleroma.Web.ConnCase
import Pleroma.Factory
- alias Pleroma.User
+ alias Pleroma.{User, Repo}
alias Pleroma.Web.OStatus.ActivityRepresenter
+ test "decodes a salmon", %{conn: conn} do
+ user = insert(:user)
+ salmon = File.read!("test/fixtures/salmon.xml")
+ conn = conn
+ |> put_req_header("content-type", "application/atom+xml")
+ |> post("/users/#{user.nickname}/salmon", salmon)
+
+ assert response(conn, 200)
+ end
+
+ test "decodes a salmon with a changed magic key", %{conn: conn} do
+ user = insert(:user)
+ salmon = File.read!("test/fixtures/salmon.xml")
+ conn = conn
+ |> put_req_header("content-type", "application/atom+xml")
+ |> post("/users/#{user.nickname}/salmon", salmon)
+
+ assert response(conn, 200)
+
+ # Set a wrong magic-key for a user so it has to refetch
+ salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
+ info = salmon_user.info
+ |> Map.put("magic_key", "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwrong1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB") # Wrong key
+ Repo.update(User.info_changeset(salmon_user, %{info: info}))
+
+ conn = build_conn()
+ |> put_req_header("content-type", "application/atom+xml")
+ |> post("/users/#{user.nickname}/salmon", salmon)
+
+ assert response(conn, 200)
+ end
+
test "gets a feed", %{conn: conn} do
note_activity = insert(:note_activity)
user = User.get_cached_by_ap_id(note_activity.data["actor"])
@@ -41,4 +73,21 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert response(conn, 200)
end
+
+ test "gets a notice", %{conn: conn} do
+ note_activity = insert(:note_activity)
+ url = "/notice/#{note_activity.id}"
+
+ conn = conn
+ |> get(url)
+
+ assert response(conn, 200)
+ end
+end
+
+defmodule Pleroma.Web.OStatusMock do
+ import Pleroma.Factory
+ def handle_incoming(_doc) do
+ insert(:note_activity)
+ end
end
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index 95038b73c..de01612b3 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -85,7 +85,7 @@ defmodule Pleroma.Web.OStatusTest do
assert activity.data["type"] == "Create"
assert activity.data["object"]["type"] == "Note"
assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda"
- assert String.contains?(activity.data["object"]["content"], "technologic")
+ assert activity.data["object"]["summary"] == "technologic"
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
end
@@ -93,7 +93,7 @@ defmodule Pleroma.Web.OStatusTest do
incoming = File.read!("test/fixtures/cw_retweet.xml")
{:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
- assert String.contains?(retweeted_activity.data["object"]["content"], "Hey.")
+ assert retweeted_activity.data["object"]["summary"] == "Hey."
end
test "handle incoming notes - GS, subscription, reply" do
diff --git a/test/web/ostatus/user_representer_test.exs b/test/web/ostatus/user_representer_test.exs
index a4afc2cf7..d5d70f5c6 100644
--- a/test/web/ostatus/user_representer_test.exs
+++ b/test/web/ostatus/user_representer_test.exs
@@ -18,6 +18,7 @@ defmodule Pleroma.Web.OStatus.UserRepresenterTest do
<poco:preferredUsername>#{user.nickname}</poco:preferredUsername>
<poco:displayName>#{user.name}</poco:displayName>
<poco:note>#{user.bio}</poco:note>
+ <summary>#{user.bio}</summary>
<name>#{user.nickname}</name>
<link rel="avatar" href="#{User.avatar_url(user)}" />
"""