summaryrefslogtreecommitdiff
path: root/internal/federation/federatingprotocol_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-04-03 13:57:07 +0100
committerLibravatar GitHub <noreply@github.com>2024-04-03 13:57:07 +0100
commit15ede4c1ea4e5a9f69b3f0ed72d94ce764ffed1d (patch)
treeb76e1fe10e2c900541776b02f1ef7f9aeb729340 /internal/federation/federatingprotocol_test.go
parent[bugfix] Set domain for empty-domain Friendica accounts (#2800) (diff)
downloadgotosocial-15ede4c1ea4e5a9f69b3f0ed72d94ce764ffed1d.tar.xz
[bugfix] improved authenticate post inbox error handling (#2803)
* improved PostInboxScheme() error handling / logging in case of failed auth * dumbass kim. returning err instead of errWithCode... * add checks for the slightly changed error handling in tests, add notes in codebase about the odd way of working
Diffstat (limited to 'internal/federation/federatingprotocol_test.go')
-rw-r--r--internal/federation/federatingprotocol_test.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/federation/federatingprotocol_test.go b/internal/federation/federatingprotocol_test.go
index 999569c85..f975cd7d6 100644
--- a/internal/federation/federatingprotocol_test.go
+++ b/internal/federation/federatingprotocol_test.go
@@ -21,6 +21,7 @@ import (
"bytes"
"context"
"encoding/json"
+ "errors"
"io"
"net/http"
"net/http/httptest"
@@ -30,6 +31,7 @@ import (
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
+ "github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/testrig"
"github.com/superseriousbusiness/httpsig"
@@ -99,7 +101,14 @@ func (suite *FederatingProtocolTestSuite) authenticatePostInbox(
recorder := httptest.NewRecorder()
newContext, authed, err := suite.federator.AuthenticatePostInbox(ctx, recorder, request)
- if err != nil {
+ if withCode := new(gtserror.WithCode); (errors.As(err, withCode) &&
+ (*withCode).Code() >= 500) || (err != nil && (*withCode) == nil) {
+ // NOTE: the behaviour here is a little strange as we have
+ // the competing code styles of the go-fed interface expecting
+ // that any err is a no-go, but authed bool is intended to be
+ // the main passer of whether failed auth occurred, but we in
+ // the gts codebase use errors to pass-back non-200 status codes,
+ // so we specifically have to check for an internal error code.
suite.FailNow(err.Error())
}