From: Nutomic Date: Sun, 12 Dec 2021 02:39:18 +0000 (+0000) Subject: Test pleroma follow (#1988) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%7Bthis.state.thumbnail%7D?a=commitdiff_plain;h=c6ac606f604b2d72063caf25fb54d3ab6a1cdcfc;p=lemmy.git Test pleroma follow (#1988) * Add test case for Pleroma follow activity (ref #1984) * Use WithContext in apub tests where possible --- diff --git a/crates/apub/assets/pleroma/activities/follow.json b/crates/apub/assets/pleroma/activities/follow.json new file mode 100644 index 00000000..8d0f008a --- /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 63ddcf96..8693647f 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 3258dbb7..693725a9 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 bd590d49..4ee13b77 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");