Skip to content

Commit

Permalink
tests: add many more samples for Firefish and GlitchSoc
Browse files Browse the repository at this point in the history
Also includes the table requested in #58
  • Loading branch information
warriordog committed Jul 24, 2023
1 parent 83735f2 commit e11a8e2
Show file tree
Hide file tree
Showing 27 changed files with 1,276 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ActivityPub.Types/Json/ASTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class ASTypeConverter<T> : JsonConverter<T>
{
private readonly IASTypeInfoCache _asTypeInfoCache;
private readonly IJsonTypeInfoCache _jsonTypeInfoCache;

public ASTypeConverter(IASTypeInfoCache asTypeInfoCache, IJsonTypeInfoCache jsonTypeInfoCache)
{
_asTypeInfoCache = asTypeInfoCache;
Expand Down Expand Up @@ -138,7 +139,7 @@ private static object ReadObjectDirectly(JsonElement inputElement, JsonTypeInfo

return obj;
}

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
// If value is a subtype of T, then we need to re-enter with the correct type
Expand Down
63 changes: 63 additions & 0 deletions Tests/ActivityPub.Types.Tests/Smoke/Samples/Firefish/Create.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"id": "https://enby.life/notes/9h203ewltks9dbfb/activity",
"actor": "https://enby.life/users/9fpnzspgtp",
"type": "Create",
"published": "2023-07-11T15:17:48.213Z",
"object": {
"id": "https://enby.life/notes/9h203ewltks9dbfb",
"type": "Note",
"attributedTo": "https://enby.life/users/9fpnzspgtp",
"summary": null,
"content": "<p><span>Source for the instance background: </span><a href=\"https://tech.lgbt/@Gingeh/110117861681527722\">https://tech.lgbt/@Gingeh/110117861681527722</a></p>",
"_misskey_content": "Source for the instance background: https://tech.lgbt/@Gingeh/110117861681527722",
"source": {
"content": "Source for the instance background: https://tech.lgbt/@Gingeh/110117861681527722",
"mediaType": "text/x.misskeymarkdown"
},
"published": "2023-07-11T15:17:48.213Z",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://enby.life/users/9fpnzspgtp/followers"
],
"inReplyTo": null,
"attachment": [],
"sensitive": false,
"tag": []
},
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://enby.life/users/9fpnzspgtp/followers"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

using ActivityPub.Types.Collection;
using ActivityPub.Types.Extended.Activity;
using ActivityPub.Types.Extended.Actor;
using ActivityPub.Types.Extended.Link;
using ActivityPub.Types.Extended.Object;
using ActivityPub.Types.Tests.Util.Fixtures;

namespace ActivityPub.Types.Tests.Smoke.Samples.Firefish;
Expand All @@ -12,11 +15,35 @@ public class FirefishSampleTests : SampleTests
public FirefishSampleTests(JsonLdSerializerFixture fixture) : base(fixture) {}

[Fact]
public void PersonActorShouldConvert() => TestSample(typeof(PersonActor), PersonActor.PersonType);
public void CreateShouldConvert() => TestSample(typeof(CreateActivity), CreateActivity.CreateType);

[Fact]
public void HashtagShouldConvert() => TestSample(typeof(ASObject), "Hashtag");

[Fact]
public void ImageShouldConvert() => TestSample(typeof(ImageObject), ImageObject.ImageType);

[Fact]
public void KeyShouldConvert() => TestSample(typeof(ASObject), "Key");

[Fact]
public void MentionShouldConvert() => TestSample(typeof(MentionLink), MentionLink.MentionType);

[Fact]
public void NoteShouldConvert() => TestSample(typeof(NoteObject), NoteObject.NoteType);

[Fact]
public void ObjectShouldConvert() => TestSample(typeof(ASObject), ASObject.ObjectType);

[Fact]
public void ASOrderedCollectionShouldConvert() => TestSample(typeof(ASOrderedCollection<ASType>), CollectionTypes.OrderedCollectionType);
public void OrderedCollectionShouldConvert() => TestSample(typeof(ASOrderedCollection<ASObject>), CollectionTypes.OrderedCollectionType);

[Fact]
public void OrderedCollectionPageShouldConvert() => TestSample(typeof(ASOrderedCollectionPage<ASObject>), CollectionTypes.OrderedCollectionPageType);

[Fact]
public void PersonActorShouldConvert() => TestSample(typeof(PersonActor), PersonActor.PersonType);

[Fact]
public void ASOrderedCollectionPageShouldConvert() => TestSample(typeof(ASOrderedCollectionPage<ASType>), CollectionTypes.OrderedCollectionPageType);
public void PropertyValueShouldConvert() => TestSample(typeof(ASObject), "PropertyValue");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"type": "Hashtag",
"href": "https://enby.life/tags/calckey",
"name": "#calckey"
}
34 changes: 34 additions & 0 deletions Tests/ActivityPub.Types.Tests/Smoke/Samples/Firefish/Image.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"type": "Image",
"url": "https://enby.life/files/a15e1514-0c3a-48a1-8480-bb5b8e880cef",
"sensitive": false,
"name": null
}
34 changes: 34 additions & 0 deletions Tests/ActivityPub.Types.Tests/Smoke/Samples/Firefish/Key.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"id": "https://enby.life/users/9fpnzspgtp#main-key",
"type": "Key",
"owner": "https://enby.life/users/9fpnzspgtp",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAux49fKZK3XxSActEu+Rm\nitMezjOHKhRnQXzbh/UX++nrIrxhk4DJiQSmeOSuoeO3YiwlA8fcgK6ZU8l6RYFp\nhjjVauueWMaB7mrOHCBK2QtY9kPvtyMVtM1lt1cnqbsBsZP7YNWYS+9oZKw0NOCU\nPuapmYhkS+eA1hpBEDDZ0WG74HzNUSlweFD2ssQGeNyy0lTI20LPCvHqfDHO3rI1\nZkouHcf3es2O8CFqz7RIociMFfMWQEzBkmVo8fKxwUdOvrm4u/eKc6dZ5OLKuh3+\nRo8S10zbZvOE8btKosL9HhHF1X51Qg4gbqEU06hnTCKLyyxOvpkrrTFOXCQtaDJu\nypN1xhEEZIYL7j4QfDa+LZSeslzwRT2WywCnLyX2bgIzDvZDCVKeqHxfl/Z5YrX8\nFn+75j8tX/BDyjZs8XGFeesQx5hb/WWGI2FpqHz11GVUm/rcrE9gi4Thghkn43T1\nsY23URvBcKfY5Z+YG4eCkjsoMoJnybLKhLQ08YKY3rap4XGLsvn8SG+XByw7Uk1I\nZlvl/dO+AMJKfjPcme0cj56m85eWrHfmwGXQPOicMcKz6pxQ7u0icDD5Ychm9a8t\ndkgmRv8coB8qCEU5VX5JOK/N826MzmoHX5tG9WBAdXWpDg9wKdNn75ZbbajMm+eV\n5GSCDAq4TtaPFzGu8fKeWuECAwEAAQ==\n-----END PUBLIC KEY-----"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"type": "Mention",
"href": "https://enby.life/users/9fpwmts9tv",
"name": "@hazelnoot"
}
51 changes: 51 additions & 0 deletions Tests/ActivityPub.Types.Tests/Smoke/Samples/Firefish/Note.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"id": "https://enby.life/notes/9h203ewltks9dbfb",
"type": "Note",
"attributedTo": "https://enby.life/users/9fpnzspgtp",
"summary": null,
"content": "<p><span>Source for the instance background: </span><a href=\"https://tech.lgbt/@Gingeh/110117861681527722\">https://tech.lgbt/@Gingeh/110117861681527722</a></p>",
"_misskey_content": "Source for the instance background: https://tech.lgbt/@Gingeh/110117861681527722",
"source": {
"content": "Source for the instance background: https://tech.lgbt/@Gingeh/110117861681527722",
"mediaType": "text/x.misskeymarkdown"
},
"published": "2023-07-11T15:17:48.213Z",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://enby.life/users/9fpnzspgtp/followers"
],
"inReplyTo": null,
"attachment": [],
"sensitive": false,
"tag": []
}
32 changes: 32 additions & 0 deletions Tests/ActivityPub.Types.Tests/Smoke/Samples/Firefish/Object.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"content": "Source for the instance background: https://tech.lgbt/@Gingeh/110117861681527722",
"mediaType": "text/x.misskeymarkdown"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"movedToUri": "as:movedTo",
"sensitive": "as:sensitive",
"Hashtag": "as:Hashtag",
"quoteUri": "fedibird:quoteUri",
"quoteUrl": "as:quoteUrl",
"toot": "http://joinmastodon.org/ns#",
"Emoji": "toot:Emoji",
"featured": "toot:featured",
"discoverable": "toot:discoverable",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"misskey": "https://misskey-hub.net/ns#",
"_misskey_content": "misskey:_misskey_content",
"_misskey_quote": "misskey:_misskey_quote",
"_misskey_reaction": "misskey:_misskey_reaction",
"_misskey_votes": "misskey:_misskey_votes",
"_misskey_talk": "misskey:_misskey_talk",
"isCat": "misskey:isCat",
"fedibird": "http://fedibird.com/ns#",
"vcard": "http://www.w3.org/2006/vcard/ns#"
}
],
"type": "PropertyValue",
"name": "Test",
"value": "Value"
}
Loading

0 comments on commit e11a8e2

Please sign in to comment.