summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/dereferencer_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-30 12:27:42 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-30 12:27:42 +0200
commit0cd2bd2960e29a3e8c39de543f7e9a8d635e2221 (patch)
tree8c5a39db67fea3e9c247885446cab8aa3d6d65fe /internal/federation/dereferencing/dereferencer_test.go
parentGolint (#255) (diff)
downloadgotosocial-0cd2bd2960e29a3e8c39de543f7e9a8d635e2221.tar.xz
allow dereferencing of groups (#256)
Diffstat (limited to 'internal/federation/dereferencing/dereferencer_test.go')
-rw-r--r--internal/federation/dereferencing/dereferencer_test.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/internal/federation/dereferencing/dereferencer_test.go b/internal/federation/dereferencing/dereferencer_test.go
index 41909ec4d..0eeabc64a 100644
--- a/internal/federation/dereferencing/dereferencer_test.go
+++ b/internal/federation/dereferencing/dereferencer_test.go
@@ -45,7 +45,8 @@ type DereferencerStandardTestSuite struct {
storage *kv.KVStore
testRemoteStatuses map[string]vocab.ActivityStreamsNote
- testRemoteAccounts map[string]vocab.ActivityStreamsPerson
+ testRemotePeople map[string]vocab.ActivityStreamsPerson
+ testRemoteGroups map[string]vocab.ActivityStreamsGroup
testRemoteAttachments map[string]testrig.RemoteAttachmentFile
testAccounts map[string]*gtsmodel.Account
@@ -55,7 +56,8 @@ type DereferencerStandardTestSuite struct {
func (suite *DereferencerStandardTestSuite) SetupSuite() {
suite.testAccounts = testrig.NewTestAccounts()
suite.testRemoteStatuses = testrig.NewTestFediStatuses()
- suite.testRemoteAccounts = testrig.NewTestFediPeople()
+ suite.testRemotePeople = testrig.NewTestFediPeople()
+ suite.testRemoteGroups = testrig.NewTestFediGroups()
suite.testRemoteAttachments = testrig.NewTestFediAttachments("../../../testrig/media")
}
@@ -89,8 +91,7 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport.
responseType := ""
responseLength := 0
- note, ok := suite.testRemoteStatuses[req.URL.String()]
- if ok {
+ if note, ok := suite.testRemoteStatuses[req.URL.String()]; ok {
// the request is for a note that we have stored
noteI, err := streams.Serialize(note)
if err != nil {
@@ -104,8 +105,7 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport.
responseType = "application/activity+json"
}
- person, ok := suite.testRemoteAccounts[req.URL.String()]
- if ok {
+ if person, ok := suite.testRemotePeople[req.URL.String()]; ok {
// the request is for a person that we have stored
personI, err := streams.Serialize(person)
if err != nil {
@@ -119,8 +119,21 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport.
responseType = "application/activity+json"
}
- attachment, ok := suite.testRemoteAttachments[req.URL.String()]
- if ok {
+ if group, ok := suite.testRemoteGroups[req.URL.String()]; ok {
+ // the request is for a person that we have stored
+ groupI, err := streams.Serialize(group)
+ if err != nil {
+ panic(err)
+ }
+ groupJson, err := json.Marshal(groupI)
+ if err != nil {
+ panic(err)
+ }
+ responseBytes = groupJson
+ responseType = "application/activity+json"
+ }
+
+ if attachment, ok := suite.testRemoteAttachments[req.URL.String()]; ok {
responseBytes = attachment.Data
responseType = attachment.ContentType
}