From 0f412cf6e68fcebda3e94b71b7f182af689748bf Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 24 Dec 2018 02:25:36 +0300 Subject: Create tombstone instead of object deletion --- test/web/activity_pub/activity_pub_test.exs | 2 +- test/web/activity_pub/transmogrifier_test.exs | 2 +- test/web/mastodon_api/mastodon_api_controller_test.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 470ed08b2..95731a868 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -478,7 +478,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert Repo.get(Activity, delete.id) != nil - assert Repo.get(Object, object.id) == nil + assert Repo.get(Object, object.id).data["type"] == "tombstone" end end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 0428e052d..18a5ad3d0 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -363,7 +363,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data) - refute Repo.get(Activity, activity.id) + assert Repo.get(Activity, activity.id).data["type"] == "tombstone" end test "it fails for incoming deletes with spoofed origin" do diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index aec0f851c..6c6cc2a00 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -292,7 +292,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert %{} = json_response(conn, 200) - assert Repo.get(Activity, activity.id) == nil + assert Repo.get(Activity, activity.id).data["type"] == "tombstone" end test "when you didn't create it", %{conn: conn} do -- cgit v1.2.3 From 18a4cbb244dbc188f5a391626fb98e3a53571318 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 24 Dec 2018 20:09:18 +0300 Subject: Capitalize "tombstone" --- test/web/activity_pub/activity_pub_test.exs | 2 +- test/web/activity_pub/transmogrifier_test.exs | 2 +- test/web/mastodon_api/mastodon_api_controller_test.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 95731a868..4d16a87e2 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -478,7 +478,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert Repo.get(Activity, delete.id) != nil - assert Repo.get(Object, object.id).data["type"] == "tombstone" + assert Repo.get(Object, object.id).data["type"] == "Tombstone" end end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 18a5ad3d0..8ab240dff 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -363,7 +363,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data) - assert Repo.get(Activity, activity.id).data["type"] == "tombstone" + assert Repo.get(Activity, activity.id).data["type"] == "Tombstone" end test "it fails for incoming deletes with spoofed origin" do diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 6c6cc2a00..f1baa9953 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -292,7 +292,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert %{} = json_response(conn, 200) - assert Repo.get(Activity, activity.id).data["type"] == "tombstone" + assert Repo.get(Activity, activity.id).data["type"] == "Tombstone" end test "when you didn't create it", %{conn: conn} do -- cgit v1.2.3 From 2bbec33c7112ede3f93a7d35e9d5f3ac5a31ce05 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 00:29:13 +0300 Subject: Fix failing tests --- test/web/ostatus/incoming_documents/delete_handling_test.exs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/web') diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs index 1e041e5b0..4e9c0f90f 100644 --- a/test/web/ostatus/incoming_documents/delete_handling_test.exs +++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs @@ -23,9 +23,9 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do {:ok, [delete]} = OStatus.handle_incoming(incoming) - refute Repo.get(Activity, note.id) - refute Repo.get(Activity, like.id) - refute Object.get_by_ap_id(note.data["object"]["id"]) + assert Repo.get(Activity, note.id).data["type"] == "Tombstone" + assert Repo.get(Activity, like.id).data["type"] == "Tombstone" + assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone" assert Repo.get(Activity, second_note.id) assert Object.get_by_ap_id(second_note.data["object"]["id"]) -- cgit v1.2.3 From f75f707f6cf07c66a23ddbbe80a9b782a1ecb6f8 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 03:00:06 +0300 Subject: Revert Activity tombstones, add ObjectTombstone struct --- test/web/activity_pub/transmogrifier_test.exs | 2 +- .../mastodon_api/mastodon_api_controller_test.exs | 21 ++++++++++++++++++++- .../incoming_documents/delete_handling_test.exs | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'test/web') diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 8ab240dff..0428e052d 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -363,7 +363,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data) - assert Repo.get(Activity, activity.id).data["type"] == "Tombstone" + refute Repo.get(Activity, activity.id) end test "it fails for incoming deletes with spoofed origin" do diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index f1baa9953..23f63372c 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -292,7 +292,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert %{} = json_response(conn, 200) - assert Repo.get(Activity, activity.id).data["type"] == "Tombstone" + refute Repo.get(Activity, activity.id) end test "when you didn't create it", %{conn: conn} do @@ -308,6 +308,25 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert Repo.get(Activity, activity.id) == activity end + + # test "404 when making an attempt to get it" do + # activity = insert(:note_activity) + # author = User.get_by_ap_id(activity.data["actor"]) + + # conn = + # conn + # |> assign(:user, author) + # |> delete("/api/v1/statuses/#{activity.id}") + + # assert %{} = json_response(conn, 200) + + # conn = + # build_conn() + # |> assign(:user, author) + # |> get("/api/v1/statuses/#{activity.id}") + + # assert %{} = json_response(conn, 200) + # end end describe "filters" do diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs index 4e9c0f90f..c8fbff6cc 100644 --- a/test/web/ostatus/incoming_documents/delete_handling_test.exs +++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs @@ -23,8 +23,8 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do {:ok, [delete]} = OStatus.handle_incoming(incoming) - assert Repo.get(Activity, note.id).data["type"] == "Tombstone" - assert Repo.get(Activity, like.id).data["type"] == "Tombstone" + refute Repo.get(Activity, note.id) + refute Repo.get(Activity, like.id) assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone" assert Repo.get(Activity, second_note.id) assert Object.get_by_ap_id(second_note.data["object"]["id"]) -- cgit v1.2.3 From aeb89bece60846d8311afd69d0ccfd1df80cbe65 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 03:38:02 +0300 Subject: Remove unused test --- .../web/mastodon_api/mastodon_api_controller_test.exs | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'test/web') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 23f63372c..00cf52d69 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -308,25 +308,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert Repo.get(Activity, activity.id) == activity end - - # test "404 when making an attempt to get it" do - # activity = insert(:note_activity) - # author = User.get_by_ap_id(activity.data["actor"]) - - # conn = - # conn - # |> assign(:user, author) - # |> delete("/api/v1/statuses/#{activity.id}") - - # assert %{} = json_response(conn, 200) - - # conn = - # build_conn() - # |> assign(:user, author) - # |> get("/api/v1/statuses/#{activity.id}") - - # assert %{} = json_response(conn, 200) - # end end describe "filters" do -- cgit v1.2.3 From 012b7ab5e64eae468c630730f392ea8289a5d874 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 23:40:57 +0300 Subject: Add test to check /object/:id does not leak the tombstone itself --- test/web/ostatus/ostatus_controller_test.exs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs index 560305c15..c503cadae 100644 --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@ -1,7 +1,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do use Pleroma.Web.ConnCase import Pleroma.Factory - alias Pleroma.{User, Repo} + alias Pleroma.{User, Repo, Object} alias Pleroma.Web.CommonAPI alias Pleroma.Web.OStatus.ActivityRepresenter @@ -110,6 +110,22 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do |> response(404) end + test "404s on deleted objects", %{conn: conn} do + note_activity = insert(:note_activity) + [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])) + object = Object.get_by_ap_id(note_activity.data["object"]["id"]) + + conn + |> get("/objects/#{uuid}") + |> response(200) + + Object.delete(object) + + conn + |> get("/objects/#{uuid}") + |> response(404) + end + test "gets an activity", %{conn: conn} do note_activity = insert(:note_activity) [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])) -- cgit v1.2.3