diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/delete.xml | 39 | ||||
-rw-r--r-- | test/web/ostatus/incoming_documents/delete_handling_test.exs | 23 |
2 files changed, 62 insertions, 0 deletions
diff --git a/test/fixtures/delete.xml b/test/fixtures/delete.xml new file mode 100644 index 000000000..731e1c204 --- /dev/null +++ b/test/fixtures/delete.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:mastodon="http://mastodon.social/schema/1.0"> + <id>https://mastodon.sdf.org/users/snowdusk.atom</id> + <title>snowdusk</title> + <subtitle>Amateur live performance DJ/radio DJ on SDF's underground Internet radio http://aNONradio.net (LIVE Sat Sun Mon Tue 23:00-24:00 UTC) - http://snowdusk.sdf.org</subtitle> + <updated>2017-06-17T04:14:34Z</updated> + <logo>https://mastodon.sdf.org/system/accounts/avatars/000/000/002/original/405a7652d5f60449.jpg?1497672873</logo> + <author> + <id>https://mastodon.sdf.org/users/snowdusk</id> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://mastodon.sdf.org/users/snowdusk</uri> + <name>snowdusk</name> + <email>snowdusk@mastodon.sdf.org</email> + <summary type="html"><p>Amateur live performance DJ/radio DJ on SDF&apos;s underground Internet radio <a href="http://anonradio.net/" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">anonradio.net/</span><span class="invisible"></span></a> (LIVE Sat Sun Mon Tue 23:00-24:00 UTC) - <a href="http://snowdusk.sdf.org/" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">snowdusk.sdf.org/</span><span class="invisible"></span></a></p></summary> + <link rel="alternate" type="text/html" href="https://mastodon.sdf.org/@snowdusk"/> + <link rel="avatar" type="image/jpeg" media:width="120" media:height="120" href="https://mastodon.sdf.org/system/accounts/avatars/000/000/002/original/405a7652d5f60449.jpg?1497672873"/> + <link rel="header" type="image/jpeg" media:width="700" media:height="335" href="https://mastodon.sdf.org/system/accounts/headers/000/000/002/original/f1e9b0fb21b4e5a0.jpeg?1495793472"/> + <poco:preferredUsername>snowdusk</poco:preferredUsername> + <poco:displayName>snowdusk</poco:displayName> + <poco:note>Amateur live performance DJ/radio DJ on SDF's underground Internet radio http://aNONradio.net (LIVE Sat Sun Mon Tue 23:00-24:00 UTC) - http://snowdusk.sdf.org</poco:note> + <mastodon:scope>public</mastodon:scope> + </author> + <link rel="alternate" type="text/html" href="https://mastodon.sdf.org/@snowdusk"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.sdf.org/users/snowdusk.atom"/> + <link rel="next" type="application/atom+xml" href="https://mastodon.sdf.org/users/snowdusk.atom?max_id=7592"/> + <link rel="hub" href="https://mastodon.sdf.org/api/push"/> + <link rel="salmon" href="https://mastodon.sdf.org/api/salmon/2"/> + <entry> + <id>tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status</id> + <published>2017-06-10T22:02:31Z</published> + <updated>2017-06-10T22:02:31Z</updated> + <title>snowdusk deleted status</title> + <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type> + <activity:verb>http://activitystrea.ms/schema/1.0/delete</activity:verb> + <content>Deleted status</content> + <link rel="alternate" type="text/html" href="https://mastodon.sdf.org/users/snowdusk/updates/7782"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.sdf.org/users/snowdusk/updates/7782.atom"/> + </entry> +</feed> diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs new file mode 100644 index 000000000..8cd6e295e --- /dev/null +++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs @@ -0,0 +1,23 @@ +defmodule Pleroma.Web.OStatus.DeleteHandlingTest do + use Pleroma.DataCase + + import Pleroma.Factory + alias Pleroma.{Repo, Activity, Object} + alias Pleroma.Web.OStatus + + describe "deletions" do + test "it removes the mentioned activity" do + note = insert(:note_activity) + second_note = insert(:note_activity) + + incoming = File.read!("test/fixtures/delete.xml") + |> String.replace("tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status", note.data["object"]["id"]) + {:ok, []} = OStatus.handle_incoming(incoming) + + refute Repo.get(Activity, note.id) + refute Object.get_by_ap_id(note.data["object"]["id"]) + assert Repo.get(Activity, second_note.id) + assert Object.get_by_ap_id(second_note.data["object"]["id"]) + end + end +end |