1 defmodule Pleroma.Web.OStatusTest do
3 alias Pleroma.Web.OStatus
6 test "handle incoming notes" do
7 incoming = File.read!("test/fixtures/incoming_note_activity.xml")
8 {:ok, activity} = OStatus.handle_incoming(incoming)
10 assert activity.data["type"] == "Create"
11 assert activity.data["object"]["type"] == "Note"
12 assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
13 assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
14 assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
17 test "handle incoming replies" do
18 incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
19 {:ok, activity} = OStatus.handle_incoming(incoming)
21 assert activity.data["type"] == "Create"
22 assert activity.data["object"]["type"] == "Note"
23 assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
24 assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"]
27 describe "new remote user creation" do
28 test "tries to use the information in poco fields" do
29 # TODO make test local
30 uri = "https://social.heldscal.la/user/23211"
32 {:ok, user} = OStatus.find_or_make_user(uri)
34 user = Repo.get(Pleroma.User, user.id)
35 assert user.name == "Constance Variable"
36 assert user.nickname == "lambadalambda@social.heldscal.la"
37 assert user.local == false
38 assert user.info["uri"] == uri
39 assert user.ap_id == uri
41 {:ok, user_again} = OStatus.find_or_make_user(uri)
43 assert user == user_again
47 describe "gathering user info from a user id" do
48 test "it returns user info in a hash" do
49 user = "shp@social.heldscal.la"
51 # TODO: make test local
52 {:ok, data} = OStatus.gather_user_info(user)
55 hub: "https://social.heldscal.la/main/push/hub",
56 magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
59 salmon: "https://social.heldscal.la/main/salmon/user/29191",
60 subject: "acct:shp@social.heldscal.la",
61 topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
62 uri: "https://social.heldscal.la/user/29191",
63 host: "social.heldscal.la",
66 assert data == expected
69 test "it works with the uri" do
70 user = "https://social.heldscal.la/user/29191"
72 # TODO: make test local
73 {:ok, data} = OStatus.gather_user_info(user)
76 hub: "https://social.heldscal.la/main/push/hub",
77 magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
80 salmon: "https://social.heldscal.la/main/salmon/user/29191",
81 subject: "https://social.heldscal.la/user/29191",
82 topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
83 uri: "https://social.heldscal.la/user/29191",
84 host: "social.heldscal.la",
87 assert data == expected