From c6ac606f604b2d72063caf25fb54d3ab6a1cdcfc Mon Sep 17 00:00:00 2001 From: Nutomic Date: Sun, 12 Dec 2021 02:39:18 +0000 Subject: [PATCH] Test pleroma follow (#1988) * Add test case for Pleroma follow activity (ref #1984) * Use WithContext in apub tests where possible --- .../apub/assets/pleroma/activities/follow.json | 18 ++++++++++++++++++ .../activities/create_or_update/mod.rs | 9 +++++++-- .../src/protocol/activities/following/mod.rs | 18 ++++++++++++------ crates/apub/src/protocol/objects/mod.rs | 9 +++++---- 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 crates/apub/assets/pleroma/activities/follow.json diff --git a/crates/apub/assets/pleroma/activities/follow.json b/crates/apub/assets/pleroma/activities/follow.json new file mode 100644 index 000000000..8d0f008a8 --- /dev/null +++ b/crates/apub/assets/pleroma/activities/follow.json @@ -0,0 +1,18 @@ +{ + "@context": [ + "https://www.w3.org/ns/activitystreams", + "https://mycrowd.ca/schemas/litepub-0.1.jsonld", + { + "@language": "und" + } + ], + "actor": "https://mycrowd.ca/users/kinetix", + "cc": [], + "id": "https://mycrowd.ca/activities/dab6a4d3-0db0-41ee-8aab-7bfa4929b4fd", + "object": "https://lemmy.ca/u/kinetix", + "state": "pending", + "to": [ + "https://lemmy.ca/u/kinetix" + ], + "type": "Follow" +} diff --git a/crates/apub/src/protocol/activities/create_or_update/mod.rs b/crates/apub/src/protocol/activities/create_or_update/mod.rs index 63ddcf967..8693647f6 100644 --- a/crates/apub/src/protocol/activities/create_or_update/mod.rs +++ b/crates/apub/src/protocol/activities/create_or_update/mod.rs @@ -4,6 +4,7 @@ pub mod post; #[cfg(test)] mod tests { use crate::{ + context::WithContext, objects::tests::file_to_json_object, protocol::{ activities::create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost}, @@ -23,8 +24,12 @@ mod tests { "assets/lemmy/activities/create_or_update/create_note.json", ); - file_to_json_object::("assets/pleroma/activities/create_note.json"); - file_to_json_object::("assets/smithereen/activities/create_note.json"); + file_to_json_object::>( + "assets/pleroma/activities/create_note.json", + ); + file_to_json_object::>( + "assets/smithereen/activities/create_note.json", + ); file_to_json_object::("assets/mastodon/activities/create_note.json"); file_to_json_object::("assets/lotide/activities/create_page.json"); diff --git a/crates/apub/src/protocol/activities/following/mod.rs b/crates/apub/src/protocol/activities/following/mod.rs index 3258dbb7e..693725a94 100644 --- a/crates/apub/src/protocol/activities/following/mod.rs +++ b/crates/apub/src/protocol/activities/following/mod.rs @@ -4,13 +4,17 @@ pub mod undo_follow; #[cfg(test)] mod tests { - use crate::protocol::{ - activities::following::{ - accept::AcceptFollowCommunity, - follow::FollowCommunity, - undo_follow::UndoFollowCommunity, + use crate::{ + context::WithContext, + objects::tests::file_to_json_object, + protocol::{ + activities::following::{ + accept::AcceptFollowCommunity, + follow::FollowCommunity, + undo_follow::UndoFollowCommunity, + }, + tests::test_parse_lemmy_item, }, - tests::test_parse_lemmy_item, }; #[actix_rt::test] @@ -20,5 +24,7 @@ mod tests { test_parse_lemmy_item::( "assets/lemmy/activities/following/undo_follow.json", ); + + file_to_json_object::>("assets/pleroma/activities/follow.json"); } } diff --git a/crates/apub/src/protocol/objects/mod.rs b/crates/apub/src/protocol/objects/mod.rs index bd590d493..4ee13b775 100644 --- a/crates/apub/src/protocol/objects/mod.rs +++ b/crates/apub/src/protocol/objects/mod.rs @@ -18,6 +18,7 @@ pub struct Endpoints { #[cfg(test)] mod tests { use crate::{ + context::WithContext, objects::tests::file_to_json_object, protocol::{ objects::{chat_message::ChatMessage, group::Group, note::Note, page::Page, person::Person}, @@ -33,11 +34,11 @@ mod tests { test_parse_lemmy_item::("assets/lemmy/objects/note.json"); test_parse_lemmy_item::("assets/lemmy/objects/chat_message.json"); - file_to_json_object::("assets/pleroma/objects/person.json"); - file_to_json_object::("assets/pleroma/objects/note.json"); - file_to_json_object::("assets/pleroma/objects/chat_message.json"); + file_to_json_object::>("assets/pleroma/objects/person.json"); + file_to_json_object::>("assets/pleroma/objects/note.json"); + file_to_json_object::>("assets/pleroma/objects/chat_message.json"); - file_to_json_object::("assets/smithereen/objects/person.json"); + file_to_json_object::>("assets/smithereen/objects/person.json"); file_to_json_object::("assets/smithereen/objects/note.json"); file_to_json_object::("assets/mastodon/objects/person.json");