1 defmodule Pleroma.Web.OStatus.OStatusControllerTest do
2 use Pleroma.Web.ConnCase
4 alias Pleroma.{User, Repo}
5 alias Pleroma.Web.OStatus.ActivityRepresenter
7 test "decodes a salmon", %{conn: conn} do
9 salmon = File.read!("test/fixtures/salmon.xml")
13 |> put_req_header("content-type", "application/atom+xml")
14 |> post("/users/#{user.nickname}/salmon", salmon)
16 assert response(conn, 200)
19 test "decodes a salmon with a changed magic key", %{conn: conn} do
21 salmon = File.read!("test/fixtures/salmon.xml")
25 |> put_req_header("content-type", "application/atom+xml")
26 |> post("/users/#{user.nickname}/salmon", salmon)
28 assert response(conn, 200)
30 # Set a wrong magic-key for a user so it has to refetch
31 salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
37 "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwrong1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB"
40 Repo.update(User.info_changeset(salmon_user, %{info: info}))
44 |> put_req_header("content-type", "application/atom+xml")
45 |> post("/users/#{user.nickname}/salmon", salmon)
47 assert response(conn, 200)
50 test "gets a feed", %{conn: conn} do
51 note_activity = insert(:note_activity)
52 user = User.get_cached_by_ap_id(note_activity.data["actor"])
56 |> get("/users/#{user.nickname}/feed.atom")
58 assert response(conn, 200) =~ note_activity.data["object"]["content"]
61 test "gets an object", %{conn: conn} do
62 note_activity = insert(:note_activity)
63 user = User.get_by_ap_id(note_activity.data["actor"])
64 [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"]))
65 url = "/objects/#{uuid}"
72 ActivityRepresenter.to_simple_form(note_activity, user, true)
73 |> ActivityRepresenter.wrap_with_entry()
74 |> :xmerl.export_simple(:xmerl_xml)
77 assert response(conn, 200) == expected
80 test "gets an activity", %{conn: conn} do
81 note_activity = insert(:note_activity)
82 [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"]))
83 url = "/activities/#{uuid}"
89 assert response(conn, 200)
92 test "gets a notice", %{conn: conn} do
93 note_activity = insert(:note_activity)
94 url = "/notice/#{note_activity.id}"
100 assert response(conn, 200)