diff options
author | 2024-01-22 15:38:45 +0100 | |
---|---|---|
committer | 2024-01-22 14:38:45 +0000 | |
commit | d9729e7d28bd64a707443a8a7a6b0e4383b14caf (patch) | |
tree | a7c9ab3fe8fe3b62b84b025dfc1fbf2f3b4af2b9 /internal/ap/resolve_test.go | |
parent | [chore]: Bump codeberg.org/gruf/go-mutexes from 1.3.1 to 1.4.0 (#2562) (diff) | |
download | gotosocial-d9729e7d28bd64a707443a8a7a6b0e4383b14caf.tar.xz |
[bugfix] Don't return Internal Server Error when searching for URIs that don't return AP JSON (#2550)
* [bugfix] Don't return Internal Server Error when searching for URIs that don't return AP JSON
* don't pass map pointer
Diffstat (limited to 'internal/ap/resolve_test.go')
-rw-r--r-- | internal/ap/resolve_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/ap/resolve_test.go b/internal/ap/resolve_test.go index 0b2c8fb0c..bc32af7e4 100644 --- a/internal/ap/resolve_test.go +++ b/internal/ap/resolve_test.go @@ -47,6 +47,29 @@ func (suite *ResolveTestSuite) TestResolveDocumentAsAccountable() { suite.Nil(accountable) } +func (suite *ResolveTestSuite) TestResolveHTMLAsAccountable() { + b := []byte(`<!DOCTYPE html> + <title>.</title>`) + + accountable, err := ap.ResolveAccountable(context.Background(), b) + suite.True(gtserror.IsWrongType(err)) + suite.EqualError(err, "ResolveAccountable: error unmarshalling bytes into json: invalid character '<' looking for beginning of value") + suite.Nil(accountable) +} + +func (suite *ResolveTestSuite) TestResolveNonAPJSONAsAccountable() { + b := []byte(`{ + "@context": "definitely a legit context muy lord", + "type": "definitely an account muy lord", + "pee pee":"poo poo" +}`) + + accountable, err := ap.ResolveAccountable(context.Background(), b) + suite.True(gtserror.IsWrongType(err)) + suite.EqualError(err, "ResolveAccountable: error resolving json into ap vocab type: activity stream did not match any known types") + suite.Nil(accountable) +} + func TestResolveTestSuite(t *testing.T) { suite.Run(t, &ResolveTestSuite{}) } |