summaryrefslogtreecommitdiff
path: root/testrig/testmodels.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-02-03 20:03:05 +0000
committerLibravatar GitHub <noreply@github.com>2023-02-03 20:03:05 +0000
commit33aee1b1e974e99182a95ce1a05e2be924d19bb2 (patch)
tree1471623039f70325a0b7a1c25dd4fe3afc883970 /testrig/testmodels.go
parent[feature/frogend] (Mastodon) domain block CSV import (#1390) (diff)
downloadgotosocial-33aee1b1e974e99182a95ce1a05e2be924d19bb2.tar.xz
[chore] reformat GetAccount() functionality, support updating accounts based on last_fetch (#1411)
* reformat GetAccount() functionality, and add UpdateAccount() function. * use fetched_at instead of last_webfingered_at * catch local "not found" errors. small formatting / error string changes * remove now unused error type * return nil when wrapping nil error * update expected error messages * return correct url for foss satan webfinger * add AP model for Some_User * normalize local domain * return notretrievable where appropriate * expose NewErrNotRetrievable * ensure webfinger for new accounts searched by uri * update local account short circuit * allow enrich to fail for already-known accounts * remove unused LastWebfingeredAt * expose test maps on mock http client * update Update test * reformat GetAccount() functionality, and add UpdateAccount() function. * use fetched_at instead of last_webfingered_at * catch local "not found" errors. small formatting / error string changes * remove nil error checks (we shouldn't be passing nil errors to newError() initializers) * remove mutex unlock on transport init fail (it hasn't yet been locked!) * woops add back the error wrapping to use ErrNotRetrievable * caches were never being started... :see_no_evil: --------- Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'testrig/testmodels.go')
-rw-r--r--testrig/testmodels.go43
1 files changed, 35 insertions, 8 deletions
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,
+ ),
}
}