summaryrefslogtreecommitdiff
path: root/testrig
diff options
context:
space:
mode:
Diffstat (limited to 'testrig')
-rw-r--r--testrig/config.go2
-rw-r--r--testrig/testmodels.go43
-rw-r--r--testrig/transportcontroller.go44
3 files changed, 58 insertions, 31 deletions
diff --git a/testrig/config.go b/testrig/config.go
index 140d73e6a..d470c8703 100644
--- a/testrig/config.go
+++ b/testrig/config.go
@@ -34,7 +34,7 @@ func InitTestConfig() {
}
var testDefaults = config.Configuration{
- LogLevel: "trace",
+ LogLevel: "info",
LogDbQueries: true,
ApplicationName: "gotosocial",
LandingPageUser: "",
diff --git a/testrig/testmodels.go b/testrig/testmodels.go
index f44dce71c..e5fe45d9e 100644
--- a/testrig/testmodels.go
+++ b/testrig/testmodels.go
@@ -335,7 +335,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
URI: "http://localhost:8080/users/localhost:8080",
URL: "http://localhost:8080/@localhost:8080",
PublicKeyURI: "http://localhost:8080/users/localhost:8080#main-key",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://localhost:8080/users/localhost:8080/inbox",
OutboxURI: "http://localhost:8080/users/localhost:8080/outbox",
FollowersURI: "http://localhost:8080/users/localhost:8080/followers",
@@ -373,7 +373,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
Language: "en",
URI: "http://localhost:8080/users/weed_lord420",
URL: "http://localhost:8080/@weed_lord420",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://localhost:8080/users/weed_lord420/inbox",
OutboxURI: "http://localhost:8080/users/weed_lord420/outbox",
FollowersURI: "http://localhost:8080/users/weed_lord420/followers",
@@ -413,7 +413,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
URI: "http://localhost:8080/users/admin",
URL: "http://localhost:8080/@admin",
PublicKeyURI: "http://localhost:8080/users/admin#main-key",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://localhost:8080/users/admin/inbox",
OutboxURI: "http://localhost:8080/users/admin/outbox",
FollowersURI: "http://localhost:8080/users/admin/followers",
@@ -452,7 +452,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
Language: "en",
URI: "http://localhost:8080/users/the_mighty_zork",
URL: "http://localhost:8080/@the_mighty_zork",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://localhost:8080/users/the_mighty_zork/inbox",
OutboxURI: "http://localhost:8080/users/the_mighty_zork/outbox",
FollowersURI: "http://localhost:8080/users/the_mighty_zork/followers",
@@ -492,7 +492,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
Language: "en",
URI: "http://localhost:8080/users/1happyturtle",
URL: "http://localhost:8080/@1happyturtle",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://localhost:8080/users/1happyturtle/inbox",
OutboxURI: "http://localhost:8080/users/1happyturtle/outbox",
FollowersURI: "http://localhost:8080/users/1happyturtle/followers",
@@ -527,7 +527,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
Language: "en",
URI: "http://fossbros-anonymous.io/users/foss_satan",
URL: "http://fossbros-anonymous.io/@foss_satan",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://fossbros-anonymous.io/users/foss_satan/inbox",
SharedInboxURI: StringPtr("http://fossbros-anonymous.io/inbox"),
OutboxURI: "http://fossbros-anonymous.io/users/foss_satan/outbox",
@@ -563,7 +563,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
Language: "en",
URI: "http://example.org/users/Some_User",
URL: "http://example.org/@Some_User",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://example.org/users/Some_User/inbox",
SharedInboxURI: StringPtr(""),
OutboxURI: "http://example.org/users/Some_User/outbox",
@@ -599,7 +599,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
Language: "en",
URI: "http://thequeenisstillalive.technology/users/her_fuckin_maj",
URL: "http://thequeenisstillalive.technology/@her_fuckin_maj",
- LastWebfingeredAt: time.Time{},
+ FetchedAt: time.Time{},
InboxURI: "http://thequeenisstillalive.technology/users/her_fuckin_maj/inbox",
SharedInboxURI: StringPtr(""),
OutboxURI: "http://thequeenisstillalive.technology/users/her_fuckin_maj/outbox",
@@ -2137,6 +2137,12 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson {
}
turnipLover6969Pub := &turnipLover6969Priv.PublicKey
+ someUserPriv, err := rsa.GenerateKey(rand.Reader, 2048)
+ if err != nil {
+ panic(err)
+ }
+ someUserPub := &someUserPriv.PublicKey
+
return map[string]vocab.ActivityStreamsPerson{
"https://unknown-instance.com/users/brand_new_person": newAPPerson(
URLMustParse("https://unknown-instance.com/users/brand_new_person"),
@@ -2180,6 +2186,27 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson {
"image/png",
false,
),
+ "https://example.org/users/Some_User": newAPPerson(
+ URLMustParse("https://example.org/users/Some_User"),
+ URLMustParse("https://example.org/users/Some_User/following"),
+ URLMustParse("https://example.org/users/Some_User/followers"),
+ URLMustParse("https://example.org/users/Some_User/inbox"),
+ URLMustParse("https://example.org/sharedInbox"),
+ URLMustParse("https://example.org/users/Some_User/outbox"),
+ URLMustParse("https://example.org/users/Some_User/collections/featured"),
+ "Some_User",
+ "just some user, don't mind me",
+ "Peepee poo poo",
+ URLMustParse("https://example.org/@Some_User"),
+ true,
+ URLMustParse("https://example.org/users/Some_User#main-key"),
+ someUserPub,
+ nil,
+ "image/jpeg",
+ nil,
+ "image/png",
+ false,
+ ),
}
}
diff --git a/testrig/transportcontroller.go b/testrig/transportcontroller.go
index c7344e678..09775f6a2 100644
--- a/testrig/transportcontroller.go
+++ b/testrig/transportcontroller.go
@@ -60,13 +60,13 @@ func NewTestTransportController(client pub.HttpClient, db db.DB, fedWorker *conc
type MockHTTPClient struct {
do func(req *http.Request) (*http.Response, error)
- testRemoteStatuses map[string]vocab.ActivityStreamsNote
- testRemotePeople map[string]vocab.ActivityStreamsPerson
- testRemoteGroups map[string]vocab.ActivityStreamsGroup
- testRemoteServices map[string]vocab.ActivityStreamsService
- testRemoteAttachments map[string]RemoteAttachmentFile
- testRemoteEmojis map[string]vocab.TootEmoji
- testTombstones map[string]*gtsmodel.Tombstone
+ TestRemoteStatuses map[string]vocab.ActivityStreamsNote
+ TestRemotePeople map[string]vocab.ActivityStreamsPerson
+ TestRemoteGroups map[string]vocab.ActivityStreamsGroup
+ TestRemoteServices map[string]vocab.ActivityStreamsService
+ TestRemoteAttachments map[string]RemoteAttachmentFile
+ TestRemoteEmojis map[string]vocab.TootEmoji
+ TestTombstones map[string]*gtsmodel.Tombstone
SentMessages sync.Map
}
@@ -88,13 +88,13 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
return mockHTTPClient
}
- mockHTTPClient.testRemoteStatuses = NewTestFediStatuses()
- mockHTTPClient.testRemotePeople = NewTestFediPeople()
- mockHTTPClient.testRemoteGroups = NewTestFediGroups()
- mockHTTPClient.testRemoteServices = NewTestFediServices()
- mockHTTPClient.testRemoteAttachments = NewTestFediAttachments(relativeMediaPath)
- mockHTTPClient.testRemoteEmojis = NewTestFediEmojis()
- mockHTTPClient.testTombstones = NewTestTombstones()
+ mockHTTPClient.TestRemoteStatuses = NewTestFediStatuses()
+ mockHTTPClient.TestRemotePeople = NewTestFediPeople()
+ mockHTTPClient.TestRemoteGroups = NewTestFediGroups()
+ mockHTTPClient.TestRemoteServices = NewTestFediServices()
+ mockHTTPClient.TestRemoteAttachments = NewTestFediAttachments(relativeMediaPath)
+ mockHTTPClient.TestRemoteEmojis = NewTestFediEmojis()
+ mockHTTPClient.TestTombstones = NewTestTombstones()
mockHTTPClient.do = func(req *http.Request) (*http.Response, error) {
responseCode := http.StatusNotFound
@@ -123,7 +123,7 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseContentLength = len(responseBytes)
} else if strings.Contains(req.URL.String(), ".well-known/webfinger") {
responseCode, responseBytes, responseContentType, responseContentLength = WebfingerResponse(req)
- } else if note, ok := mockHTTPClient.testRemoteStatuses[req.URL.String()]; ok {
+ } else if note, ok := mockHTTPClient.TestRemoteStatuses[req.URL.String()]; ok {
// the request is for a note that we have stored
noteI, err := streams.Serialize(note)
if err != nil {
@@ -137,7 +137,7 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseBytes = noteJSON
responseContentType = applicationActivityJSON
responseContentLength = len(noteJSON)
- } else if person, ok := mockHTTPClient.testRemotePeople[req.URL.String()]; ok {
+ } else if person, ok := mockHTTPClient.TestRemotePeople[req.URL.String()]; ok {
// the request is for a person that we have stored
personI, err := streams.Serialize(person)
if err != nil {
@@ -151,7 +151,7 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseBytes = personJSON
responseContentType = applicationActivityJSON
responseContentLength = len(personJSON)
- } else if group, ok := mockHTTPClient.testRemoteGroups[req.URL.String()]; ok {
+ } else if group, ok := mockHTTPClient.TestRemoteGroups[req.URL.String()]; ok {
// the request is for a person that we have stored
groupI, err := streams.Serialize(group)
if err != nil {
@@ -165,7 +165,7 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseBytes = groupJSON
responseContentType = applicationActivityJSON
responseContentLength = len(groupJSON)
- } else if service, ok := mockHTTPClient.testRemoteServices[req.URL.String()]; ok {
+ } else if service, ok := mockHTTPClient.TestRemoteServices[req.URL.String()]; ok {
serviceI, err := streams.Serialize(service)
if err != nil {
panic(err)
@@ -178,7 +178,7 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseBytes = serviceJSON
responseContentType = applicationActivityJSON
responseContentLength = len(serviceJSON)
- } else if emoji, ok := mockHTTPClient.testRemoteEmojis[req.URL.String()]; ok {
+ } else if emoji, ok := mockHTTPClient.TestRemoteEmojis[req.URL.String()]; ok {
emojiI, err := streams.Serialize(emoji)
if err != nil {
panic(err)
@@ -191,12 +191,12 @@ func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error), relat
responseBytes = emojiJSON
responseContentType = applicationActivityJSON
responseContentLength = len(emojiJSON)
- } else if attachment, ok := mockHTTPClient.testRemoteAttachments[req.URL.String()]; ok {
+ } else if attachment, ok := mockHTTPClient.TestRemoteAttachments[req.URL.String()]; ok {
responseCode = http.StatusOK
responseBytes = attachment.Data
responseContentType = attachment.ContentType
responseContentLength = len(attachment.Data)
- } else if _, ok := mockHTTPClient.testTombstones[req.URL.String()]; ok {
+ } else if _, ok := mockHTTPClient.TestTombstones[req.URL.String()]; ok {
responseCode = http.StatusGone
responseBytes = []byte{}
responseContentType = "text/html"
@@ -278,7 +278,7 @@ func WebfingerResponse(req *http.Request) (responseCode int, responseBytes []byt
{
Rel: "self",
Type: applicationActivityJSON,
- Href: "https://fossbros-anonymous.io/users/foss_satan",
+ Href: "http://fossbros-anonymous.io/users/foss_satan",
},
},
}