From 384474930c62515d22bfefe8304cab5300d7ff0b Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 3 May 2022 08:17:17 +0900 Subject: [PATCH] Add test for Create activity with licensed article --- plume-common/src/activity_pub/mod.rs | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index 2940add7..4ba34df6 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -489,6 +489,7 @@ impl ToAsUri for OneOrMany { #[cfg(test)] mod tests { use super::*; + use activitystreams::activity::Create; use assert_json_diff::assert_json_eq; use serde_json::{from_str, json, to_value}; @@ -626,4 +627,57 @@ mod tests { assert_eq!(to_value(value).unwrap(), expected); } + + #[test] + fn de_create_with_licensed_article() { + let value: Create = from_str( + r#" + { + "id": "https://plu.me/~/Blog/my-article", + "type": "Create", + "actor": "https://plu.me/@/Admin", + "to": "https://www.w3.org/ns/activitystreams#Public", + "object": { + "type": "Article", + "id": "https://plu.me/~/Blog/my-article", + "attributedTo": ["https://plu.me/@/Admin", "https://plu.me/~/Blog"], + "content": "Hello.", + "name": "My Article", + "summary": "Bye.", + "source": { + "content": "Hello.", + "mediaType": "text/markdown" + }, + "published": "2014-12-12T12:12:12Z", + "to": ["https://www.w3.org/ns/activitystreams#Public"], + "license": "CC-0" + } + } + "#, + ) + .unwrap(); + let expected = json!({ + "id": "https://plu.me/~/Blog/my-article", + "type": "Create", + "actor": "https://plu.me/@/Admin", + "to": "https://www.w3.org/ns/activitystreams#Public", + "object": { + "type": "Article", + "id": "https://plu.me/~/Blog/my-article", + "attributedTo": ["https://plu.me/@/Admin", "https://plu.me/~/Blog"], + "content": "Hello.", + "name": "My Article", + "summary": "Bye.", + "source": { + "content": "Hello.", + "mediaType": "text/markdown" + }, + "published": "2014-12-12T12:12:12Z", + "to": ["https://www.w3.org/ns/activitystreams#Public"], + "license": "CC-0" + } + }); + + assert_eq!(to_value(value).unwrap(), expected); + } }