[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
This commit is contained in:
tobi
2024-01-22 15:38:45 +01:00
committed by GitHub
parent b3ba1516a7
commit d9729e7d28
3 changed files with 70 additions and 19 deletions

View File

@@ -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{})
}