From 34d3aea92f1bce7ba51a44ef1fdc68e47822c3a4 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 24 Apr 2017 18:46:02 +0200 Subject: Add incoming xml fixtures. --- test/fixtures/incoming_note_activity.xml | 40 ++++++++++++++++++++++++++++++++ test/fixtures/user_full.xml | 10 ++++++++ test/fixtures/user_name_only.xml | 5 ++++ 3 files changed, 55 insertions(+) create mode 100644 test/fixtures/incoming_note_activity.xml create mode 100644 test/fixtures/user_full.xml create mode 100644 test/fixtures/user_name_only.xml (limited to 'test') diff --git a/test/fixtures/incoming_note_activity.xml b/test/fixtures/incoming_note_activity.xml new file mode 100644 index 000000000..e54b25e39 --- /dev/null +++ b/test/fixtures/incoming_note_activity.xml @@ -0,0 +1,40 @@ + + http://activitystrea.ms/schema/1.0/note + tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note + New note by lambda + @<a href="http://pleroma.example.org:4000/users/lain3" class="h-card mention">lain3</a> + + + http://activitystrea.ms/schema/1.0/post + 2017-04-23T14:51:03+00:00 + 2017-04-23T14:51:03+00:00 + + http://activitystrea.ms/schema/1.0/person + http://gs.example.org:4040/index.php/user/1 + lambda + + + + + lambda + lambda + + + + + tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b + + + + http://gs.example.org:4040/index.php/api/statuses/user_timeline/1.atom + lambda + + + + http://gs.example.org:4040/theme/neo-gnu/default-avatar-profile.png + 2017-04-23T14:51:03+00:00 + + + + + diff --git a/test/fixtures/user_full.xml b/test/fixtures/user_full.xml new file mode 100644 index 000000000..8eee8c686 --- /dev/null +++ b/test/fixtures/user_full.xml @@ -0,0 +1,10 @@ + + http://activitystrea.ms/schema/1.0/person + http://gs.example.org:4040/index.php/user/1 + lambda + + + + Constance Variable + lambadalambda + diff --git a/test/fixtures/user_name_only.xml b/test/fixtures/user_name_only.xml new file mode 100644 index 000000000..6d895d5c2 --- /dev/null +++ b/test/fixtures/user_name_only.xml @@ -0,0 +1,5 @@ + + http://activitystrea.ms/schema/1.0/person + http://gs.example.org:4040/index.php/user/1 + lambda + -- cgit v1.2.3 From ab0114fbaabd28d1e1a6961f6bfbd683f3e7fbbc Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 24 Apr 2017 18:46:34 +0200 Subject: Return salmon path for users, basic incoming salmon handling. --- test/web/ostatus/feed_representer_test.exs | 1 + test/web/ostatus/ostatus_test.exs | 53 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/web/ostatus/ostatus_test.exs (limited to 'test') diff --git a/test/web/ostatus/feed_representer_test.exs b/test/web/ostatus/feed_representer_test.exs index 9a02d8c16..13cdeb79d 100644 --- a/test/web/ostatus/feed_representer_test.exs +++ b/test/web/ostatus/feed_representer_test.exs @@ -27,6 +27,7 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do #{user.nickname}'s timeline #{most_recent_update} + #{user_xml} diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs new file mode 100644 index 000000000..8ee605494 --- /dev/null +++ b/test/web/ostatus/ostatus_test.exs @@ -0,0 +1,53 @@ +defmodule Pleroma.Web.OStatusTest do + use Pleroma.DataCase + alias Pleroma.Web.OStatus + + test "handle incoming notes" do + incoming = File.read!("test/fixtures/incoming_note_activity.xml") + {:ok, activity} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Create" + assert activity.data["object"]["type"] == "Note" + assert activity.data["published"] == "2017-04-23T14:51:03+00:00" + end + + describe "new remote user creation" do + test "make new user or find them based on an 'author' xml doc" do + incoming = File.read!("test/fixtures/user_name_only.xml") + {doc, _rest} = :xmerl_scan.string(to_charlist(incoming)) + + {:ok, user} = OStatus.find_or_make_user(doc) + + assert user.name == "lambda" + assert user.nickname == "lambda" + assert user.local == false + assert user.info["ostatus_uri"] == "http://gs.example.org:4040/index.php/user/1" + assert user.info["system"] == "ostatus" + assert user.ap_id == "http://gs.example.org:4040/index.php/user/1" + + {:ok, user_again} = OStatus.find_or_make_user(doc) + + assert user == user_again + end + + test "tries to use the information in poco fields" do + incoming = File.read!("test/fixtures/user_full.xml") + {doc, _rest} = :xmerl_scan.string(to_charlist(incoming)) + + {:ok, user} = OStatus.find_or_make_user(doc) + + assert user.name == "Constance Variable" + assert user.nickname == "lambadalambda" + assert user.local == false + assert user.info["ostatus_uri"] == "http://gs.example.org:4040/index.php/user/1" + assert user.info["system"] == "ostatus" + assert user.ap_id == "http://gs.example.org:4040/index.php/user/1" + + assert List.first(user.avatar["url"])["href"] == "http://gs.example.org:4040/theme/neo-gnu/default-avatar-profile.png" + + {:ok, user_again} = OStatus.find_or_make_user(doc) + + assert user == user_again + end + end +end -- cgit v1.2.3 From b438ea24ee936ae10efdcd3c9079e3b45ae521f4 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 25 Apr 2017 17:45:34 +0200 Subject: Add ostatus conversation as context. --- test/web/ostatus/ostatus_test.exs | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 8ee605494..61dca5446 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -9,6 +9,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["type"] == "Create" assert activity.data["object"]["type"] == "Note" assert activity.data["published"] == "2017-04-23T14:51:03+00:00" + assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b" end describe "new remote user creation" do -- cgit v1.2.3 From f980f6778b1447b808299fa9274854bb25f9823b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 25 Apr 2017 18:03:14 +0200 Subject: Wire up mentions. --- test/web/ostatus/ostatus_test.exs | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 61dca5446..dffebf5a7 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -10,6 +10,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["type"] == "Note" assert activity.data["published"] == "2017-04-23T14:51:03+00:00" assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b" + assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"] end describe "new remote user creation" do -- cgit v1.2.3 From b91ccef2371fb0bbc23638b174e815dd7189482e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 26 Apr 2017 08:47:22 +0200 Subject: Output conversation id. --- test/support/factory.ex | 6 ++++-- test/web/ostatus/activity_representer_test.exs | 2 ++ test/web/ostatus/feed_representer_test.exs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/support/factory.ex b/test/support/factory.ex index d7c16f0e0..d037be4a6 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -24,7 +24,8 @@ defmodule Pleroma.Factory do "to" => ["https://www.w3.org/ns/activitystreams#Public"], "published_at" => DateTime.utc_now() |> DateTime.to_iso8601, "likes" => [], - "like_count" => 0 + "like_count" => 0, + "context" => "2hu" } %Pleroma.Object{ @@ -40,7 +41,8 @@ defmodule Pleroma.Factory do "actor" => note.data["actor"], "to" => note.data["to"], "object" => note.data, - "published_at" => DateTime.utc_now() |> DateTime.to_iso8601 + "published_at" => DateTime.utc_now() |> DateTime.to_iso8601, + "context" => note.data["context"] } %Pleroma.Activity{ diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 61df41a1d..10f9a9d0b 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -23,6 +23,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{note_activity.data["object"]["content"]} #{inserted_at} #{updated_at} + #{note_activity.data["context"]} + """ tuple = ActivityRepresenter.to_simple_form(note_activity, user) diff --git a/test/web/ostatus/feed_representer_test.exs b/test/web/ostatus/feed_representer_test.exs index 13cdeb79d..ef0f4d5ff 100644 --- a/test/web/ostatus/feed_representer_test.exs +++ b/test/web/ostatus/feed_representer_test.exs @@ -22,7 +22,7 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do |> :xmerl.export_simple_content(:xmerl_xml) expected = """ - + #{OStatus.feed_path(user)} #{user.nickname}'s timeline #{most_recent_update} -- cgit v1.2.3 From d9ebd785ab7d9b371ba5accdc6ca5d72af7b509d Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 26 Apr 2017 10:08:13 +0200 Subject: Ostatus doesn't distinguish between activities / objects on create. --- test/web/ostatus/activity_representer_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 10f9a9d0b..6cea9cff0 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -18,7 +18,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do expected = """ http://activitystrea.ms/schema/1.0/note http://activitystrea.ms/schema/1.0/post - #{note_activity.data["object"]["id"]} + #{note_activity.data["id"]} New note by #{user.nickname} #{note_activity.data["object"]["content"]} #{inserted_at} -- cgit v1.2.3 From f1ebf812eede5b77931d2315757a7ad8e0ea5a7e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 26 Apr 2017 10:22:51 +0200 Subject: Add inReplyTo to incoming messages. --- test/fixtures/incoming_note_activity_answer.xml | 42 +++++++++++++++++++++++++ test/web/ostatus/ostatus_test.exs | 10 ++++++ 2 files changed, 52 insertions(+) create mode 100644 test/fixtures/incoming_note_activity_answer.xml (limited to 'test') diff --git a/test/fixtures/incoming_note_activity_answer.xml b/test/fixtures/incoming_note_activity_answer.xml new file mode 100644 index 000000000..b1244faa6 --- /dev/null +++ b/test/fixtures/incoming_note_activity_answer.xml @@ -0,0 +1,42 @@ + + http://activitystrea.ms/schema/1.0/note + tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note + New note by lambda + hey. + + + http://activitystrea.ms/schema/1.0/post + 2017-04-25T18:16:13+00:00 + 2017-04-25T18:16:13+00:00 + + http://activitystrea.ms/schema/1.0/person + http://gs.example.org:4040/index.php/user/1 + lambda + + + + + lambda + lambda + + + + + + + http://pleroma.example.org:4000/contexts/8f6f45d4-8e4d-4e1a-a2de-09f27367d2d0 + + + + http://gs.example.org:4040/index.php/api/statuses/user_timeline/1.atom + lambda + + + + http://gs.example.org:4040/theme/neo-gnu/default-avatar-profile.png + 2017-04-25T18:16:13+00:00 + + + + + diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index dffebf5a7..96f2cb4f3 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -13,6 +13,16 @@ defmodule Pleroma.Web.OStatusTest do assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"] end + test "handle incoming replies" do + incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml") + {:ok, activity} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Create" + assert activity.data["object"]["type"] == "Note" + assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc" + assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"] + end + describe "new remote user creation" do test "make new user or find them based on an 'author' xml doc" do incoming = File.read!("test/fixtures/user_name_only.xml") -- cgit v1.2.3 From 57bd59e4071adf847f94229479e5ffa0951721fd Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 26 Apr 2017 14:25:44 +0200 Subject: Salmon creation. --- test/fixtures/private_key.pem | 27 +++++++++++++++++++++++++++ test/web/salmon/salmon_test.exs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/fixtures/private_key.pem (limited to 'test') diff --git a/test/fixtures/private_key.pem b/test/fixtures/private_key.pem new file mode 100644 index 000000000..7a4b14654 --- /dev/null +++ b/test/fixtures/private_key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAqnWeDtrqWasCKNXiuSq1tSCLI5H7BSvIROy5YfuGsXHrIlCq +LdIm9QlIUUmIi9QyzgiGEDsPCCkA1UguCVgF/UrJ1+FvHcHsTELkkBu/yCl9mrgt +WzTckhb6KjOhqtxi/TKgRaJ2Rlwz2bvH5sbCP9qffthitdxfh14KC5V0gqDt1xCy +WgZo79vbYMcVkcQoh5uLtG64ksYFBMfgnLaSj7xg5i2qCDiIY7bqBujo5HllDqeo +w3LXmsztt1cT8heXEjW0SYJvAHJK00OsG1kp4cqhfKzxLCHNGQJVHQxLOXy97I7o +HOeuhbxPhjpGSBMgw7YFm3ODXviqf557eqFcaQIDAQABAoIBAC6f+VnK22sncXHF +/zvyyL0AZ86U8XpanW7s6VA5wn/qzwwV0Fa0Mt+3aEaDvIuywSrF/hWWcegjfwzX +r2/y2cCMomUgTopvLrk1WttoG68eWjLlydI2xVZYXpkIgmH/4juri1dAtuVL9wrJ +aEZhe2SH4jSJ74Ya/y5BtLGycaoA9FHyIzHPTx52Ix2jWKWtKimW8J+aERi2uHdN +7yTnLT2APhs5fnvNnn0tg85CI3Ny2GNiqmAail14yVfRz8Sf6qDIepH5Jfz9oll4 +I+GYUOLs6eTgkHXBn8LGhtHTE/9UJmb42OyWrW8X+nc/Mjz5xh0u/g1Gdp36oUMz +OotfneECgYEA3cGfQxmxjEqSbXt9jbxiCukU7PmkDDQqBu97URC4N8qEcMF1wW7X +AddU7Kq/UJU+oqjD/7UQHoS2ZThPtto6SpVdXQzsnrnPWQcrv5b1DV/TpXfwGoZ3 +svUIAcx4vGzhhmHDJCBsdY6n8xWBYtSqfLFXgN5UkdafLGy3EkCEtmUCgYEAxMgl +7eU2QkWkzgJxOj6xjG2yqM3jxOvvoiRnD0rIQaBS70P/1N94ZkMXzOwddddZ5OW+ +55h/a8TmFKP/+NW4PHRYra/dazGI4IBlw6Yeq6uq/4jbuSqtBbaNn/Dz5kdHBTqM +PtbBvc9Fztd2zb3InyyLbb4c+WjMqi0AooN027UCgYB4Tax7GJtLwsEBiDcrB4Ig +7SYfEae/vyT1skIyTmHCUqnbCfk6QUl/hDRcWJ2FuBHM6MW8GZxvEgxpiU0lo+pv +v+xwqKxNx/wHDm7bd6fl45DMee7WVRDnEyuO3kC56E/JOYxGMxjkBcpzg703wqvj +Dcqs7PDwVYDw9uGykzHsSQKBgEQnNcvA+RvW1w9qlSChGgkS7S+9r0dCl8pGZVNM +iTMBfffUS0TE6QQx9IpKtKFdpoq6b3XywR7oIO/BJSRfkOGPQi9Vm5BGpatrjNNI +M5Mtb5n1InRtLWOvKDnez/pPcW+EKZKR+qPsp7bNtR3ovxUx7lBh6dMP0uKVl4Sx +lsWJAoGBAIeek9eG+S3m2jaJRHasfKo5mJ2JrrmnjQXUOGUP8/CgO8sW1VmG2WAk +Av7+BRI2mP2f+3SswG/AoRGmRXXw65ly63ws8ixrhK0MG3MgqDkWc69SbTaaMJ+u +BQFYMsB1vZdUV3CaRqySkjY68QWGcJ4Z5JKHuTXzKv/GeFmw0V9R +-----END RSA PRIVATE KEY----- diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index 4ebb32081..6fbabd19f 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -16,4 +16,37 @@ defmodule Pleroma.Web.Salmon.SalmonTest do {:ok, salmon} = File.read("test/fixtures/salmon.xml") assert Salmon.decode_and_validate(@wrong_magickey, salmon) == :error end + + test "generates an RSA private key pem" do + {:ok, key} = Salmon.generate_rsa_pem + assert is_binary(key) + assert Regex.match?(~r/RSA/, key) + end + + test "it encodes a magic key from a public key" do + key = Salmon.decode_key(@magickey) + magic_key = Salmon.encode_key(key) + + assert @magickey == magic_key + end + + test "returns a public and private key from a pem" do + pem = File.read!("test/fixtures/private_key.pem") + {:ok, private, public} = Salmon.keys_from_pem(pem) + + assert elem(private, 0) == :RSAPrivateKey + assert elem(public, 0) == :RSAPublicKey + end + + test "encodes an xml payload with a private key" do + doc = File.read!("test/fixtures/incoming_note_activity.xml") + pem = File.read!("test/fixtures/private_key.pem") + {:ok, private, public} = Salmon.keys_from_pem(pem) + + # Let's try a roundtrip. + {:ok, salmon} = Salmon.encode(private, doc) + {:ok, decoded_doc} = Salmon.decode_and_validate(Salmon.encode_key(public), salmon) + + assert doc == decoded_doc + end end -- cgit v1.2.3 From c5fa682c317717c64168bf2d77b28d805ffff450 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 26 Apr 2017 18:33:10 +0200 Subject: Refactor, add beginnings of websub client subscriptions. --- test/web/websub/websub_test.exs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 334ba03fc..7b77e696b 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -58,7 +58,6 @@ defmodule Pleroma.Web.WebsubTest do "hub.lease_seconds" => "100" } - {:ok, subscription } = Websub.incoming_subscription_request(user, data) assert subscription.topic == Pleroma.Web.OStatus.feed_path(user) assert subscription.state == "requested" @@ -87,4 +86,15 @@ defmodule Pleroma.Web.WebsubTest do assert length(Repo.all(WebsubServerSubscription)) == 1 assert subscription.id == sub.id end + + test "initiate a subscription for a given user and topic" do + user = insert(:user) + topic = "http://example.org/some-topic.atom" + + {:ok, websub} = Websub.subscribe(user, topic) + assert websub.subscribers == [user.ap_id] + assert websub.topic == topic + assert is_binary(websub.secret) + assert websub.state == "accepted" + end end -- cgit v1.2.3 From d1dce56a85e041f78e1d50900a0c9591610de2b9 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 27 Apr 2017 09:43:58 +0200 Subject: Refactor XML parsing. --- test/web/ostatus/ostatus_test.exs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 96f2cb4f3..140b32f36 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -1,6 +1,7 @@ defmodule Pleroma.Web.OStatusTest do use Pleroma.DataCase alias Pleroma.Web.OStatus + alias Pleroma.Web.XML test "handle incoming notes" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") @@ -26,7 +27,7 @@ defmodule Pleroma.Web.OStatusTest do describe "new remote user creation" do test "make new user or find them based on an 'author' xml doc" do incoming = File.read!("test/fixtures/user_name_only.xml") - {doc, _rest} = :xmerl_scan.string(to_charlist(incoming)) + doc = XML.parse_document(incoming) {:ok, user} = OStatus.find_or_make_user(doc) @@ -44,7 +45,7 @@ defmodule Pleroma.Web.OStatusTest do test "tries to use the information in poco fields" do incoming = File.read!("test/fixtures/user_full.xml") - {doc, _rest} = :xmerl_scan.string(to_charlist(incoming)) + doc = XML.parse_document(incoming) {:ok, user} = OStatus.find_or_make_user(doc) -- cgit v1.2.3 From 1ea4325fecaed981b2f949b00d3b37171013012c Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 27 Apr 2017 09:46:04 +0200 Subject: Add user feed fixture. --- test/fixtures/lambadalambda.atom | 479 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 479 insertions(+) create mode 100644 test/fixtures/lambadalambda.atom (limited to 'test') diff --git a/test/fixtures/lambadalambda.atom b/test/fixtures/lambadalambda.atom new file mode 100644 index 000000000..35e506420 --- /dev/null +++ b/test/fixtures/lambadalambda.atom @@ -0,0 +1,479 @@ + + + https://mastodon.social/users/lambadalambda.atom + Critical Value + + 2017-04-16T21:47:25Z + https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244 + + https://mastodon.social/users/lambadalambda + http://activitystrea.ms/schema/1.0/person + https://mastodon.social/users/lambadalambda + lambadalambda + lambadalambda@mastodon.social + + + + + lambadalambda + Critical Value + public + + + + + + + + tag:mastodon.social,2017-04-07:objectId=1874242:objectType=Status + 2017-04-07T11:02:56Z + 2017-04-07T11:02:56Z + lambadalambda shared a status by 0xroy@social.wxcafe.net + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + tag:social.wxcafe.net,2017-04-07:objectId=72554:objectType=Status + 2017-04-07T11:01:59Z + 2017-04-07T11:02:00Z + New status by 0xroy@social.wxcafe.net + + https://social.wxcafe.net/users/0xroy + http://activitystrea.ms/schema/1.0/person + https://social.wxcafe.net/users/0xroy + 0xroy + 0xroy@social.wxcafe.net + ta caution weeb | discussions privées : <a href="https://💌.0xroy.me" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="">💌.0xroy.me</span><span class="invisible"></span></a> + + + + 0xroy + 「R O Y 🍵 B O S」 + ta caution weeb | discussions privées : <a href="https://%F0%9F%92%8C.0xroy.me" rel="nofollow noopener"><span class="invisible">https://</span><span class="">💌.0xroy.me</span><span class="invisible"></span></a> + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p>someone pls eli5 matrix (protocol) and riot</p> + + public + + + <p>someone pls eli5 matrix (protocol) and riot</p> + + public + + + + + tag:mastodon.social,2017-04-06:objectId=1768247:objectType=Status + 2017-04-06T11:10:19Z + 2017-04-06T11:10:19Z + lambadalambda shared a status by areyoutoo@mastodon.xyz + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + tag:mastodon.xyz,2017-04-05:objectId=133327:objectType=Status + 2017-04-05T17:36:41Z + 2017-04-05T18:12:14Z + New status by areyoutoo@mastodon.xyz + + https://mastodon.xyz/users/areyoutoo + http://activitystrea.ms/schema/1.0/person + https://mastodon.xyz/users/areyoutoo + areyoutoo + areyoutoo@mastodon.xyz + devops | retired gamedev | always boost puppy pics + + + + areyoutoo + Raw Butter + devops | retired gamedev | always boost puppy pics + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p>Some UX thoughts for <a href="https://mastodon.xyz/tags/mastodev" class="mention hashtag">#<span>mastodev</span></a>:</p><p>- Would be nice if I could work on multiple draft toots? Clicking to reply to someone seems to erase any draft I had been working on.</p><p>- Kinda risky to click on the Federated Timeline if it loads new toots and scrolls 10ms before I click on something.</p><p>I probably don't know enough web frontend to help, but it might be fun to try.</p> + + + public + + + <p>Some UX thoughts for <a href="https://mastodon.xyz/tags/mastodev" class="mention hashtag">#<span>mastodev</span></a>:</p><p>- Would be nice if I could work on multiple draft toots? Clicking to reply to someone seems to erase any draft I had been working on.</p><p>- Kinda risky to click on the Federated Timeline if it loads new toots and scrolls 10ms before I click on something.</p><p>I probably don't know enough web frontend to help, but it might be fun to try.</p> + + public + + + + + tag:mastodon.social,2017-04-06:objectId=1764509:objectType=Status + 2017-04-06T10:15:38Z + 2017-04-06T10:15:38Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + This is a test for cw federation + <p>This is a test for cw federation body text.</p> + + public + + + + + tag:mastodon.social,2017-04-05:objectId=1645208:objectType=Status + 2017-04-05T07:14:53Z + 2017-04-05T07:14:53Z + lambadalambda shared a status by lambadalambda@social.heldscal.la + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + tag:social.heldscal.la,2017-04-05:noticeId=1502088:objectType=note + 2017-04-05T06:12:09Z + 2017-04-05T07:12:47Z + New status by lambadalambda@social.heldscal.la + + https://social.heldscal.la/user/23211 + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + lambadalambda@social.heldscal.la + Call me Deacon Blues. + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + Federation 101: <a href="https://www.youtube.com/watch?v=t1lYU5CA40o" rel="nofollow external noreferrer" class="attachment thumbnail">https://www.youtube.com/watch?v=t1lYU5CA40o</a> + + public + + + Federation 101: <a href="https://www.youtube.com/watch?v=t1lYU5CA40o" rel="nofollow external noreferrer" class="attachment thumbnail">https://www.youtube.com/watch?v=t1lYU5CA40o</a> + + public + + + + + tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status + 2017-04-05T05:44:48Z + 2017-04-05T05:44:48Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> just a test.</p> + + + public + + + + + tag:mastodon.social,2017-04-04:objectId=1540149:objectType=Status + 2017-04-04T06:31:09Z + 2017-04-04T06:31:09Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p>Looks like you still can&apos;t delete your account here (PRIVACY!), but I won&apos;t be posting here anymore, my main account is <span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span></p> + + + public + + + + + tag:mastodon.social,2017-04-04:objectId=1539608:objectType=Status + 2017-04-04T06:18:16Z + 2017-04-04T06:18:16Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@ghostbar" class="u-url mention">@<span>ghostbar</span></a></span> Remember to rewrite it in Rust once you&apos;re done.</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1504813:objectType=Status + 2017-04-03T18:01:20Z + 2017-04-03T18:01:20Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.xyz/@Azurolu" class="u-url mention">@<span>Azurolu</span></a></span> You mean gs.smuglo.li?</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1504805:objectType=Status + 2017-04-03T18:01:05Z + 2017-04-03T18:01:05Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p>There&apos;s nothing wrong with having several alt accounts all across the fediverse. Try out another mastodon instance (<a href="https://icosahedron.website" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="">icosahedron.website</span><span class="invisible"></span></a>) or a GNU Social instance (like <a href="https://shitposter.club" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="">shitposter.club</span><span class="invisible"></span></a> or <a href="https://freezepeach.xyz" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="">freezepeach.xyz</span><span class="invisible"></span></a>), or friendica. They are all on the same network, so you can still follow all your friends!</p> + + public + + + + + tag:mastodon.social,2017-04-03:objectId=1503965:objectType=Status + 2017-04-03T17:31:30Z + 2017-04-03T17:31:30Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@20Hz" class="u-url mention">@<span>20Hz</span></a></span> you could also try out a GS instance, which are on the same network :)</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1503955:objectType=Status + 2017-04-03T17:31:08Z + 2017-04-03T17:31:08Z + lambadalambda shared a status by shpuld@shitposter.club + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + tag:shitposter.club,2017-04-03:noticeId=2251717:objectType=note + 2017-04-03T17:06:43Z + 2017-04-03T17:12:06Z + New status by shpuld@shitposter.club + + https://shitposter.club/user/5381 + http://activitystrea.ms/schema/1.0/person + https://shitposter.club/user/5381 + shpuld + shpuld@shitposter.club + + + + + shpuld + shp + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + reposting the classic <a href="https://shitposter.club/file/89c5fe483526caf3a46cfc5cdd4ae68061054350e767397731af658d54786e31.jpg" class="attachment" rel="nofollow external">https://shitposter.club/attachment/219846</a> + + + public + + + reposting the classic <a href="https://shitposter.club/file/89c5fe483526caf3a46cfc5cdd4ae68061054350e767397731af658d54786e31.jpg" class="attachment" rel="nofollow external">https://shitposter.club/attachment/219846</a> + + public + + + + + tag:mastodon.social,2017-04-03:objectId=1503929:objectType=Status + 2017-04-03T17:30:43Z + 2017-04-03T17:30:43Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@ghostbar" class="u-url mention">@<span>ghostbar</span></a></span> Normally you shouldn&apos;t be running tens of thousands of users on one instance... That&apos;s one of the reasons for federation.</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1477255:objectType=Status + 2017-04-03T08:24:39Z + 2017-04-03T08:24:39Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@dot_tiff" class="u-url mention">@<span>dot_tiff</span></a></span> it&apos;s the vaporwave mode.</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1476210:objectType=Status + 2017-04-03T07:45:42Z + 2017-04-03T07:45:42Z + lambadalambda shared a status by lambadalambda@social.heldscal.la + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + tag:social.heldscal.la,2017-04-03:noticeId=1475727:objectType=note + 2017-04-03T07:44:43Z + 2017-04-03T07:44:48Z + New status by lambadalambda@social.heldscal.la + + https://social.heldscal.la/user/23211 + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + lambadalambda@social.heldscal.la + Call me Deacon Blues. + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + Here's a song by the original anti-idol, Togawa Jun: <a href="https://www.youtube.com/watch?v=kNI_NK2YY-s" rel="nofollow external noreferrer" class="attachment">https://www.youtube.com/watch?v=kNI_NK2YY-s</a> + + public + + + Here's a song by the original anti-idol, Togawa Jun: <a href="https://www.youtube.com/watch?v=kNI_NK2YY-s" rel="nofollow external noreferrer" class="attachment">https://www.youtube.com/watch?v=kNI_NK2YY-s</a> + + public + + + + + tag:mastodon.social,2017-04-03:objectId=1476047:objectType=Status + 2017-04-03T07:39:14Z + 2017-04-03T07:39:14Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@amrrr" class="u-url mention">@<span>amrrr</span></a></span> tumblr/10, but pretty good!</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1475949:objectType=Status + 2017-04-03T07:35:45Z + 2017-04-03T07:35:45Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@Shookaite" class="u-url mention">@<span>Shookaite</span></a></span> Oh, you mean like userstyles?</p> + + + public + + + + + + tag:mastodon.social,2017-04-03:objectId=1475581:objectType=Status + 2017-04-03T07:20:03Z + 2017-04-03T07:20:03Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@Shookaite" class="u-url mention">@<span>Shookaite</span></a></span> Would be nice if someone helped port Pleroma to Mastodon, that has a theme switcher (click on the cog in the upper right): <a href="https://pleroma.heldscal.la/main/all" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="">pleroma.heldscal.la/main/all</span><span class="invisible"></span></a></p> + + + public + + + + + + tag:mastodon.social,2017-04-02:objectId=1457325:objectType=Status + 2017-04-02T21:57:43Z + 2017-04-02T21:57:43Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://mastodon.social/@rhosyn" class="u-url mention">@<span>rhosyn</span></a></span> <span class="h-card"><a href="https://mastodon.social/@Meaningness" class="u-url mention">@<span>Meaningness</span></a></span> you could take a look at those listed at social.guhnoo.org</p> + + + + public + + + + + + tag:mastodon.social,2017-04-02:objectId=1447926:objectType=Status + 2017-04-02T18:31:52Z + 2017-04-02T18:31:52Z + New status by lambadalambda + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + <p>My main account is <span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> , btw.</p> + + + public + + + + + tag:mastodon.social,2017-04-02:objectId=1447878:objectType=Status + 2017-04-02T18:30:37Z + 2017-04-02T18:30:37Z + lambadalambda shared a status by Firstaide@awoo.space + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + tag:awoo.space,2017-04-02:objectId=135324:objectType=Status + 2017-04-02T18:29:32Z + 2017-04-02T18:29:32Z + New status by Firstaide@awoo.space + + https://awoo.space/users/Firstaide + http://activitystrea.ms/schema/1.0/person + https://awoo.space/users/Firstaide + Firstaide + Firstaide@awoo.space + A smol awoo account, for a smol autistic 💙 +They/them please! +NB/white/ace + + + + Firstaide + Miff🚑✨ + A smol awoo account, for a smol autistic 💙 +They/them please! +NB/white/ace + public + + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><a href="https://mastodon.social/users/lambadalambda" class="h-card u-url p-nickname mention">@<span>lambadalambda</span></a> yeah, I think that's p much the big issue here? <br>When I first heard of Masto, I thought it was just like twitter at first, I had no idea federation was even a thing?, and I actually joined p early on? :-o </p><p>idk I think more stuff needs to be done about federation promotion, but honestly its gotta come from the get go when people get here to make an account I feel :-o</p> + + + public + + + + <p><a href="https://mastodon.social/users/lambadalambda" class="h-card u-url p-nickname mention">@<span>lambadalambda</span></a> yeah, I think that's p much the big issue here? <br>When I first heard of Masto, I thought it was just like twitter at first, I had no idea federation was even a thing?, and I actually joined p early on? :-o </p><p>idk I think more stuff needs to be done about federation promotion, but honestly its gotta come from the get go when people get here to make an account I feel :-o</p> + + public + + + + -- cgit v1.2.3 From 90da25505f9cfbd16a9088e20714b24c2c6fa215 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 27 Apr 2017 09:46:45 +0200 Subject: Add discovery and subscription requests to websub. --- test/support/factory.ex | 10 +++++++ test/web/websub/websub_test.exs | 61 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/support/factory.ex b/test/support/factory.ex index d037be4a6..ac276567a 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -76,4 +76,14 @@ defmodule Pleroma.Factory do state: "requested" } end + + def websub_client_subscription_factory do + %Pleroma.Web.Websub.WebsubClientSubscription{ + topic: "http://example.org", + secret: "here's a secret", + valid_until: nil, + state: "requested", + subscribers: [] + } + end end diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 7b77e696b..bf243ac91 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -77,7 +77,6 @@ defmodule Pleroma.Web.WebsubTest do "hub.lease_seconds" => "100" } - {:ok, subscription } = Websub.incoming_subscription_request(user, data) assert subscription.topic == Pleroma.Web.OStatus.feed_path(user) assert subscription.state == sub.state @@ -87,14 +86,72 @@ defmodule Pleroma.Web.WebsubTest do assert subscription.id == sub.id end + def accepting_verifier(subscription) do + {:ok, %{ subscription | state: "accepted" }} + end + test "initiate a subscription for a given user and topic" do user = insert(:user) topic = "http://example.org/some-topic.atom" - {:ok, websub} = Websub.subscribe(user, topic) + {:ok, websub} = Websub.subscribe(user, topic, &accepting_verifier/1) assert websub.subscribers == [user.ap_id] assert websub.topic == topic assert is_binary(websub.secret) + assert websub.user == user assert websub.state == "accepted" end + + test "discovers the hub and canonical url" do + topic = "https://mastodon.social/users/lambadalambda.atom" + + getter = fn(^topic) -> + doc = File.read!("test/fixtures/lambadalambda.atom") + {:ok, %{status_code: 200, body: doc}} + end + + {:ok, discovered} = Websub.discover(topic, getter) + assert %{hub: "https://mastodon.social/api/push", url: topic} == discovered + end + + test "calls the hub, requests topic" do + hub = "https://social.heldscal.la/main/push/hub" + topic = "https://social.heldscal.la/api/statuses/user_timeline/23211.atom" + websub = insert(:websub_client_subscription, %{hub: hub, topic: topic}) + + poster = fn (^hub, {:form, data}, _headers) -> + assert Keyword.get(data, :"hub.mode") == "subscribe" + {:ok, %{status_code: 202}} + end + + task = Task.async(fn -> Websub.request_subscription(websub, poster) end) + + change = Ecto.Changeset.change(websub, %{state: "accepted"}) + {:ok, _} = Repo.update(change) + + {:ok, websub} = Task.await(task) + + assert websub.state == "accepted" + end + + test "rejects the subscription if it can't be accepted" do + hub = "https://social.heldscal.la/main/push/hub" + topic = "https://social.heldscal.la/api/statuses/user_timeline/23211.atom" + websub = insert(:websub_client_subscription, %{hub: hub, topic: topic}) + + poster = fn (^hub, {:form, _data}, _headers) -> + {:ok, %{status_code: 202}} + end + + {:error, websub} = Websub.request_subscription(websub, poster, 1000) + assert websub.state == "rejected" + + websub = insert(:websub_client_subscription, %{hub: hub, topic: topic}) + poster = fn (^hub, {:form, _data}, _headers) -> + {:ok, %{status_code: 400}} + end + + {:error, websub} = Websub.request_subscription(websub, poster, 1000) + assert websub.state == "rejected" + end end -- cgit v1.2.3 From 451d18af63fcf97f0d9621e5bfe296e1f18a0312 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 28 Apr 2017 09:51:47 +0200 Subject: Add proper callback route for websub confirmation. --- test/web/websub/websub_test.exs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index bf243ac91..ca04a55cd 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -3,11 +3,13 @@ defmodule Pleroma.Web.WebsubMock do {:ok, sub} end end + defmodule Pleroma.Web.WebsubTest do use Pleroma.DataCase alias Pleroma.Web.Websub alias Pleroma.Web.Websub.WebsubServerSubscription import Pleroma.Factory + alias Pleroma.Web.Router.Helpers test "a verification of a request that is accepted" do sub = insert(:websub_subscription) @@ -121,6 +123,7 @@ defmodule Pleroma.Web.WebsubTest do poster = fn (^hub, {:form, data}, _headers) -> assert Keyword.get(data, :"hub.mode") == "subscribe" + assert Keyword.get(data, :"hub.callback") == Helpers.websub_url(Pleroma.Web.Endpoint, :websub_subscription_confirmation, websub.id) {:ok, %{status_code: 202}} end -- cgit v1.2.3 From 1422e7aa84a897c6026e9dcd26b7d5955050687a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 28 Apr 2017 15:45:10 +0200 Subject: Handle incoming websub subscriptions. --- test/web/websub/websub_controller_test.exs | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'test') diff --git a/test/web/websub/websub_controller_test.exs b/test/web/websub/websub_controller_test.exs index 8368cafea..521bbb9aa 100644 --- a/test/web/websub/websub_controller_test.exs +++ b/test/web/websub/websub_controller_test.exs @@ -1,6 +1,9 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do use Pleroma.Web.ConnCase import Pleroma.Factory + alias Pleroma.Web.Websub.WebsubClientSubscription + alias Pleroma.{Repo, Activity} + alias Pleroma.Web.Websub test "websub subscription request", %{conn: conn} do user = insert(:user) @@ -20,4 +23,60 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do assert response(conn, 202) == "Accepted" end + + test "websub subscription confirmation", %{conn: conn} do + websub = insert(:websub_client_subscription) + + params = %{ + "hub.mode" => "subscribe", + "hub.topic" => websub.topic, + "hub.challenge" => "some challenge", + "hub.lease_seconds" => 100 + } + + conn = conn + |> get("/push/subscriptions/#{websub.id}", params) + + websub = Repo.get(WebsubClientSubscription, websub.id) + + assert response(conn, 200) == "some challenge" + assert websub.state == "accepted" + end + + test "handles incoming feed updates", %{conn: conn} do + websub = insert(:websub_client_subscription) + doc = "some stuff" + signature = Websub.sign(websub.secret, doc) + + conn = conn + |> put_req_header("x-hub-signature", "sha1=" <> signature) + |> put_req_header("content-type", "application/atom+xml") + |> post("/push/subscriptions/#{websub.id}", doc) + + assert response(conn, 200) == "OK" + + assert length(Repo.all(Activity)) == 1 + end + + test "rejects incoming feed updates with the wrong signature", %{conn: conn} do + websub = insert(:websub_client_subscription) + doc = "some stuff" + signature = Websub.sign("wrong secret", doc) + + conn = conn + |> put_req_header("x-hub-signature", "sha1=" <> signature) + |> put_req_header("content-type", "application/atom+xml") + |> post("/push/subscriptions/#{websub.id}", doc) + + assert response(conn, 500) == "Error" + + assert length(Repo.all(Activity)) == 0 + end +end + +defmodule Pleroma.Web.OStatusMock do + import Pleroma.Factory + def handle_incoming(_doc) do + insert(:note_activity) + end end -- cgit v1.2.3 From ca40dda04c114c32ca9ecfe5f998a083448a189c Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 28 Apr 2017 17:41:12 +0200 Subject: Add some basic webfingering. --- test/fixtures/webfinger.xml | 20 ++++++++++++++++++++ test/web/web_finger/web_finger_test.exs | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/webfinger.xml (limited to 'test') diff --git a/test/fixtures/webfinger.xml b/test/fixtures/webfinger.xml new file mode 100644 index 000000000..4cde42e3f --- /dev/null +++ b/test/fixtures/webfinger.xml @@ -0,0 +1,20 @@ + + + acct:shp@social.heldscal.la + https://social.heldscal.la/user/29191 + https://social.heldscal.la/shp + https://social.heldscal.la/index.php/user/29191 + https://social.heldscal.la/index.php/shp + + + + + + + + + + + + + diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index 8a3007ff9..e5347a2b0 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -1,11 +1,29 @@ defmodule Pleroma.Web.WebFingerTest do use Pleroma.DataCase + alias Pleroma.Web.WebFinger describe "host meta" do test "returns a link to the xml lrdd" do - host_info = Pleroma.Web.WebFinger.host_meta + host_info = WebFinger.host_meta() assert String.contains?(host_info, Pleroma.Web.base_url) end end + + describe "fingering" do + test "returns the info for a user" do + user = "shp@social.heldscal.la" + + getter = fn(_url, _headers, [params: [resource: ^user]]) -> + {:ok, %{status_code: 200, body: File.read!("test/fixtures/webfinger.xml")}} + end + + {:ok, data} = WebFinger.finger(user, getter) + + assert data.magic_key == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB" + assert data.topic == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom" + assert data.subject == "acct:shp@social.heldscal.la" + assert data.salmon == "https://social.heldscal.la/main/salmon/user/29191" + end + end end -- cgit v1.2.3 From 69922bc724736fb07bf36beaef42d944158d9269 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 29 Apr 2017 17:51:59 +0200 Subject: Add user info gathering. --- test/web/ostatus/ostatus_test.exs | 22 ++++++++++++++++++++++ test/web/websub/websub_test.exs | 11 +++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 140b32f36..2a5156b31 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -63,4 +63,26 @@ defmodule Pleroma.Web.OStatusTest do assert user == user_again end end + + describe "gathering user info from a user id" do + test "it returns user info in a hash" do + user = "shp@social.heldscal.la" + + # TODO: make test local + {:ok, data} = OStatus.gather_user_info(user) + + expected = %{ + hub: "https://social.heldscal.la/main/push/hub", + magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB", + name: "shp", + nickname: "shp", + salmon: "https://social.heldscal.la/main/salmon/user/29191", + subject: "acct:shp@social.heldscal.la", + topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", + uri: "https://social.heldscal.la/user/29191", + fqn: user + } + assert data == expected + end + end end diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index ca04a55cd..1b1ef3fa6 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -112,8 +112,15 @@ defmodule Pleroma.Web.WebsubTest do {:ok, %{status_code: 200, body: doc}} end - {:ok, discovered} = Websub.discover(topic, getter) - assert %{hub: "https://mastodon.social/api/push", url: topic} == discovered + {:ok, discovered} = Websub.gather_feed_data(topic, getter) + expected = %{ + hub: "https://mastodon.social/api/push", + uri: "https://mastodon.social/users/lambadalambda", + nickname: "lambadalambda", + name: "Critical Value" + } + + assert expected == discovered end test "calls the hub, requests topic" do -- cgit v1.2.3 From 427bac0966c551eb16eaa6595d99fc5361a32ea9 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 29 Apr 2017 19:06:01 +0200 Subject: Rework remote user subscription. --- test/web/ostatus/ostatus_test.exs | 54 +++++++++++++++++++-------------------- test/web/websub/websub_test.exs | 11 ++++---- 2 files changed, 33 insertions(+), 32 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 2a5156b31..4f396d940 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -25,40 +25,20 @@ defmodule Pleroma.Web.OStatusTest do end describe "new remote user creation" do - test "make new user or find them based on an 'author' xml doc" do - incoming = File.read!("test/fixtures/user_name_only.xml") - doc = XML.parse_document(incoming) - - {:ok, user} = OStatus.find_or_make_user(doc) - - assert user.name == "lambda" - assert user.nickname == "lambda" - assert user.local == false - assert user.info["ostatus_uri"] == "http://gs.example.org:4040/index.php/user/1" - assert user.info["system"] == "ostatus" - assert user.ap_id == "http://gs.example.org:4040/index.php/user/1" - - {:ok, user_again} = OStatus.find_or_make_user(doc) - - assert user == user_again - end - test "tries to use the information in poco fields" do - incoming = File.read!("test/fixtures/user_full.xml") - doc = XML.parse_document(incoming) + # TODO make test local + uri = "https://social.heldscal.la/user/23211" - {:ok, user} = OStatus.find_or_make_user(doc) + {:ok, user} = OStatus.find_or_make_user(uri) + user = Repo.get(Pleroma.User, user.id) assert user.name == "Constance Variable" assert user.nickname == "lambadalambda" assert user.local == false - assert user.info["ostatus_uri"] == "http://gs.example.org:4040/index.php/user/1" - assert user.info["system"] == "ostatus" - assert user.ap_id == "http://gs.example.org:4040/index.php/user/1" - - assert List.first(user.avatar["url"])["href"] == "http://gs.example.org:4040/theme/neo-gnu/default-avatar-profile.png" + assert user.info["uri"] == uri + assert user.ap_id == uri - {:ok, user_again} = OStatus.find_or_make_user(doc) + {:ok, user_again} = OStatus.find_or_make_user(uri) assert user == user_again end @@ -84,5 +64,25 @@ defmodule Pleroma.Web.OStatusTest do } assert data == expected end + + test "it works with the uri" do + user = "https://social.heldscal.la/user/29191" + + # TODO: make test local + {:ok, data} = OStatus.gather_user_info(user) + + expected = %{ + hub: "https://social.heldscal.la/main/push/hub", + magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB", + name: "shp", + nickname: "shp", + salmon: "https://social.heldscal.la/main/salmon/user/29191", + subject: "https://social.heldscal.la/user/29191", + topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", + uri: "https://social.heldscal.la/user/29191", + fqn: user + } + assert data == expected + end end end diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 1b1ef3fa6..25c2b8baa 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -93,12 +93,13 @@ defmodule Pleroma.Web.WebsubTest do end test "initiate a subscription for a given user and topic" do - user = insert(:user) - topic = "http://example.org/some-topic.atom" + subscriber = insert(:user) + user = insert(:user, %{info: %{ "topic" => "some_topic", "hub" => "some_hub"}}) - {:ok, websub} = Websub.subscribe(user, topic, &accepting_verifier/1) - assert websub.subscribers == [user.ap_id] - assert websub.topic == topic + {:ok, websub} = Websub.subscribe(subscriber, user, &accepting_verifier/1) + assert websub.subscribers == [subscriber.ap_id] + assert websub.topic == "some_topic" + assert websub.hub == "some_hub" assert is_binary(websub.secret) assert websub.user == user assert websub.state == "accepted" -- cgit v1.2.3 From ba1ea770012893ea818f248e9a0a2ee3ab854676 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 29 Apr 2017 19:47:56 +0200 Subject: Make key fetching use ostatus fetching. --- test/fixtures/salmon2.xml | 2 ++ test/web/salmon/salmon_test.exs | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 test/fixtures/salmon2.xml (limited to 'test') diff --git a/test/fixtures/salmon2.xml b/test/fixtures/salmon2.xml new file mode 100644 index 000000000..d8ecbc17e --- /dev/null +++ b/test/fixtures/salmon2.xml @@ -0,0 +1,2 @@ + +PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8-PGVudHJ5IHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDA1L0F0b20iIHhtbG5zOnRocj0iaHR0cDovL3B1cmwub3JnL3N5bmRpY2F0aW9uL3RocmVhZC8xLjAiIHhtbG5zOmFjdGl2aXR5PSJodHRwOi8vYWN0aXZpdHlzdHJlYS5tcy9zcGVjLzEuMC8iIHhtbG5zOmdlb3Jzcz0iaHR0cDovL3d3dy5nZW9yc3Mub3JnL2dlb3JzcyIgeG1sbnM6b3N0YXR1cz0iaHR0cDovL29zdGF0dXMub3JnL3NjaGVtYS8xLjAiIHhtbG5zOnBvY289Imh0dHA6Ly9wb3J0YWJsZWNvbnRhY3RzLm5ldC9zcGVjLzEuMCIgeG1sbnM6bWVkaWE9Imh0dHA6Ly9wdXJsLm9yZy9zeW5kaWNhdGlvbi9hdG9tbWVkaWEiIHhtbG5zOnN0YXR1c25ldD0iaHR0cDovL3N0YXR1cy5uZXQvc2NoZW1hL2FwaS8xLyI-CiA8YWN0aXZpdHk6b2JqZWN0LXR5cGU-aHR0cDovL2FjdGl2aXR5c3RyZWEubXMvc2NoZW1hLzEuMC9ub3RlPC9hY3Rpdml0eTpvYmplY3QtdHlwZT4KIDxpZD50YWc6c29jaWFsLmhlbGRzY2FsLmxhLDIwMTctMDQtMjk6bm90aWNlSWQ9MTk2NzEwNjpvYmplY3RUeXBlPW5vdGU8L2lkPgogPHRpdGxlPk5ldyBub3RlIGJ5IGxhbWJhZGFsYW1iZGE8L3RpdGxlPgogPGNvbnRlbnQgdHlwZT0iaHRtbCI-dGVzdCBAJmx0O2EgaHJlZj0mcXVvdDtodHRwczovL3BsZXJvbWEuc295a2FmLmNvbS91c2Vycy9sYWluJnF1b3Q7IGNsYXNzPSZxdW90O2gtY2FyZCB1LXVybCBwLW5pY2tuYW1lIG1lbnRpb24mcXVvdDsmZ3Q7bGFpbiZsdDsvYSZndDs8L2NvbnRlbnQ-CiA8bGluayByZWw9ImFsdGVybmF0ZSIgdHlwZT0idGV4dC9odG1sIiBocmVmPSJodHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9ub3RpY2UvMTk2NzEwNiIvPgogPHN0YXR1c19uZXQgbm90aWNlX2lkPSIxOTY3MTA2Ij48L3N0YXR1c19uZXQ-CiA8YWN0aXZpdHk6dmVyYj5odHRwOi8vYWN0aXZpdHlzdHJlYS5tcy9zY2hlbWEvMS4wL3Bvc3Q8L2FjdGl2aXR5OnZlcmI-CiA8cHVibGlzaGVkPjIwMTctMDQtMjlUMTc6Mjg6MjErMDA6MDA8L3B1Ymxpc2hlZD4KIDx1cGRhdGVkPjIwMTctMDQtMjlUMTc6Mjg6MjErMDA6MDA8L3VwZGF0ZWQ-CiA8YXV0aG9yPgogIDxhY3Rpdml0eTpvYmplY3QtdHlwZT5odHRwOi8vYWN0aXZpdHlzdHJlYS5tcy9zY2hlbWEvMS4wL3BlcnNvbjwvYWN0aXZpdHk6b2JqZWN0LXR5cGU-CiAgPHVyaT5odHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS91c2VyLzIzMjExPC91cmk-CiAgPG5hbWU-bGFtYmFkYWxhbWJkYTwvbmFtZT4KICA8c3VtbWFyeT5DYWxsIG1lIERlYWNvbiBCbHVlcy48L3N1bW1hcnk-CiAgPGxpbmsgcmVsPSJhbHRlcm5hdGUiIHR5cGU9InRleHQvaHRtbCIgaHJlZj0iaHR0cHM6Ly9zb2NpYWwuaGVsZHNjYWwubGEvbGFtYmFkYWxhbWJkYSIvPgogIDxsaW5rIHJlbD0iYXZhdGFyIiB0eXBlPSJpbWFnZS9qcGVnIiBtZWRpYTp3aWR0aD0iMjM2IiBtZWRpYTpoZWlnaHQ9IjIzNiIgaHJlZj0iaHR0cHM6Ly9zb2NpYWwuaGVsZHNjYWwubGEvYXZhdGFyLzIzMjExLW9yaWdpbmFsLTIwMTcwNDE2MTE0MjU1LmpwZWciLz4KICA8bGluayByZWw9ImF2YXRhciIgdHlwZT0iaW1hZ2UvanBlZyIgbWVkaWE6d2lkdGg9Ijk2IiBtZWRpYTpoZWlnaHQ9Ijk2IiBocmVmPSJodHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9hdmF0YXIvMjMyMTEtOTYtMjAxNzA0MTYxMTQyNTUuanBlZyIvPgogIDxsaW5rIHJlbD0iYXZhdGFyIiB0eXBlPSJpbWFnZS9qcGVnIiBtZWRpYTp3aWR0aD0iNDgiIG1lZGlhOmhlaWdodD0iNDgiIGhyZWY9Imh0dHBzOi8vc29jaWFsLmhlbGRzY2FsLmxhL2F2YXRhci8yMzIxMS00OC0yMDE3MDQxNjExNDI1NS5qcGVnIi8-CiAgPGxpbmsgcmVsPSJhdmF0YXIiIHR5cGU9ImltYWdlL2pwZWciIG1lZGlhOndpZHRoPSIyNCIgbWVkaWE6aGVpZ2h0PSIyNCIgaHJlZj0iaHR0cHM6Ly9zb2NpYWwuaGVsZHNjYWwubGEvYXZhdGFyLzIzMjExLTI0LTIwMTcwNDE2MTE0MjU3LmpwZWciLz4KICA8cG9jbzpwcmVmZXJyZWRVc2VybmFtZT5sYW1iYWRhbGFtYmRhPC9wb2NvOnByZWZlcnJlZFVzZXJuYW1lPgogIDxwb2NvOmRpc3BsYXlOYW1lPkNvbnN0YW5jZSBWYXJpYWJsZTwvcG9jbzpkaXNwbGF5TmFtZT4KICA8cG9jbzpub3RlPkNhbGwgbWUgRGVhY29uIEJsdWVzLjwvcG9jbzpub3RlPgogIDxwb2NvOmFkZHJlc3M-CiAgIDxwb2NvOmZvcm1hdHRlZD5CZXJsaW48L3BvY286Zm9ybWF0dGVkPgogIDwvcG9jbzphZGRyZXNzPgogIDxwb2NvOnVybHM-CiAgIDxwb2NvOnR5cGU-aG9tZXBhZ2U8L3BvY286dHlwZT4KICAgPHBvY286dmFsdWU-aHR0cHM6Ly9oZWxkc2NhbC5sYTwvcG9jbzp2YWx1ZT4KICAgPHBvY286cHJpbWFyeT50cnVlPC9wb2NvOnByaW1hcnk-CiAgPC9wb2NvOnVybHM-CiAgPGZvbGxvd2VycyB1cmw9Imh0dHBzOi8vc29jaWFsLmhlbGRzY2FsLmxhL2xhbWJhZGFsYW1iZGEvc3Vic2NyaWJlcnMiPjwvZm9sbG93ZXJzPgogIDxzdGF0dXNuZXQ6cHJvZmlsZV9pbmZvIGxvY2FsX2lkPSIyMzIxMSI-PC9zdGF0dXNuZXQ6cHJvZmlsZV9pbmZvPgogPC9hdXRob3I-CiA8bGluayByZWw9Im9zdGF0dXM6Y29udmVyc2F0aW9uIiBocmVmPSJodHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9jb252ZXJzYXRpb24vMTAwNzQ5NiIvPgogPG9zdGF0dXM6Y29udmVyc2F0aW9uIGhyZWY9Imh0dHBzOi8vc29jaWFsLmhlbGRzY2FsLmxhL2NvbnZlcnNhdGlvbi8xMDA3NDk2IiBsb2NhbF9pZD0iMTAwNzQ5NiIgcmVmPSJ0YWc6c29jaWFsLmhlbGRzY2FsLmxhLDIwMTctMDQtMjk6b2JqZWN0VHlwZT10aHJlYWQ6bm9uY2U9NDU5ZGYyMjM2NDFiMDNkZSI-dGFnOnNvY2lhbC5oZWxkc2NhbC5sYSwyMDE3LTA0LTI5Om9iamVjdFR5cGU9dGhyZWFkOm5vbmNlPTQ1OWRmMjIzNjQxYjAzZGU8L29zdGF0dXM6Y29udmVyc2F0aW9uPgogPGxpbmsgcmVsPSJtZW50aW9uZWQiIG9zdGF0dXM6b2JqZWN0LXR5cGU9Imh0dHA6Ly9hY3Rpdml0eXN0cmVhLm1zL3NjaGVtYS8xLjAvcGVyc29uIiBocmVmPSJodHRwczovL3BsZXJvbWEuc295a2FmLmNvbS91c2Vycy9sYWluIi8-CiA8bGluayByZWw9Im1lbnRpb25lZCIgb3N0YXR1czpvYmplY3QtdHlwZT0iaHR0cDovL2FjdGl2aXR5c3RyZWEubXMvc2NoZW1hLzEuMC9jb2xsZWN0aW9uIiBocmVmPSJodHRwOi8vYWN0aXZpdHlzY2hlbWEub3JnL2NvbGxlY3Rpb24vcHVibGljIi8-CiA8c291cmNlPgogIDxpZD5odHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9hcGkvc3RhdHVzZXMvdXNlcl90aW1lbGluZS8yMzIxMS5hdG9tPC9pZD4KICA8dGl0bGU-Q29uc3RhbmNlIFZhcmlhYmxlPC90aXRsZT4KICA8bGluayByZWw9ImFsdGVybmF0ZSIgdHlwZT0idGV4dC9odG1sIiBocmVmPSJodHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9sYW1iYWRhbGFtYmRhIi8-CiAgPGxpbmsgcmVsPSJzZWxmIiB0eXBlPSJhcHBsaWNhdGlvbi9hdG9tK3htbCIgaHJlZj0iaHR0cHM6Ly9zb2NpYWwuaGVsZHNjYWwubGEvYXBpL3N0YXR1c2VzL3VzZXJfdGltZWxpbmUvMjMyMTEuYXRvbSIvPgogIDxsaW5rIHJlbD0ibGljZW5zZSIgaHJlZj0iaHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LzMuMC8iLz4KICA8aWNvbj5odHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9hdmF0YXIvMjMyMTEtOTYtMjAxNzA0MTYxMTQyNTUuanBlZzwvaWNvbj4KICA8dXBkYXRlZD4yMDE3LTA0LTI5VDE3OjI4OjIxKzAwOjAwPC91cGRhdGVkPgogPC9zb3VyY2U-CiA8bGluayByZWw9InNlbGYiIHR5cGU9ImFwcGxpY2F0aW9uL2F0b20reG1sIiBocmVmPSJodHRwczovL3NvY2lhbC5oZWxkc2NhbC5sYS9hcGkvc3RhdHVzZXMvc2hvdy8xOTY3MTA2LmF0b20iLz4KIDxsaW5rIHJlbD0iZWRpdCIgdHlwZT0iYXBwbGljYXRpb24vYXRvbSt4bWwiIGhyZWY9Imh0dHBzOi8vc29jaWFsLmhlbGRzY2FsLmxhL2FwaS9zdGF0dXNlcy9zaG93LzE5NjcxMDYuYXRvbSIvPgogPHN0YXR1c25ldDpub3RpY2VfaW5mbyBsb2NhbF9pZD0iMTk2NzEwNiIgc291cmNlPSJQbGVyb21hIEZFIj48L3N0YXR1c25ldDpub3RpY2VfaW5mbz4KPC9lbnRyeT4Kbase64urlRSA-SHA256CJ3wiWW9Io6Y24To3PFBF8cGuvJG8ps5zEwu1k1kSAlSX7WcysvS4ZoPKICFrD4brJxMLpW3AQCLNPIa246-Y0noGiNdpj0w0_TWgWXukWo50pD7cWVugr15YCMUtC-v00iDYfZTlmrTVM6kSCcpAmGMbZPTaXVmKZryjTDoXSI= \ No newline at end of file diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index 6fbabd19f..aa77659d0 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -49,4 +49,12 @@ defmodule Pleroma.Web.Salmon.SalmonTest do assert doc == decoded_doc end + + test "it gets a magic key" do + # TODO: Make test local + salmon = File.read!("test/fixtures/salmon2.xml") + key = Salmon.fetch_magic_key(salmon) + + assert key == "RSA.uzg6r1peZU0vXGADWxGJ0PE34WvmhjUmydbX5YYdOiXfODVLwCMi1umGoqUDm-mRu4vNEdFBVJU1CpFA7dKzWgIsqsa501i2XqElmEveXRLvNRWFB6nG03Q5OUY2as8eE54BJm0p20GkMfIJGwP6TSFb-ICp3QjzbatuSPJ6xCE=.AQAB" + end end -- cgit v1.2.3 From 20015b4b67cf0dfab6bdb658c9eb0e1ae04febdc Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 29 Apr 2017 20:08:45 +0200 Subject: Save remote users with fqn as nickname. --- test/web/ostatus/ostatus_test.exs | 4 +++- test/web/websub/websub_test.exs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 4f396d940..cc0975bb5 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -33,7 +33,7 @@ defmodule Pleroma.Web.OStatusTest do user = Repo.get(Pleroma.User, user.id) assert user.name == "Constance Variable" - assert user.nickname == "lambadalambda" + assert user.nickname == "lambadalambda@social.heldscal.la" assert user.local == false assert user.info["uri"] == uri assert user.ap_id == uri @@ -60,6 +60,7 @@ defmodule Pleroma.Web.OStatusTest do subject: "acct:shp@social.heldscal.la", topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", uri: "https://social.heldscal.la/user/29191", + host: "social.heldscal.la", fqn: user } assert data == expected @@ -80,6 +81,7 @@ defmodule Pleroma.Web.OStatusTest do subject: "https://social.heldscal.la/user/29191", topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", uri: "https://social.heldscal.la/user/29191", + host: "social.heldscal.la", fqn: user } assert data == expected diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 25c2b8baa..e0d71e16d 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -118,7 +118,8 @@ defmodule Pleroma.Web.WebsubTest do hub: "https://mastodon.social/api/push", uri: "https://mastodon.social/users/lambadalambda", nickname: "lambadalambda", - name: "Critical Value" + name: "Critical Value", + host: "mastodon.social" } assert expected == discovered -- cgit v1.2.3 From a16da387d251edc4d1bae949146c807d217cee1f Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 29 Apr 2017 21:13:21 +0200 Subject: Handle full incoming feeds. --- test/fixtures/ostatus_incoming_post.xml | 57 ++++++++++++++++++++++++++++++ test/web/ostatus/ostatus_test.exs | 17 ++++++--- test/web/websub/websub_controller_test.exs | 2 ++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/ostatus_incoming_post.xml (limited to 'test') diff --git a/test/fixtures/ostatus_incoming_post.xml b/test/fixtures/ostatus_incoming_post.xml new file mode 100644 index 000000000..7967e1b32 --- /dev/null +++ b/test/fixtures/ostatus_incoming_post.xml @@ -0,0 +1,57 @@ + + + GNU social + https://social.heldscal.la/api/statuses/user_timeline/23211.atom + lambadalambda timeline + Updates from lambadalambda on social.heldscal.la! + https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg + 2017-04-29T18:25:38+00:00 + + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + Call me Deacon Blues. + + + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + + Berlin + + + homepage + https://heldscal.la + true + + + + + + + + + + + + + http://activitystrea.ms/schema/1.0/note + tag:social.heldscal.la,2017-04-29:noticeId=1967725:objectType=note + New note by lambadalambda + Will it blend? + + + http://activitystrea.ms/schema/1.0/post + 2017-04-29T18:25:38+00:00 + 2017-04-29T18:25:38+00:00 + + tag:social.heldscal.la,2017-04-29:objectType=thread:nonce=3f3a9dd83acc4e35 + + + + + + diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index cc0975bb5..1e747c728 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -1,11 +1,10 @@ defmodule Pleroma.Web.OStatusTest do use Pleroma.DataCase alias Pleroma.Web.OStatus - alias Pleroma.Web.XML - test "handle incoming notes" do + test "handle incoming note - GS, Salmon" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") - {:ok, activity} = OStatus.handle_incoming(incoming) + {:ok, [activity]} = OStatus.handle_incoming(incoming) assert activity.data["type"] == "Create" assert activity.data["object"]["type"] == "Note" @@ -14,9 +13,19 @@ defmodule Pleroma.Web.OStatusTest do assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"] end + test "handle incoming notes - GS, subscription" do + incoming = File.read!("test/fixtures/ostatus_incoming_post.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Create" + assert activity.data["object"]["type"] == "Note" + assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"]["content"] == "Will it blend?" + end + test "handle incoming replies" do incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml") - {:ok, activity} = OStatus.handle_incoming(incoming) + {:ok, [activity]} = OStatus.handle_incoming(incoming) assert activity.data["type"] == "Create" assert activity.data["object"]["type"] == "Note" diff --git a/test/web/websub/websub_controller_test.exs b/test/web/websub/websub_controller_test.exs index 521bbb9aa..8f68248a4 100644 --- a/test/web/websub/websub_controller_test.exs +++ b/test/web/websub/websub_controller_test.exs @@ -41,6 +41,8 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do assert response(conn, 200) == "some challenge" assert websub.state == "accepted" + + # TODO valid_until end test "handles incoming feed updates", %{conn: conn} do -- cgit v1.2.3 From 8a0d2b33d8c9a1cef347c5daf5589a2245eb01b0 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 09:25:46 +0200 Subject: Keep ostatus id as activity id. --- test/web/ostatus/ostatus_test.exs | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 1e747c728..a53e0ebde 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Web.OStatusTest do {:ok, [activity]} = OStatus.handle_incoming(incoming) assert activity.data["type"] == "Create" + assert activity.data["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note" assert activity.data["object"]["type"] == "Note" assert activity.data["published"] == "2017-04-23T14:51:03+00:00" assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b" -- cgit v1.2.3 From 9d7c3190cc346bf2a5576b6b93c26723059ae9a1 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 11:16:41 +0200 Subject: Get create activity from created object id. This is useful for Ostatus federation because ostatus doesn't have different ids for objects and activities... --- test/activity_test.exs | 7 +++++++ test/web/ostatus/feed_representer_test.exs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/activity_test.exs b/test/activity_test.exs index ce6eb1545..366a2f957 100644 --- a/test/activity_test.exs +++ b/test/activity_test.exs @@ -15,4 +15,11 @@ defmodule Pleroma.ActivityTest do assert activity == found_activity end + + test "returns the activity that created an object" do + activity = insert(:note_activity) + found_activity = Pleroma.Activity.get_create_activity_by_object_ap_id(activity.data["object"]["id"]) + + assert activity == found_activity + end end diff --git a/test/web/ostatus/feed_representer_test.exs b/test/web/ostatus/feed_representer_test.exs index ef0f4d5ff..7bbfae49a 100644 --- a/test/web/ostatus/feed_representer_test.exs +++ b/test/web/ostatus/feed_representer_test.exs @@ -22,7 +22,7 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do |> :xmerl.export_simple_content(:xmerl_xml) expected = """ - + #{OStatus.feed_path(user)} #{user.nickname}'s timeline #{most_recent_update} -- cgit v1.2.3 From d937a8e69567ace33a72d5248c046860305076d7 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 11:17:34 +0200 Subject: Add thr:in-reply-to to ostatus representer. --- test/web/ostatus/activity_representer_test.exs | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 6cea9cff0..fd1b1598c 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -34,6 +34,42 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do assert clean(res) == clean(expected) end + test "a reply note" do + note = insert(:note_activity) + answer = insert(:note_activity) + object = answer.data["object"] + object = Map.put(object, "inReplyTo", note.data["object"]["id"]) + + data = %{answer.data | "object" => object} + answer = %{answer | data: data} + + updated_at = answer.updated_at + |> NaiveDateTime.to_iso8601 + inserted_at = answer.inserted_at + |> NaiveDateTime.to_iso8601 + + user = User.get_cached_by_ap_id(answer.data["actor"]) + + expected = """ + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + #{answer.data["id"]} + New note by #{user.nickname} + #{answer.data["object"]["content"]} + #{inserted_at} + #{updated_at} + #{answer.data["context"]} + + + """ + + tuple = ActivityRepresenter.to_simple_form(answer, user) + + res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary + + assert clean(res) == clean(expected) + end + test "an unknown activity" do tuple = ActivityRepresenter.to_simple_form(%Activity{}, nil) assert is_nil(tuple) -- cgit v1.2.3 From 84027ff00b7fc63934f12129f84b5c7ee1d39248 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 11:39:27 +0200 Subject: Handle comments. --- test/fixtures/ostatus_incoming_reply.xml | 60 ++++++++++++++++++++++++++++++++ test/web/ostatus/ostatus_test.exs | 11 ++++++ 2 files changed, 71 insertions(+) create mode 100644 test/fixtures/ostatus_incoming_reply.xml (limited to 'test') diff --git a/test/fixtures/ostatus_incoming_reply.xml b/test/fixtures/ostatus_incoming_reply.xml new file mode 100644 index 000000000..83a427a68 --- /dev/null +++ b/test/fixtures/ostatus_incoming_reply.xml @@ -0,0 +1,60 @@ + + + GNU social + https://social.heldscal.la/api/statuses/user_timeline/23211.atom + lambadalambda timeline + Updates from lambadalambda on social.heldscal.la! + https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg + 2017-04-30T09:30:32+00:00 + + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + Call me Deacon Blues. + + + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + + Berlin + + + homepage + https://heldscal.la + true + + + + + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:social.heldscal.la,2017-04-30:noticeId=1978790:objectType=comment + New comment by lambadalambda + @<a href="https://gs.archae.me/user/4687" class="h-card u-url p-nickname mention" title="shpbot">shpbot</a> why not indeed. + + + http://activitystrea.ms/schema/1.0/post + 2017-04-30T09:30:32+00:00 + 2017-04-30T09:30:32+00:00 + + + + https://gs.archae.me/conversation/327120 + + + + + + + diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index a53e0ebde..5452e5888 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -24,6 +24,17 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["content"] == "Will it blend?" end + test "handle incoming notes - GS, subscription, reply" do + incoming = File.read!("test/fixtures/ostatus_incoming_reply.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Create" + assert activity.data["object"]["type"] == "Note" + assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"]["content"] == "@shpbot why not indeed." + assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note" + end + test "handle incoming replies" do incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) -- cgit v1.2.3 From 62607f37dcf3ab149baa09fe144959a25322be69 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 11:55:19 +0200 Subject: Federate object id for posts in ostatus. This is because ostatus doens't have an id for the activities. --- test/web/ostatus/activity_representer_test.exs | 6 +++--- test/web/ostatus/ostatus_test.exs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index fd1b1598c..6344889b1 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -18,7 +18,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do expected = """ http://activitystrea.ms/schema/1.0/note http://activitystrea.ms/schema/1.0/post - #{note_activity.data["id"]} + #{note_activity.data["object"]["id"]} New note by #{user.nickname} #{note_activity.data["object"]["content"]} #{inserted_at} @@ -53,14 +53,14 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do expected = """ http://activitystrea.ms/schema/1.0/note http://activitystrea.ms/schema/1.0/post - #{answer.data["id"]} + #{answer.data["object"]["id"]} New note by #{user.nickname} #{answer.data["object"]["content"]} #{inserted_at} #{updated_at} #{answer.data["context"]} - + """ tuple = ActivityRepresenter.to_simple_form(answer, user) diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 5452e5888..3edd39911 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -7,8 +7,8 @@ defmodule Pleroma.Web.OStatusTest do {:ok, [activity]} = OStatus.handle_incoming(incoming) assert activity.data["type"] == "Create" - assert activity.data["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note" assert activity.data["object"]["type"] == "Note" + assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note" assert activity.data["published"] == "2017-04-23T14:51:03+00:00" assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b" assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"] -- cgit v1.2.3 From 18edc299b262974d3acb9d6f9c3758629b2c0968 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 12:36:47 +0200 Subject: Handle duplicates. --- test/web/ostatus/ostatus_test.exs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 3edd39911..07073a40d 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -2,6 +2,12 @@ defmodule Pleroma.Web.OStatusTest do use Pleroma.DataCase alias Pleroma.Web.OStatus + test "don't insert create notes twice" do + incoming = File.read!("test/fixtures/incoming_note_activity.xml") + {:ok, [_activity]} = OStatus.handle_incoming(incoming) + assert {:ok, [{:error, "duplicate activity"}]} == OStatus.handle_incoming(incoming) + end + test "handle incoming note - GS, Salmon" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) -- cgit v1.2.3 From f9912599c4688a8609bd3500e0548eb2bf06c4a9 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 12:53:49 +0200 Subject: Pull in remote avatar on federation. --- test/web/ostatus/ostatus_test.exs | 7 +++++-- test/web/websub/websub_test.exs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 07073a40d..4e7e401cd 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -64,6 +64,7 @@ defmodule Pleroma.Web.OStatusTest do assert user.local == false assert user.info["uri"] == uri assert user.ap_id == uri + assert user.avatar["type"] == "Image" {:ok, user_again} = OStatus.find_or_make_user(uri) @@ -88,7 +89,8 @@ defmodule Pleroma.Web.OStatusTest do topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", uri: "https://social.heldscal.la/user/29191", host: "social.heldscal.la", - fqn: user + fqn: user, + avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} } assert data == expected end @@ -109,7 +111,8 @@ defmodule Pleroma.Web.OStatusTest do topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", uri: "https://social.heldscal.la/user/29191", host: "social.heldscal.la", - fqn: user + fqn: user, + avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} } assert data == expected end diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index e0d71e16d..ad312cd25 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -119,7 +119,8 @@ defmodule Pleroma.Web.WebsubTest do uri: "https://mastodon.social/users/lambadalambda", nickname: "lambadalambda", name: "Critical Value", - host: "mastodon.social" + host: "mastodon.social", + avatar: %{"type" => "Image", "url" => [%{"href" => "https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244", "mediaType" => "image/gif", "type" => "Link"}]} } assert expected == discovered -- cgit v1.2.3 From 4c8111c3342aa57cf38accf64f0aa06be6958704 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 13:53:26 +0200 Subject: Use conversation mapping objects to get / retrieve context from TwAPI. --- .../representers/activity_representer_test.exs | 11 +++++--- .../twitter_api/twitter_api_controller_test.exs | 7 +++-- test/web/twitter_api/twitter_api_test.exs | 32 ++++++++++++++++++++-- 3 files changed, 40 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index d0cccb149..64e7f0641 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -69,6 +69,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do content = HtmlSanitizeEx.strip_tags(content_html) date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601 + {:ok, convo_object} = Object.context_mapping("2hu") |> Repo.insert + activity = %Activity{ id: 1, data: %{ @@ -84,14 +86,15 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "type" => "Note", "content" => content_html, "inReplyToStatusId" => 213123, - "statusnetConversationId" => 4711, "attachment" => [ object ], "like_count" => 5, - "announcement_count" => 3 + "announcement_count" => 3, + "context" => "2hu" }, - "published" => date + "published" => date, + "context" => "2hu" } } @@ -106,7 +109,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "is_post_verb" => true, "created_at" => "Tue May 24 13:26:08 +0000 2016", "in_reply_to_status_id" => 213123, - "statusnet_conversation_id" => 4711, + "statusnet_conversation_id" => convo_object.id, "attachments" => [ ObjectRepresenter.to_map(object) ], diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 6c249be7d..05cd084b4 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -84,12 +84,13 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do describe "GET /statusnet/conversation/:id.json" do test "returns the statuses in the conversation", %{conn: conn} do {:ok, _user} = UserBuilder.insert - {:ok, _activity} = ActivityBuilder.insert(%{"statusnetConversationId" => 1, "context" => "2hu"}) - {:ok, _activity_two} = ActivityBuilder.insert(%{"statusnetConversationId" => 1,"context" => "2hu"}) + {:ok, _activity} = ActivityBuilder.insert(%{"context" => "2hu"}) + {:ok, _activity_two} = ActivityBuilder.insert(%{"context" => "2hu"}) {:ok, _activity_three} = ActivityBuilder.insert(%{"context" => "3hu"}) + {:ok, object} = Object.context_mapping("2hu") |> Repo.insert conn = conn - |> get("/api/statusnet/conversation/1.json") + |> get("/api/statusnet/conversation/#{object.id}.json") response = json_response(conn, 200) diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 590428423..720011257 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -201,11 +201,13 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do test "fetch statuses in a context using the conversation id" do {:ok, user} = UserBuilder.insert() - {:ok, activity} = ActivityBuilder.insert(%{"statusnetConversationId" => 1, "context" => "2hu"}) - {:ok, activity_two} = ActivityBuilder.insert(%{"statusnetConversationId" => 1,"context" => "2hu"}) + {:ok, activity} = ActivityBuilder.insert(%{"context" => "2hu"}) + {:ok, activity_two} = ActivityBuilder.insert(%{"context" => "2hu"}) {:ok, _activity_three} = ActivityBuilder.insert(%{"context" => "3hu"}) - statuses = TwitterAPI.fetch_conversation(user, 1) + {:ok, object} = Object.context_mapping("2hu") |> Repo.insert + + statuses = TwitterAPI.fetch_conversation(user, object.id) assert length(statuses) == 2 assert Enum.at(statuses, 0)["id"] == activity.id @@ -314,9 +316,33 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do refute Repo.get_by(User, nickname: "lain") end + test "it assigns an integer conversation_id" do + note_activity = insert(:note_activity) + user = User.get_cached_by_ap_id(note_activity.data["actor"]) + status = ActivityRepresenter.to_map(note_activity, %{user: user}) + + assert is_number(status["statusnet_conversation_id"]) + end + setup do Supervisor.terminate_child(Pleroma.Supervisor, Cachex) Supervisor.restart_child(Pleroma.Supervisor, Cachex) :ok end + + describe "context_to_conversation_id" do + test "creates a mapping object" do + conversation_id = TwitterAPI.context_to_conversation_id("random context") + object = Object.get_by_ap_id("random context") + + assert conversation_id == object.id + end + + test "returns an existing mapping for an existing object" do + {:ok, object} = Object.context_mapping("random context") |> Repo.insert + conversation_id = TwitterAPI.context_to_conversation_id("random context") + + assert conversation_id == object.id + end + end end -- cgit v1.2.3 From 009fcd2acfdc3ae3ba4b706eb71c50015227de50 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 14:02:04 +0200 Subject: Stop adding statusnetConversationIds. --- test/web/twitter_api/twitter_api_test.exs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 720011257..eb061d334 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -41,11 +41,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public") assert Enum.member?(get_in(activity.data, ["to"]), "shp") - # Add a context + 'statusnet_conversation_id' + # Add a context assert is_binary(get_in(activity.data, ["context"])) assert is_binary(get_in(activity.data, ["object", "context"])) - assert get_in(activity.data, ["object", "statusnetConversationId"]) == activity.id - assert get_in(activity.data, ["statusnetConversationId"]) == activity.id assert is_list(activity.data["object"]["attachment"]) -- cgit v1.2.3 From 09f7ed421497e12797f30ae34e0f2346f1b6a428 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 14:26:29 +0200 Subject: Don't set statusnetConversationIds on replies anymore. --- test/web/twitter_api/twitter_api_test.exs | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index eb061d334..207d9d12a 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -67,8 +67,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"]) assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"]) - assert get_in(reply.data, ["statusnetConversationId"]) == get_in(activity.data, ["statusnetConversationId"]) - assert get_in(reply.data, ["object", "statusnetConversationId"]) == get_in(activity.data, ["object", "statusnetConversationId"]) assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"]) assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id assert Enum.member?(get_in(reply.data, ["to"]), "some_cool_id") -- cgit v1.2.3 From bb1d08a47c34c70d42f6c3afa08232765a24884d Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 15:00:04 +0200 Subject: Return keys in webfinger. --- test/web/web_finger/web_finger_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index e5347a2b0..303abe529 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -1,6 +1,7 @@ defmodule Pleroma.Web.WebFingerTest do use Pleroma.DataCase alias Pleroma.Web.WebFinger + import Pleroma.Factory describe "host meta" do test "returns a link to the xml lrdd" do @@ -26,4 +27,19 @@ defmodule Pleroma.Web.WebFingerTest do assert data.salmon == "https://social.heldscal.la/main/salmon/user/29191" end end + + describe "ensure_keys_present" do + test "it creates keys for a user and stores them in info" do + user = insert(:user) + refute is_binary(user.info["keys"]) + {:ok, user} = WebFinger.ensure_keys_present(user) + assert is_binary(user.info["keys"]) + end + + test "it doesn't create keys if there already are some" do + user = insert(:user, %{info: %{"keys" => "xxx"}}) + {:ok, user} = WebFinger.ensure_keys_present(user) + assert user.info["keys"] == "xxx" + end + end end -- cgit v1.2.3 From bed0b398139897ebe9f839d1263acf6934c4a42f Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 30 Apr 2017 18:48:48 +0200 Subject: Add function to fetch users from fqn. --- test/user_test.exs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/user_test.exs b/test/user_test.exs index d711adb9d..6684aa434 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -86,4 +86,24 @@ defmodule Pleroma.UserTest do assert changeset.changes[:following] == [User.ap_followers(%User{nickname: @full_user_data.nickname})] end end + + describe "fetching a user from nickname or trying to build one" do + test "gets an existing user" do + user = insert(:user) + fetched_user = User.get_or_fetch_by_nickname(user.nickname) + + assert user == fetched_user + end + + test "fetches an external user via ostatus if no user exists" do + fetched_user = User.get_or_fetch_by_nickname("shp@social.heldscal.la") + assert fetched_user.nickname == "shp@social.heldscal.la" + end + + test "returns nil if no user could be fetched" do + fetched_user = User.get_or_fetch_by_nickname("nonexistant@social.heldscal.la") + assert fetched_user == nil + end + end end + -- cgit v1.2.3 From 6843755834192c671aebece505a1ab9322e57eee Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 1 May 2017 13:14:58 +0200 Subject: Make outgoing salmons work. --- test/user_test.exs | 6 +++++ test/web/ostatus/activity_representer_test.exs | 2 ++ test/web/salmon/salmon_test.exs | 32 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) (limited to 'test') diff --git a/test/user_test.exs b/test/user_test.exs index 6684aa434..1331ac971 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -95,6 +95,7 @@ defmodule Pleroma.UserTest do assert user == fetched_user end + # TODO: Make the test local. test "fetches an external user via ostatus if no user exists" do fetched_user = User.get_or_fetch_by_nickname("shp@social.heldscal.la") assert fetched_user.nickname == "shp@social.heldscal.la" @@ -104,6 +105,11 @@ defmodule Pleroma.UserTest do fetched_user = User.get_or_fetch_by_nickname("nonexistant@social.heldscal.la") assert fetched_user == nil end + + test "returns nil for nonexistant local user" do + fetched_user = User.get_or_fetch_by_nickname("nonexistant") + assert fetched_user == nil + end end end diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 6344889b1..439c733d7 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -25,6 +25,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{updated_at} #{note_activity.data["context"]} + """ tuple = ActivityRepresenter.to_simple_form(note_activity, user) @@ -61,6 +62,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{answer.data["context"]} + """ tuple = ActivityRepresenter.to_simple_form(answer, user) diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index aa77659d0..77dacc1c0 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -1,6 +1,8 @@ defmodule Pleroma.Web.Salmon.SalmonTest do use Pleroma.DataCase alias Pleroma.Web.Salmon + alias Pleroma.{Repo, Activity, User} + import Pleroma.Factory @magickey "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwQhh-1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB" @@ -57,4 +59,34 @@ defmodule Pleroma.Web.Salmon.SalmonTest do assert key == "RSA.uzg6r1peZU0vXGADWxGJ0PE34WvmhjUmydbX5YYdOiXfODVLwCMi1umGoqUDm-mRu4vNEdFBVJU1CpFA7dKzWgIsqsa501i2XqElmEveXRLvNRWFB6nG03Q5OUY2as8eE54BJm0p20GkMfIJGwP6TSFb-ICp3QjzbatuSPJ6xCE=.AQAB" end + + test "it pushes an activity to remote accounts it's addressed to" do + user_data = %{ + info: %{ + "salmon" => "http://example.org/salmon" + }, + local: false + } + + mentioned_user = insert(:user, user_data) + note = insert(:note) + activity_data = %{ + "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id, + "type" => "Create", + "actor" => note.data["actor"], + "to" => note.data["to"] ++ [mentioned_user.ap_id], + "object" => note.data, + "published_at" => DateTime.utc_now() |> DateTime.to_iso8601, + "context" => note.data["context"] + } + + {:ok, activity} = Repo.insert(%Activity{data: activity_data}) + user = Repo.get_by(User, ap_id: activity.data["actor"]) + {:ok, user} = Pleroma.Web.WebFinger.ensure_keys_present(user) + + poster = fn (url, data, headers) -> + assert url == "http://example.org/salmon" + end + Salmon.publish(user, activity, poster) + end end -- cgit v1.2.3 From e54e592d6c1d0ff5de5a029ae1fccee447f97149 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 1 May 2017 13:51:17 +0200 Subject: Return webfinger for ap_ids. --- test/web/web_finger/web_finger_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index 303abe529..b48fdd0aa 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -11,6 +11,22 @@ defmodule Pleroma.Web.WebFingerTest do end end + describe "incoming webfinger request" do + test "works for fqns" do + user = insert(:user) + + {:ok, result} = WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.host}") + assert is_binary(result) + end + + test "works for ap_ids" do + user = insert(:user) + + {:ok, result} = WebFinger.webfinger(user.ap_id) + assert is_binary(result) + end + end + describe "fingering" do test "returns the info for a user" do user = "shp@social.heldscal.la" -- cgit v1.2.3 From ceb2f68432e2861f09f7ba34b98bef259be9158a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 1 May 2017 18:40:36 +0200 Subject: Add type to rel=self link in feed. --- test/web/ostatus/feed_representer_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/ostatus/feed_representer_test.exs b/test/web/ostatus/feed_representer_test.exs index 7bbfae49a..df5a964e2 100644 --- a/test/web/ostatus/feed_representer_test.exs +++ b/test/web/ostatus/feed_representer_test.exs @@ -28,7 +28,7 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do #{most_recent_update} - + #{user_xml} -- cgit v1.2.3 From 89c1e90eb2a5da0a6f635a6158fe880076518a38 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 1 May 2017 22:02:07 +0200 Subject: Don't crypt raw iolists. --- test/web/websub/websub_test.exs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index ad312cd25..63acb3c43 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -167,4 +167,11 @@ defmodule Pleroma.Web.WebsubTest do {:error, websub} = Websub.request_subscription(websub, poster, 1000) assert websub.state == "rejected" end + + test "sign a text" do + signed = Websub.sign("secret", "text") + assert signed == "B8392C23690CCF871F37EC270BE1582DEC57A503" + + signed = Websub.sign("secret", [["て"], ['す']]) + end end -- cgit v1.2.3 From 56bacc90d1f401f8867e4ca7a052f7d15e18a304 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 10:43:35 +0200 Subject: Fix specs, add local marker to actitivies. --- test/support/builders/activity_builder.ex | 4 ++-- test/web/twitter_api/twitter_api_test.exs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/support/builders/activity_builder.ex b/test/support/builders/activity_builder.ex index 0f9cd0d15..16011edbf 100644 --- a/test/support/builders/activity_builder.ex +++ b/test/support/builders/activity_builder.ex @@ -5,7 +5,7 @@ defmodule Pleroma.Builders.ActivityBuilder do def build(data \\ %{}, opts \\ %{}) do user = opts[:user] || Pleroma.Factory.insert(:user) activity = %{ - "id" => 1, + "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id, "actor" => user.ap_id, "to" => ["https://www.w3.org/ns/activitystreams#Public"], "object" => %{ @@ -23,7 +23,7 @@ defmodule Pleroma.Builders.ActivityBuilder do def insert_list(times, data \\ %{}, opts \\ %{}) do Enum.map(1..times, fn (n) -> - {:ok, activity} = insert(Map.merge(data, %{"id" => n})) + {:ok, activity} = insert(data) activity end) end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 207d9d12a..57dcddd4c 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -40,6 +40,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user)) assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public") assert Enum.member?(get_in(activity.data, ["to"]), "shp") + assert activity.local == true # Add a context assert is_binary(get_in(activity.data, ["context"])) -- cgit v1.2.3 From 6dd8335477ff3adc2dda5fe4e45b0e1b38dc5b9b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 10:47:04 +0200 Subject: Mark incoming activties as non-local. --- test/web/ostatus/ostatus_test.exs | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 4e7e401cd..3951dbc9c 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -18,6 +18,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["published"] == "2017-04-23T14:51:03+00:00" assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b" assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"] + assert activity.local == false end test "handle incoming notes - GS, subscription" do -- cgit v1.2.3 From 32a95d73daf94a1186ccdbcdc9ce0f91b559119c Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 14:12:43 +0200 Subject: Add twkn timeline. --- test/web/twitter_api/twitter_api_test.exs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 57dcddd4c..4e17f3298 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -73,8 +73,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert Enum.member?(get_in(reply.data, ["to"]), "some_cool_id") end - test "fetch public statuses" do + test "fetch public statuses, excluding remote ones." do %{ public: activity, user: user } = ActivityBuilder.public_and_non_public + insert(:note_activity, %{local: false}) follower = insert(:user, following: [User.ap_followers(user)]) @@ -84,6 +85,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: user, for: follower}) end + test "fetch whole known network statuses" do + %{ public: activity, user: user } = ActivityBuilder.public_and_non_public + insert(:note_activity, %{local: false}) + + follower = insert(:user, following: [User.ap_followers(user)]) + + statuses = TwitterAPI.fetch_public_and_external_statuses(follower) + + assert length(statuses) == 2 + assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: user, for: follower}) + end + test "fetch friends' statuses" do user = insert(:user, %{following: ["someguy/followers"]}) {:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]}) -- cgit v1.2.3 From 16f8406eb60562b961536ecfabecde8e15160aa6 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 14:36:04 +0200 Subject: Add statusnet_profile_url to the TwAPI. --- test/web/twitter_api/representers/user_representer_test.exs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/twitter_api/representers/user_representer_test.exs b/test/web/twitter_api/representers/user_representer_test.exs index 1e92c5190..77f065948 100644 --- a/test/web/twitter_api/representers/user_representer_test.exs +++ b/test/web/twitter_api/representers/user_representer_test.exs @@ -48,7 +48,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do "profile_image_url_profile_size" => image, "profile_image_url_original" => image, "following" => false, - "rights" => %{} + "rights" => %{}, + "statusnet_profile_url" => user.ap_id } assert represented == UserRepresenter.to_map(user) @@ -72,7 +73,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do "profile_image_url_profile_size" => image, "profile_image_url_original" => image, "following" => true, - "rights" => %{} + "rights" => %{}, + "statusnet_profile_url" => user.ap_id } assert represented == UserRepresenter.to_map(user, %{for: follower}) -- cgit v1.2.3 From a3e82c5c246a4852d7bfaa5f6e216145b89fe0d8 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 15:54:14 +0200 Subject: Save context in likes / announces. --- test/web/activity_pub/activity_pub_test.exs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 744021c8c..6e42fbda2 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -125,6 +125,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert like_activity.data["type"] == "Like" assert like_activity.data["object"] == object.data["id"] assert like_activity.data["to"] == [User.ap_followers(user), note_activity.data["actor"]] + assert like_activity.data["context"] == object.data["context"] assert object.data["like_count"] == 1 assert object.data["likes"] == [user.ap_id] @@ -174,6 +175,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert announce_activity.data["to"] == [User.ap_followers(user), note_activity.data["actor"]] assert announce_activity.data["object"] == object.data["id"] assert announce_activity.data["actor"] == user.ap_id + assert announce_activity.data["context"] == object.data["context"] end end -- cgit v1.2.3 From 93de6039667b9fe6f3b9019c4c2297d4f23b3a1a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 16:35:53 +0200 Subject: Add an ostatus representer for like activities. --- test/web/ostatus/activity_representer_test.exs | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 439c733d7..4cf73427b 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -3,6 +3,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do alias Pleroma.Web.OStatus.ActivityRepresenter alias Pleroma.{User, Activity} + alias Pleroma.Web.ActivityPub.ActivityPub import Pleroma.Factory @@ -72,6 +73,41 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do assert clean(res) == clean(expected) end + test "a like activity" do + note = insert(:note) + user = insert(:user) + {:ok, like, _note} = ActivityPub.like(user, note) + + updated_at = like.updated_at + |> NaiveDateTime.to_iso8601 + inserted_at = like.inserted_at + |> NaiveDateTime.to_iso8601 + + tuple = ActivityRepresenter.to_simple_form(like, user) + refute is_nil(tuple) + + res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary + + expected = """ + http://activitystrea.ms/schema/1.0/favorite + #{like.data["id"]} + New favorite by #{user.nickname} + #{user.nickname} favorited something + #{inserted_at} + #{updated_at} + + http://activitystrea.ms/schema/1.0/note + #{note.data["id"]} + + #{like.data["context"]} + + + + """ + + assert clean(res) == clean(expected) + end + test "an unknown activity" do tuple = ActivityRepresenter.to_simple_form(%Activity{}, nil) assert is_nil(tuple) -- cgit v1.2.3 From 102455bf296165a88578a04f0ded259c32349d7f Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 17:13:41 +0200 Subject: Add avatar updating from incoming messages. --- test/fixtures/23211.atom | 508 ++++++++++++++++++++++++++++++++++++++ test/web/ostatus/ostatus_test.exs | 20 ++ 2 files changed, 528 insertions(+) create mode 100644 test/fixtures/23211.atom (limited to 'test') diff --git a/test/fixtures/23211.atom b/test/fixtures/23211.atom new file mode 100644 index 000000000..d5d111baa --- /dev/null +++ b/test/fixtures/23211.atom @@ -0,0 +1,508 @@ + + + GNU social + https://social.heldscal.la/api/statuses/user_timeline/23211.atom + lambadalambda timeline + Updates from lambadalambda on social.heldscal.la! + https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg + 2017-05-02T14:59:30+00:00 + + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + Call me Deacon Blues. + + + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + + Berlin + + + homepage + https://heldscal.la + true + + + + + + + + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2015260:2017-05-02T14:45:47+00:00 + Favorite + lambadalambda favorited something by godemperorofdune: <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> It's because your instance decided to be trap! lol.</p> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T14:45:47+00:00 + 2017-05-02T14:45:47+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:pawoo.net,2017-05-02:objectId=7397439:objectType=Status + New comment by godemperorofdune + <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> It's because your instance decided to be trap! lol.</p> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=136e244b26cdf1e9 + + + + + + + http://activitystrea.ms/schema/1.0/note + tag:social.heldscal.la,2017-05-02:noticeId=2015221:objectType=note + New note by lambadalambda + Some script thinks I'm a mastodon server.<br /> <br /> [info] GET /api/v1/timelines/public<br /> [debug] Processing with Fallback.RedirectController.redirector/2<br /> Parameters: %{&quot;limit&quot; =&gt; &quot;40&quot;, &quot;path&quot; =&gt; [&quot;api&quot;, &quot;v1&quot;, &quot;timelines&quot;, &quot;public&quot;]}<br /> Pipelines: [] + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T14:40:50+00:00 + 2017-05-02T14:40:50+00:00 + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=136e244b26cdf1e9 + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:social.heldscal.la,2017-05-02:noticeId=2014759:objectType=comment + New comment by lambadalambda + @<a href="https://mstdn.io/users/mattskala" class="h-card u-url p-nickname mention" title="Matthew Skala">mattskala</a> You and @<a href="https://mastodon.social/users/kevinmarks" class="h-card u-url p-nickname mention" title="Kevin Marks">kevinmarks</a> are not wrong, but my comment was a suggestion to users and admins: Don't use big instances, don't run big instances. Also, it's a secondary advice to devs: Don't add features that encourage big instances. + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T14:11:54+00:00 + 2017-05-02T14:11:54+00:00 + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=58e32e013ab6487d + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:social.heldscal.la,2017-05-02:noticeId=2014684:objectType=comment + New comment by lambadalambda + @<a href="https://mastodon.social/users/Ronkjeffries" class="h-card u-url p-nickname mention" title="Ron K Jeffries social">ronkjeffries</a> @<a href="https://xoxo.zone/users/KevinMarks" class="h-card u-url p-nickname mention" title="Kevin Marks ">kevinmarks</a> Usually people who run their own private instance just look at the timelines of other servers, follow a seed population and then go from there. This is of course hard on Mastodon, because it doesn't have a publicly visible timeline. + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T14:07:00+00:00 + 2017-05-02T14:07:00+00:00 + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=58e32e013ab6487d + + + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2014584:2017-05-02T14:05:32+00:00 + Favorite + lambadalambda favorited something by mattskala: <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> It's reasonable to expect that instance sizes will obey a power-law distribution because that's what such things in nature nearly always do. If so, there'll necessarily be a few instances much larger than the others; even if most are small, the network both socially and technically has to be able to deal with the existence of the few large ones.</p> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T14:05:32+00:00 + 2017-05-02T14:05:32+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:mstdn.io,2017-05-02:objectId=1316931:objectType=Status + New comment by mattskala + <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> It's reasonable to expect that instance sizes will obey a power-law distribution because that's what such things in nature nearly always do. If so, there'll necessarily be a few instances much larger than the others; even if most are small, the network both socially and technically has to be able to deal with the existence of the few large ones.</p> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=58e32e013ab6487d + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2013568:2017-05-02T14:05:29+00:00 + Favorite + lambadalambda favorited something by kevinmarks: <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> except instance populations will be power law distributed, and the problems for the tummlers are worse at scale</p> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T14:05:29+00:00 + 2017-05-02T14:05:29+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:xoxo.zone,2017-05-02:objectId=89478:objectType=Status + New comment by kevinmarks + <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> except instance populations will be power law distributed, and the problems for the tummlers are worse at scale</p> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=58e32e013ab6487d + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2014060:2017-05-02T13:34:32+00:00 + Favorite + lambadalambda favorited something by gcarregues: <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> Oh purée ! Ma vie en images !</p> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T13:34:32+00:00 + 2017-05-02T13:34:32+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:mastodon.etalab.gouv.fr,2017-05-02:objectId=55287:objectType=Status + New comment by gcarregues + <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> Oh purée ! Ma vie en images !</p> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2c27c27df8ec4dcc + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:note:2013573:2017-05-02T13:03:33+00:00 + Favorite + lambadalambda favorited something by phildobangnz: also @<a href="https://sealion.club/user/579" class="h-card mention" title="Sim Bot">sim</a> reminder you are awesome; don't even trip- u kewler than Tutankhamen's cucumber, fam. Okay, good night. + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T13:03:33+00:00 + 2017-05-02T13:03:33+00:00 + + http://activitystrea.ms/schema/1.0/note + tag:sealion.club,2017-05-02:noticeId=3060818:objectType=note + New note by phildobangnz + also @<a href="https://sealion.club/user/579" class="h-card mention" title="Sim Bot">sim</a> reminder you are awesome; don't even trip- u kewler than Tutankhamen's cucumber, fam. Okay, good night. + + + + + + + https://sealion.club/conversation/1633267 + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:social.heldscal.la,2017-05-02:noticeId=2013586:objectType=comment + New comment by lambadalambda + @<a href="https://xoxo.zone/users/KevinMarks" class="h-card u-url p-nickname mention" title="Kevin Marks ">kevinmarks</a> People can stay in their giant unmoderatable instances with meaningless public and federated timelines and experience constant federation drama if they want. I'll stay here with my 5 friends. + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T12:54:59+00:00 + 2017-05-02T12:54:59+00:00 + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=58e32e013ab6487d + + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:note:2013486:2017-05-02T12:46:48+00:00 + Favorite + lambadalambda favorited something by fortune: There once was a dentist named Stone<br /> Who saw all his patients alone.<br /> In a fit of depravity<br /> He filled the wrong cavity,<br /> And my, how his practice has grown! + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:46:48+00:00 + 2017-05-02T12:46:48+00:00 + + http://activitystrea.ms/schema/1.0/note + tag:gs.kawa-kun.com,2017-05-02:noticeId=1655658:objectType=note + New note by fortune + There once was a dentist named Stone<br /> Who saw all his patients alone.<br /> In a fit of depravity<br /> He filled the wrong cavity,<br /> And my, how his practice has grown! + + + + + + + https://gs.kawa-kun.com/conversation/714072 + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:note:2013365:2017-05-02T12:37:55+00:00 + Favorite + lambadalambda favorited something by xj9: <p>&gt; rollerblading to work</p> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:37:55+00:00 + 2017-05-02T12:37:55+00:00 + + http://activitystrea.ms/schema/1.0/note + tag:sunshinegardens.org,2017-05-02:objectId=61020:objectType=Status + New note by xj9 + <p>&gt; rollerblading to work</p> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=5a0e98612f634218 + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2013259:2017-05-02T12:29:03+00:00 + Favorite + lambadalambda favorited something by cereal: @<a href="https://gs.smuglo.li/user/28250" class="h-card mention" title="Bricky">thatbrickster</a> @<a href="https://social.heldscal.la/user/23211" class="h-card mention" title="Constance Variable">lambadalambda</a> But why? + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:29:03+00:00 + 2017-05-02T12:29:03+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:sealion.club,2017-05-02:noticeId=3059985:objectType=comment + New comment by cereal + @<a href="https://gs.smuglo.li/user/28250" class="h-card mention" title="Bricky">thatbrickster</a> @<a href="https://social.heldscal.la/user/23211" class="h-card mention" title="Constance Variable">lambadalambda</a> But why? + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2c27c27df8ec4dcc + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2013227:2017-05-02T12:24:27+00:00 + Favorite + lambadalambda favorited something by thatbrickster: @<a href="https://social.heldscal.la/user/23211" class="h-card u-url p-nickname mention" title="Constance Variable">lambadalambda</a> install gentoo + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:24:27+00:00 + 2017-05-02T12:24:27+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:gs.smuglo.li,2017-05-02:noticeId=2144296:objectType=comment + New comment by thatbrickster + @<a href="https://social.heldscal.la/user/23211" class="h-card u-url p-nickname mention" title="Constance Variable">lambadalambda</a> install gentoo + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2c27c27df8ec4dcc + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2013213:2017-05-02T12:22:53+00:00 + Favorite + lambadalambda favorited something by dwmatiz: @<a href="https://social.heldscal.la/user/23211" class="h-card mention">lambadalambda</a> *unzips dick* + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:22:53+00:00 + 2017-05-02T12:22:53+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:sealion.club,2017-05-02:noticeId=3059800:objectType=comment + New comment by dwmatiz + @<a href="https://social.heldscal.la/user/23211" class="h-card mention">lambadalambda</a> *unzips dick* + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2c27c27df8ec4dcc + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2013199:2017-05-02T12:22:03+00:00 + Favorite + lambadalambda favorited something by shpuld: @<a href="https://social.heldscal.la/user/23211" class="h-card mention" title="Constance Variable">lambadalambda</a> get #<span class="tag"><a href="https://shitposter.club/tag/cofe" rel="tag">cofe</a></span> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:22:03+00:00 + 2017-05-02T12:22:03+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2017-05-02:noticeId=2783524:objectType=comment + New comment by shpuld + @<a href="https://social.heldscal.la/user/23211" class="h-card mention" title="Constance Variable">lambadalambda</a> get #<span class="tag"><a href="https://shitposter.club/tag/cofe" rel="tag">cofe</a></span> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2c27c27df8ec4dcc + + + + + + + http://activitystrea.ms/schema/1.0/note + tag:social.heldscal.la,2017-05-02:noticeId=2013185:objectType=note + New note by lambadalambda + What now? <a href="https://social.heldscal.la/file/e4822d95de677757ff50d49672a4046c83218b76c04a0ad5e5f1f0a9a9eb1a74.gif" title="https://social.heldscal.la/file/e4822d95de677757ff50d49672a4046c83218b76c04a0ad5e5f1f0a9a9eb1a74.gif" rel="nofollow external noreferrer" class="attachment" id="attachment-422572">https://social.heldscal.la/attachment/422572</a> + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T12:21:04+00:00 + 2017-05-02T12:21:04+00:00 + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2c27c27df8ec4dcc + + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:note:2012929:2017-05-02T12:01:25+00:00 + Favorite + lambadalambda favorited something by drkmttr: <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> I checked out No Agenda because I saw you mention it several time. Sadly, I wasn't impressed. I'm all about varying perspectives but Adam and John basically just sound like resentful curmudgeons. It seems like their shtick is basically playing devil's advocate to everything to arouse some discontent. Just my two cents. 😉</p> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T12:01:25+00:00 + 2017-05-02T12:01:25+00:00 + + http://activitystrea.ms/schema/1.0/note + tag:mstdn.io,2017-05-02:objectId=1310093:objectType=Status + New note by drkmttr + <p><span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> I checked out No Agenda because I saw you mention it several time. Sadly, I wasn't impressed. I'm all about varying perspectives but Adam and John basically just sound like resentful curmudgeons. It seems like their shtick is basically playing devil's advocate to everything to arouse some discontent. Just my two cents. 😉</p> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=2f329b4eb20e83e2 + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2012336:2017-05-02T11:06:42+00:00 + Favorite + lambadalambda favorited something by clacke: @<a href="https://mastodon.org.uk/users/dick_turpin" class="h-card u-url p-nickname mention" title="dick_turpin">dickturpin</a> @<a href="http://quitter.se/user/113503" class="h-card u-url p-nickname mention" title="Luke">luke</a> Oh no, I miss being irritated by you, it helps me understand myself and others. Also it builds character. :-)<br /> <br /> So if this is not federation because you can't follow all of online mankind, what should we call it? Proto-federated? Pre-federated?<br /> <br /> The term has been used decades ago for just one Microsoft Active Directory domain cross-certifying the root of another, by mutual agreement. I don't see how it's any less relevant to opportunistic federation between open servers on an open internet.<br /> <br /> I'm not saying we should be satisfied, I'm just saying that "federate" is a useful word and to build a big system we need to start with a small one. And focus on the things we *can* change, like helping the OStatus network grow and making the tools more useful.<br /> <br /> Saying that the network's ideals have failed because other networks aren't joining is doing neither of that. + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T11:06:42+00:00 + 2017-05-02T11:06:42+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:social.heldscal.la,2017-05-02:noticeId=2012336:objectType=comment + New comment by clacke + @<a href="https://mastodon.org.uk/users/dick_turpin" class="h-card u-url p-nickname mention" title="dick_turpin">dickturpin</a> @<a href="http://quitter.se/user/113503" class="h-card u-url p-nickname mention" title="Luke">luke</a> Oh no, I miss being irritated by you, it helps me understand myself and others. Also it builds character. :-)<br /> <br /> So if this is not federation because you can't follow all of online mankind, what should we call it? Proto-federated? Pre-federated?<br /> <br /> The term has been used decades ago for just one Microsoft Active Directory domain cross-certifying the root of another, by mutual agreement. I don't see how it's any less relevant to opportunistic federation between open servers on an open internet.<br /> <br /> I'm not saying we should be satisfied, I'm just saying that &quot;federate&quot; is a useful word and to build a big system we need to start with a small one. And focus on the things we *can* change, like helping the OStatus network grow and making the tools more useful.<br /> <br /> Saying that the network's ideals have failed because other networks aren't joining is doing neither of that. + + + + + + + https://s.wefamlee.be/conversation/16478 + + + + + + + tag:social.heldscal.la,2017-05-02:fave:23211:comment:2011332:2017-05-02T10:37:40+00:00 + Favorite + lambadalambda favorited something by moonman: @<a href="https://social.heldscal.la/user/23211" class="h-card mention" title="Constance Variable">lambadalambda</a> <a href="https://www.youtube.com/watch?v=mKLizztikRk" title="https://www.youtube.com/watch?v=mKLizztikRk" class="attachment" rel="nofollow">https://www.youtube.com/watch?v=mKLizztikRk</a> + + http://activitystrea.ms/schema/1.0/favorite + 2017-05-02T10:37:40+00:00 + 2017-05-02T10:37:40+00:00 + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2017-05-02:noticeId=2781833:objectType=comment + New comment by moonman + @<a href="https://social.heldscal.la/user/23211" class="h-card mention" title="Constance Variable">lambadalambda</a> <a href="https://www.youtube.com/watch?v=mKLizztikRk" title="https://www.youtube.com/watch?v=mKLizztikRk" class="attachment" rel="nofollow">https://www.youtube.com/watch?v=mKLizztikRk</a> + + + + + + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=11d8b8c27d9513ec + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:social.heldscal.la,2017-05-02:noticeId=2012145:objectType=comment + New comment by lambadalambda + @<a href="https://sealion.club/user/186" class="h-card u-url p-nickname mention" title="I'M CEREAL U GUISE">cereal</a> ? No, you don't even need the identity servers for federation. + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T10:37:33+00:00 + 2017-05-02T10:37:33+00:00 + + + + https://sealion.club/conversation/1629037 + + + + + + + diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 3951dbc9c..1674edbd5 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -1,6 +1,7 @@ defmodule Pleroma.Web.OStatusTest do use Pleroma.DataCase alias Pleroma.Web.OStatus + alias Pleroma.Web.XML test "don't insert create notes twice" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") @@ -71,6 +72,25 @@ defmodule Pleroma.Web.OStatusTest do assert user == user_again end + + test "find_make_or_update_user takes an author element and returns an updated user" do + # TODO make test local + uri = "https://social.heldscal.la/user/23211" + + {:ok, user} = OStatus.find_or_make_user(uri) + change = Ecto.Changeset.change(user, %{avatar: nil}) + + {:ok, user} = Repo.update(change) + refute user.avatar + + doc = XML.parse_document(File.read!("test/fixtures/23211.atom")) + [author] = :xmerl_xpath.string('//author[1]', doc) + {:ok, user} = OStatus.find_make_or_update_user(author) + assert user.avatar["type"] == "Image" + + {:ok, user_again} = OStatus.find_make_or_update_user(author) + assert user_again == user + end end describe "gathering user info from a user id" do -- cgit v1.2.3 From 33c803d6da91e0253a100cbd480d253706c44964 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 18:25:39 +0200 Subject: Add attachment link to posts. --- test/web/twitter_api/twitter_api_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 4e17f3298..a92440f32 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -33,7 +33,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input) - assert get_in(activity.data, ["object", "content"]) == "Hello again, @shp.
This is on another line." + assert get_in(activity.data, ["object", "content"]) == "Hello again, @shp.
This is on another line.
http://example.org/image.jpg" assert get_in(activity.data, ["object", "type"]) == "Note" assert get_in(activity.data, ["object", "actor"]) == user.ap_id assert get_in(activity.data, ["actor"]) == user.ap_id -- cgit v1.2.3 From 018a1a390fdb72652c615c28ac36f1b9a6a84d82 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 2 May 2017 21:31:01 +0200 Subject: Use inReplyTo to find context. --- test/fixtures/incoming_reply_mastodon.xml | 29 +++++++++++++++++++++++++++++ test/web/ostatus/ostatus_test.exs | 17 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/fixtures/incoming_reply_mastodon.xml (limited to 'test') diff --git a/test/fixtures/incoming_reply_mastodon.xml b/test/fixtures/incoming_reply_mastodon.xml new file mode 100644 index 000000000..8ee1186cc --- /dev/null +++ b/test/fixtures/incoming_reply_mastodon.xml @@ -0,0 +1,29 @@ + + + tag:mastodon.social,2017-05-02:objectId=4901603:objectType=Status + 2017-05-02T18:33:06Z + 2017-05-02T18:33:06Z + New status by lambadalambda + + https://mastodon.social/users/lambadalambda + http://activitystrea.ms/schema/1.0/person + https://mastodon.social/users/lambadalambda + lambadalambda + lambadalambda@mastodon.social + + + + lambadalambda + Critical Value + public + + http://activitystrea.ms/schema/1.0/comment + http://activitystrea.ms/schema/1.0/post + <p><span class="h-card"><a href="https://pleroma.soykaf.com/users/lain" class="u-url mention">@<span>lain</span></a></span> hey</p> + + + public + + + + diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 1674edbd5..e39952807 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -2,6 +2,7 @@ defmodule Pleroma.Web.OStatusTest do use Pleroma.DataCase alias Pleroma.Web.OStatus alias Pleroma.Web.XML + alias Pleroma.{Object, Repo} test "don't insert create notes twice" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") @@ -32,6 +33,22 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["content"] == "Will it blend?" end + test "handle incoming notes - Mastodon, salmon, reply" do + # It uses the context of the replied to object + Repo.insert!(%Object{ + data: %{ + "id" => "https://pleroma.soykaf.com/objects/c237d966-ac75-4fe3-a87a-d89d71a3a7a4", + "context" => "2hu" + }}) + incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Create" + assert activity.data["object"]["type"] == "Note" + assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda" + assert activity.data["context"] == "2hu" + end + test "handle incoming notes - GS, subscription, reply" do incoming = File.read!("test/fixtures/ostatus_incoming_reply.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) -- cgit v1.2.3 From 9c42453e068b683517f6a72602c08527222f8fea Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 09:54:17 +0200 Subject: Return note objects as ostatus post activities. --- test/web/ostatus/ostatus_controller_test.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs index 229cd9b1e..f07698747 100644 --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@ -12,4 +12,16 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do assert response(conn, 200) end + + test "gets an object", %{conn: conn} do + note_activity = insert(:note_activity) + [_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"]) + url = "/objects/#{uuid}" + |> IO.inspect + + conn = conn + |> get(url) + + assert response(conn, 200) + end end -- cgit v1.2.3 From 16afea399d330c28de05c77649fe0540598ee8ec Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 10:01:26 +0200 Subject: Just give out the entry, not the whole feed. --- test/web/ostatus/ostatus_controller_test.exs | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs index f07698747..8b7ca4d89 100644 --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@ -17,7 +17,6 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do note_activity = insert(:note_activity) [_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"]) url = "/objects/#{uuid}" - |> IO.inspect conn = conn |> get(url) -- cgit v1.2.3 From 8141024259ee4bebd58d6ecd963f181aad420846 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 14:26:49 +0200 Subject: Attachment parsing, better magic key fetching. --- .../incoming_websub_gnusocial_attachments.xml | 59 ++++++++++++++++++++++ test/user_test.exs | 10 ++++ test/web/ostatus/ostatus_test.exs | 54 ++++++++++++-------- test/web/salmon/salmon_test.exs | 2 +- test/web/web_finger/web_finger_test.exs | 10 ++-- test/web/websub/websub_test.exs | 12 ++--- 6 files changed, 113 insertions(+), 34 deletions(-) create mode 100644 test/fixtures/incoming_websub_gnusocial_attachments.xml (limited to 'test') diff --git a/test/fixtures/incoming_websub_gnusocial_attachments.xml b/test/fixtures/incoming_websub_gnusocial_attachments.xml new file mode 100644 index 000000000..9d331ef32 --- /dev/null +++ b/test/fixtures/incoming_websub_gnusocial_attachments.xml @@ -0,0 +1,59 @@ + + + GNU social + https://social.heldscal.la/api/statuses/user_timeline/23211.atom + lambadalambda timeline + Updates from lambadalambda on social.heldscal.la! + https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg + 2017-05-02T20:29:35+00:00 + + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + Call me Deacon Blues. + + + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + + Berlin + + + homepage + https://heldscal.la + true + + + + + + + + + + + + + http://activitystrea.ms/schema/1.0/note + tag:social.heldscal.la,2017-05-02:noticeId=2020923:objectType=note + New note by lambadalambda + Okay gonna stream some cool games!! <a href="https://social.heldscal.la/file/7ed5ee508e6376a6e3dd581e17e7ed0b7b638147c7e86784bf83abc2641ee3d4.gif" title="https://social.heldscal.la/file/7ed5ee508e6376a6e3dd581e17e7ed0b7b638147c7e86784bf83abc2641ee3d4.gif" rel="nofollow external noreferrer" class="attachment" id="attachment-423842">https://social.heldscal.la/attachment/423842</a> <a href="https://social.heldscal.la/file/4c209099cadfc5afd3e27a334aa0db96b3a7510dde1603305d68a2707e59a11f.png" title="https://social.heldscal.la/file/4c209099cadfc5afd3e27a334aa0db96b3a7510dde1603305d68a2707e59a11f.png" rel="nofollow external noreferrer" class="attachment" id="attachment-423843">https://social.heldscal.la/attachment/423843</a> + + + http://activitystrea.ms/schema/1.0/post + 2017-05-02T20:29:35+00:00 + 2017-05-02T20:29:35+00:00 + + tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=26c7afdcbcf4ebd4 + + + + + + + + diff --git a/test/user_test.exs b/test/user_test.exs index 1331ac971..7435e30e0 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -111,5 +111,15 @@ defmodule Pleroma.UserTest do assert fetched_user == nil end end + + test "returns an ap_id for a user" do + user = insert(:user) + assert User.ap_id(user) == Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :feed_redirect, user.nickname) + end + + test "returns an ap_followers link for a user" do + user = insert(:user) + assert User.ap_followers(user) == Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :feed_redirect, user.nickname) <> "/followers" + end end diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index e39952807..94a735337 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -33,6 +33,16 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["content"] == "Will it blend?" end + test "handle incoming notes with attachments - GS, subscription" do + incoming = File.read!("test/fixtures/incoming_websub_gnusocial_attachments.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Create" + assert activity.data["object"]["type"] == "Note" + assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"]["attachment"] |> length == 2 + end + test "handle incoming notes - Mastodon, salmon, reply" do # It uses the context of the replied to object Repo.insert!(%Object{ @@ -118,17 +128,17 @@ defmodule Pleroma.Web.OStatusTest do {:ok, data} = OStatus.gather_user_info(user) expected = %{ - hub: "https://social.heldscal.la/main/push/hub", - magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB", - name: "shp", - nickname: "shp", - salmon: "https://social.heldscal.la/main/salmon/user/29191", - subject: "acct:shp@social.heldscal.la", - topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", - uri: "https://social.heldscal.la/user/29191", - host: "social.heldscal.la", - fqn: user, - avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} + "hub" => "https://social.heldscal.la/main/push/hub", + "magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB", + "name" => "shp", + "nickname" => "shp", + "salmon" => "https://social.heldscal.la/main/salmon/user/29191", + "subject" => "acct:shp@social.heldscal.la", + "topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", + "uri" => "https://social.heldscal.la/user/29191", + "host" => "social.heldscal.la", + "fqn" => user, + "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} } assert data == expected end @@ -140,17 +150,17 @@ defmodule Pleroma.Web.OStatusTest do {:ok, data} = OStatus.gather_user_info(user) expected = %{ - hub: "https://social.heldscal.la/main/push/hub", - magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB", - name: "shp", - nickname: "shp", - salmon: "https://social.heldscal.la/main/salmon/user/29191", - subject: "https://social.heldscal.la/user/29191", - topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", - uri: "https://social.heldscal.la/user/29191", - host: "social.heldscal.la", - fqn: user, - avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} + "hub" => "https://social.heldscal.la/main/push/hub", + "magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB", + "name" => "shp", + "nickname" => "shp", + "salmon" => "https://social.heldscal.la/main/salmon/user/29191", + "subject" => "https://social.heldscal.la/user/29191", + "topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", + "uri" => "https://social.heldscal.la/user/29191", + "host" => "social.heldscal.la", + "fqn" => user, + "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]} } assert data == expected end diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index 77dacc1c0..ed26ccf83 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -55,7 +55,7 @@ defmodule Pleroma.Web.Salmon.SalmonTest do test "it gets a magic key" do # TODO: Make test local salmon = File.read!("test/fixtures/salmon2.xml") - key = Salmon.fetch_magic_key(salmon) + {:ok, key} = Salmon.fetch_magic_key(salmon) assert key == "RSA.uzg6r1peZU0vXGADWxGJ0PE34WvmhjUmydbX5YYdOiXfODVLwCMi1umGoqUDm-mRu4vNEdFBVJU1CpFA7dKzWgIsqsa501i2XqElmEveXRLvNRWFB6nG03Q5OUY2as8eE54BJm0p20GkMfIJGwP6TSFb-ICp3QjzbatuSPJ6xCE=.AQAB" end diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index b48fdd0aa..495d3d50b 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -15,7 +15,7 @@ defmodule Pleroma.Web.WebFingerTest do test "works for fqns" do user = insert(:user) - {:ok, result} = WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.host}") + {:ok, result} = WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.Endpoint.host}") assert is_binary(result) end @@ -37,10 +37,10 @@ defmodule Pleroma.Web.WebFingerTest do {:ok, data} = WebFinger.finger(user, getter) - assert data.magic_key == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB" - assert data.topic == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom" - assert data.subject == "acct:shp@social.heldscal.la" - assert data.salmon == "https://social.heldscal.la/main/salmon/user/29191" + assert data["magic_key"] == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB" + assert data["topic"] == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom" + assert data["subject"] == "acct:shp@social.heldscal.la" + assert data["salmon"] == "https://social.heldscal.la/main/salmon/user/29191" end end diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 63acb3c43..065fb250a 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -115,12 +115,12 @@ defmodule Pleroma.Web.WebsubTest do {:ok, discovered} = Websub.gather_feed_data(topic, getter) expected = %{ - hub: "https://mastodon.social/api/push", - uri: "https://mastodon.social/users/lambadalambda", - nickname: "lambadalambda", - name: "Critical Value", - host: "mastodon.social", - avatar: %{"type" => "Image", "url" => [%{"href" => "https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244", "mediaType" => "image/gif", "type" => "Link"}]} + "hub" => "https://mastodon.social/api/push", + "uri" => "https://mastodon.social/users/lambadalambda", + "nickname" => "lambadalambda", + "name" => "Critical Value", + "host" => "mastodon.social", + "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244", "mediaType" => "image/gif", "type" => "Link"}]} } assert expected == discovered -- cgit v1.2.3 From df71c142cfadaae8866303768bca00c343b8bed1 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 16:08:24 +0200 Subject: Remove doubled 'to' recipients. --- test/web/activity_pub/activity_pub_test.exs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 6e42fbda2..dfa73b775 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -40,6 +40,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end end + describe "create activities" do + test "removes doubled 'to' recipients" do + {:ok, activity} = ActivityPub.create(["user1", "user1", "user2"], %User{ap_id: "1"}, "", %{}) + assert activity.data["to"] == ["user1", "user2"] + end + end + describe "fetch activities for recipients" do test "retrieve the activities for certain recipients" do {:ok, activity_one} = ActivityBuilder.insert(%{"to" => ["someone"]}) -- cgit v1.2.3 From 138641589dffc6ba69710ec15c690b50769f07b4 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 17:39:12 +0200 Subject: OStatus announce representer. --- test/web/ostatus/activity_representer_test.exs | 45 +++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 4cf73427b..d3c32e938 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -2,7 +2,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do use Pleroma.DataCase alias Pleroma.Web.OStatus.ActivityRepresenter - alias Pleroma.{User, Activity} + alias Pleroma.{User, Activity, Object} alias Pleroma.Web.ActivityPub.ActivityPub import Pleroma.Factory @@ -73,6 +73,49 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do assert clean(res) == clean(expected) end + test "an announce activity" do + note = insert(:note_activity) + user = insert(:user) + object = Object.get_cached_by_ap_id(note.data["object"]["id"]) + + {:ok, announce, object} = ActivityPub.announce(user, object) + + announce = Repo.get(Activity, announce.id) + + note_user = User.get_cached_by_ap_id(note.data["actor"]) + note = Repo.get(Activity, note.id) + note_xml = ActivityRepresenter.to_simple_form(note, note_user) + |> :xmerl.export_simple_content(:xmerl_xml) + |> IO.iodata_to_binary + + updated_at = announce.updated_at + |> NaiveDateTime.to_iso8601 + inserted_at = announce.inserted_at + |> NaiveDateTime.to_iso8601 + + expected = """ + http://activitystrea.ms/schema/1.0/share + #{announce.data["id"]} + #{user.nickname} repeated a notice + RT #{note.data["object"]["content"]} + #{inserted_at} + #{updated_at} + #{announce.data["context"]} + + + + #{note_xml} + + + """ + + announce_xml = ActivityRepresenter.to_simple_form(announce, user) + |> :xmerl.export_simple_content(:xmerl_xml) + |> IO.iodata_to_binary + + assert clean(expected) == clean(announce_xml) + end + test "a like activity" do note = insert(:note) user = insert(:user) -- cgit v1.2.3 From b34b046f16a44172ac96709dd0b6f5bced96d0b5 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 17:51:36 +0200 Subject: Add user to announced status. --- test/web/ostatus/activity_representer_test.exs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index d3c32e938..7f003226b 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -84,9 +84,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do note_user = User.get_cached_by_ap_id(note.data["actor"]) note = Repo.get(Activity, note.id) - note_xml = ActivityRepresenter.to_simple_form(note, note_user) + note_xml = ActivityRepresenter.to_simple_form(note, note_user, true) |> :xmerl.export_simple_content(:xmerl_xml) - |> IO.iodata_to_binary + |> to_string updated_at = announce.updated_at |> NaiveDateTime.to_iso8601 @@ -111,7 +111,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do announce_xml = ActivityRepresenter.to_simple_form(announce, user) |> :xmerl.export_simple_content(:xmerl_xml) - |> IO.iodata_to_binary + |> to_string assert clean(expected) == clean(announce_xml) end -- cgit v1.2.3 From 5d7831ee3e1ff62c2e54fe47aa1a6cf3474e8578 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 18:10:19 +0200 Subject: Add self links to federated statuses. --- test/web/ostatus/activity_representer_test.exs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 7f003226b..03b3e248f 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -26,6 +26,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{updated_at} #{note_activity.data["context"]} + """ @@ -62,6 +63,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{updated_at} #{answer.data["context"]} + """ @@ -94,6 +96,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do |> NaiveDateTime.to_iso8601 expected = """ + http://activitystrea.ms/schema/1.0/activity http://activitystrea.ms/schema/1.0/share #{announce.data["id"]} #{user.nickname} repeated a notice @@ -102,6 +105,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{updated_at} #{announce.data["context"]} + #{note_xml} @@ -144,6 +148,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{like.data["context"]} + """ -- cgit v1.2.3 From 1077c5c58d13325cd61893c609cad6505ad1d32e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 20:06:00 +0200 Subject: Remove reply-to for shares, mastodon gets confused. --- test/web/ostatus/activity_representer_test.exs | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 03b3e248f..12c9bbaa2 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -106,7 +106,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do #{announce.data["context"]} - #{note_xml} -- cgit v1.2.3 From 97257c692c5786b370d8f0769533d11c1d00334e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 20:06:20 +0200 Subject: Fix specs. --- test/user_test.exs | 2 +- test/web/websub/websub_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/user_test.exs b/test/user_test.exs index 7435e30e0..036e70dff 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -13,7 +13,7 @@ defmodule Pleroma.UserTest do user = UserBuilder.build - expected_ap_id = "https://#{host}/users/#{user.nickname}" + expected_ap_id = "#{Pleroma.Web.base_url}/users/#{user.nickname}" assert expected_ap_id == User.ap_id(user) end diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 065fb250a..48774dc69 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -170,7 +170,7 @@ defmodule Pleroma.Web.WebsubTest do test "sign a text" do signed = Websub.sign("secret", "text") - assert signed == "B8392C23690CCF871F37EC270BE1582DEC57A503" + assert signed == "B8392C23690CCF871F37EC270BE1582DEC57A503" |> String.downcase signed = Websub.sign("secret", [["て"], ['す']]) end -- cgit v1.2.3 From c85998ab8a21f042ab57345a7baa9e1e27c308d1 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 4 May 2017 18:42:29 +0200 Subject: Parse incoming retweets. --- test/fixtures/share-gs.xml | 99 +++++++++++++++++++++++++++++++++++++++ test/fixtures/share.xml | 54 +++++++++++++++++++++ test/web/ostatus/ostatus_test.exs | 26 ++++++++++ 3 files changed, 179 insertions(+) create mode 100644 test/fixtures/share-gs.xml create mode 100644 test/fixtures/share.xml (limited to 'test') diff --git a/test/fixtures/share-gs.xml b/test/fixtures/share-gs.xml new file mode 100644 index 000000000..ab5e488bd --- /dev/null +++ b/test/fixtures/share-gs.xml @@ -0,0 +1,99 @@ + + + GNU social + https://social.heldscal.la/api/statuses/user_timeline/23211.atom + lambadalambda timeline + Updates from lambadalambda on social.heldscal.la! + https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg + 2017-05-03T08:05:41+00:00 + + http://activitystrea.ms/schema/1.0/person + https://social.heldscal.la/user/23211 + lambadalambda + Call me Deacon Blues. + + + + + + lambadalambda + Constance Variable + Call me Deacon Blues. + + Berlin + + + homepage + https://heldscal.la + true + + + + + + + + + + + + + tag:social.heldscal.la,2017-05-03:noticeId=2028428:objectType=note + lambadalambda repeated a notice by lain + RT @<a href="https://pleroma.soykaf.com/users/lain" class="h-card u-url p-nickname mention" title="Lain Iwakura">lain</a> Added returning the entries as xml... let's see if the mastodon hammering stops now. + + http://activitystrea.ms/schema/1.0/share + 2017-05-03T08:05:41+00:00 + 2017-05-03T08:05:41+00:00 + + http://activitystrea.ms/schema/1.0/activity + https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193 + + Added returning the entries as xml... let's see if the mastodon hammering stops now. + + http://activitystrea.ms/schema/1.0/post + 2017-05-03T08:04:44+00:00 + 2017-05-03T08:04:44+00:00 + + http://activitystrea.ms/schema/1.0/person + https://pleroma.soykaf.com/users/lain + lain + Test account + + + + + + lain + Lain Iwakura + Test account + + + + http://activitystrea.ms/schema/1.0/note + https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193 + New note by lain + Added returning the entries as xml... let's see if the mastodon hammering stops now. + + + + + https://pleroma.soykaf.com/contexts/ede39a2b-7cf3-4fa4-8ccd-cb97431bcc22 + + + https://pleroma.soykaf.com/users/lain/feed.atom + Lain Iwakura + + + https://social.heldscal.la/avatar/43188-96-20170429172422.jpeg + 2017-05-03T08:04:44+00:00 + + + + https://pleroma.soykaf.com/contexts/ede39a2b-7cf3-4fa4-8ccd-cb97431bcc22 + + + + + + diff --git a/test/fixtures/share.xml b/test/fixtures/share.xml new file mode 100644 index 000000000..e07b88680 --- /dev/null +++ b/test/fixtures/share.xml @@ -0,0 +1,54 @@ + + + tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status + 2017-05-03T08:21:09Z + 2017-05-03T08:21:09Z + lambadalambda shared a status by lain@pleroma.soykaf.com + + https://mastodon.social/users/lambadalambda + http://activitystrea.ms/schema/1.0/person + https://mastodon.social/users/lambadalambda + lambadalambda + lambadalambda@mastodon.social + + + + lambadalambda + Critical Value + public + + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/share + + https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193 + 2017-05-03T08:04:44Z + 2017-05-03T08:05:52Z + New status by lain@pleroma.soykaf.com + + https://pleroma.soykaf.com/users/lain + http://activitystrea.ms/schema/1.0/person + https://pleroma.soykaf.com/users/lain + lain + lain@pleroma.soykaf.com + Test account + + + + lain + Lain Iwakura + Test account + public + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + Added returning the entries as xml... let's see if the mastodon hammering stops now. + + public + + + Added returning the entries as xml... let's see if the mastodon hammering stops now. + + public + + + diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 94a735337..e85d7677c 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -70,6 +70,32 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note" end + test "handle incoming retweets - GS, subscription" do + incoming = File.read!("test/fixtures/share-gs.xml") + {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Announce" + assert activity.data["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"] == retweeted_activity.data["object"]["id"] + refute activity.local + assert retweeted_activity.data["type"] == "Create" + assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain" + refute retweeted_activity.local + end + + test "handle incoming retweets - Mastodon, salmon" do + incoming = File.read!("test/fixtures/share.xml") + {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Announce" + assert activity.data["actor"] == "https://mastodon.social/users/lambadalambda" + assert activity.data["object"] == retweeted_activity.data["object"]["id"] + refute activity.local + assert retweeted_activity.data["type"] == "Create" + assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain" + refute retweeted_activity.local + end + test "handle incoming replies" do incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) -- cgit v1.2.3