diff options
author | 2024-07-26 12:04:28 +0200 | |
---|---|---|
committer | 2024-07-26 12:04:28 +0200 | |
commit | 8ab2b19a946251f258446d22f420d401f61d22f6 (patch) | |
tree | 39fb674f135fd1cfcf4de5b319913f0d0c17d11a /internal/ap/ap_test.go | |
parent | [docs] Add separate migration section + instructions for moving to GtS and no... (diff) | |
download | gotosocial-8ab2b19a946251f258446d22f420d401f61d22f6.tar.xz |
[feature] Federate interaction policies + Accepts; enforce policies (#3138)
* [feature] Federate interaction policies + Accepts; enforce policies
* use Acceptable type
* fix index
* remove appendIRIStrs
* add GetAccept federatingdb function
* lock on object IRI
Diffstat (limited to 'internal/ap/ap_test.go')
-rw-r--r-- | internal/ap/ap_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/internal/ap/ap_test.go b/internal/ap/ap_test.go index 0a9f66ca6..f982e4443 100644 --- a/internal/ap/ap_test.go +++ b/internal/ap/ap_test.go @@ -28,6 +28,7 @@ import ( "github.com/superseriousbusiness/activity/streams" "github.com/superseriousbusiness/activity/streams/vocab" "github.com/superseriousbusiness/gotosocial/internal/ap" + "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/testrig" ) @@ -103,6 +104,66 @@ func noteWithMentions1() vocab.ActivityStreamsNote { note.SetActivityStreamsContent(content) + policy := streams.NewGoToSocialInteractionPolicy() + + // Set canLike. + canLike := streams.NewGoToSocialCanLike() + + // Anyone can like. + canLikeAlwaysProp := streams.NewGoToSocialAlwaysProperty() + canLikeAlwaysProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI)) + canLike.SetGoToSocialAlways(canLikeAlwaysProp) + + // Empty approvalRequired. + canLikeApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty() + canLike.SetGoToSocialApprovalRequired(canLikeApprovalRequiredProp) + + // Set canLike on the policy. + canLikeProp := streams.NewGoToSocialCanLikeProperty() + canLikeProp.AppendGoToSocialCanLike(canLike) + policy.SetGoToSocialCanLike(canLikeProp) + + // Build canReply. + canReply := streams.NewGoToSocialCanReply() + + // Anyone can reply. + canReplyAlwaysProp := streams.NewGoToSocialAlwaysProperty() + canReplyAlwaysProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI)) + canReply.SetGoToSocialAlways(canReplyAlwaysProp) + + // Set empty approvalRequired. + canReplyApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty() + canReply.SetGoToSocialApprovalRequired(canReplyApprovalRequiredProp) + + // Set canReply on the policy. + canReplyProp := streams.NewGoToSocialCanReplyProperty() + canReplyProp.AppendGoToSocialCanReply(canReply) + policy.SetGoToSocialCanReply(canReplyProp) + + // Build canAnnounce. + canAnnounce := streams.NewGoToSocialCanAnnounce() + + // Only f0x and dumpsterqueer can announce. + canAnnounceAlwaysProp := streams.NewGoToSocialAlwaysProperty() + canAnnounceAlwaysProp.AppendIRI(testrig.URLMustParse("https://gts.superseriousbusiness.org/users/dumpsterqueer")) + canAnnounceAlwaysProp.AppendIRI(testrig.URLMustParse("https://gts.superseriousbusiness.org/users/f0x")) + canAnnounce.SetGoToSocialAlways(canAnnounceAlwaysProp) + + // Public requires approval to announce. + canAnnounceApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty() + canAnnounceApprovalRequiredProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI)) + canAnnounce.SetGoToSocialApprovalRequired(canAnnounceApprovalRequiredProp) + + // Set canAnnounce on the policy. + canAnnounceProp := streams.NewGoToSocialCanAnnounceProperty() + canAnnounceProp.AppendGoToSocialCanAnnounce(canAnnounce) + policy.SetGoToSocialCanAnnounce(canAnnounceProp) + + // Set the policy on the note. + policyProp := streams.NewGoToSocialInteractionPolicyProperty() + policyProp.AppendGoToSocialInteractionPolicy(policy) + note.SetGoToSocialInteractionPolicy(policyProp) + return note } @@ -296,6 +357,7 @@ type APTestSuite struct { addressable3 ap.Addressable addressable4 vocab.ActivityStreamsAnnounce addressable5 ap.Addressable + testAccounts map[string]*gtsmodel.Account } func (suite *APTestSuite) jsonToType(rawJson string) (vocab.Type, map[string]interface{}) { @@ -336,4 +398,5 @@ func (suite *APTestSuite) SetupTest() { suite.addressable3 = addressable3() suite.addressable4 = addressable4() suite.addressable5 = addressable5() + suite.testAccounts = testrig.NewTestAccounts() } |