mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Log status code when failing to authenticate with OAuth provider (#10819)
This commit is contained in:
@@ -783,7 +783,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
|
||||
ar := model.AccessResponseFromJson(tee)
|
||||
|
||||
if ar == nil || resp.StatusCode != http.StatusOK {
|
||||
return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "response_body="+buf.String(), http.StatusInternalServerError)
|
||||
return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, fmt.Sprintf("response_body=%s, status_code=%d", buf.String(), resp.StatusCode), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if strings.ToLower(ar.TokenType) != model.ACCESS_TOKEN_TYPE {
|
||||
|
||||
@@ -327,6 +327,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
_, _, _, err := th.App.AuthorizeOAuthUser(&httptest.ResponseRecorder{}, request, model.SERVICE_GITLAB, "", state, "")
|
||||
require.NotNil(t, err)
|
||||
assert.Equal(t, "api.user.authorize_oauth_user.bad_response.app_error", err.Id)
|
||||
assert.Contains(t, err.DetailedError, "status_code=418")
|
||||
})
|
||||
|
||||
t.Run("with an invalid token response", func(t *testing.T) {
|
||||
@@ -345,6 +346,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
_, _, _, err := th.App.AuthorizeOAuthUser(&httptest.ResponseRecorder{}, request, model.SERVICE_GITLAB, "", state, "")
|
||||
require.NotNil(t, err)
|
||||
assert.Equal(t, "api.user.authorize_oauth_user.bad_response.app_error", err.Id)
|
||||
assert.Contains(t, err.DetailedError, "response_body=invalid")
|
||||
})
|
||||
|
||||
t.Run("with an invalid token type", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user