1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-08 05:47:07 +09:00

GO-5589: Update invalid token error to api key terminology

This commit is contained in:
Jannis Metrikat 2025-06-03 07:26:27 +02:00
parent cbf881c589
commit 2f96ac3f63
No known key found for this signature in database
GPG key ID: B223CAC5AAF85615
2 changed files with 3 additions and 3 deletions

View file

@ -24,7 +24,7 @@ var log = logging.Logger("api-server")
var (
ErrMissingAuthorizationHeader = errors.New("missing authorization header")
ErrInvalidAuthorizationHeader = errors.New("invalid authorization header format")
ErrInvalidToken = errors.New("invalid token")
ErrInvalidApiKey = errors.New("invalid api key")
)
// ensureRateLimit creates a shared write-rate limiter middleware.
@ -76,7 +76,7 @@ func (s *Server) ensureAuthenticated(mw apicore.ClientCommands) gin.HandlerFunc
if !exists {
response := mw.WalletCreateSession(context.Background(), &pb.RpcWalletCreateSessionRequest{Auth: &pb.RpcWalletCreateSessionRequestAuthOfAppKey{AppKey: key}})
if response.Error.Code != pb.RpcWalletCreateSessionResponseError_NULL {
apiErr := util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidToken.Error())
apiErr := util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidApiKey.Error())
c.AbortWithStatusJSON(http.StatusUnauthorized, apiErr)
return
}

View file

@ -132,7 +132,7 @@ func TestEnsureAuthenticated(t *testing.T) {
// then
require.Equal(t, http.StatusUnauthorized, w.Code)
expectedJSON, err := json.Marshal(util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidToken.Error()))
expectedJSON, err := json.Marshal(util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidApiKey.Error()))
require.NoError(t, err)
require.JSONEq(t, string(expectedJSON), w.Body.String())
})