2 files changed,
15 insertions(+),
5 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2025-06-21 17:53:08 +0300
Parent:
9c8b9ea
M
e2e/apiv1_auth_test.go
··· 135 135 email string 136 136 password string 137 137 expectedCode int 138 + expectedMsg string 138 139 }{ 139 140 { 140 - name: "activated account", 141 + name: "already activated account", 141 142 email: email, 142 143 password: password, 143 144 expectedCode: http.StatusBadRequest, 145 + expectedMsg: models.ErrUserIsAlreadyVerified.Error(), 144 146 }, 145 147 { 146 148 name: "wrong credentials", 147 149 email: email, 148 150 password: e.uuid(), 149 - expectedCode: http.StatusUnauthorized, 151 + expectedCode: http.StatusBadRequest, 152 + expectedMsg: models.ErrUserWrongCredentials.Error(), 150 153 }, 151 154 } 152 155 ··· 160 163 })) 161 164 162 165 e.Equal(httpResp.Code, t.expectedCode) 166 + 167 + var body errorResponse 168 + e.readBodyAndUnjsonify(httpResp.Body, &body) 169 + e.Equal(body.Message, t.expectedMsg) 170 + 163 171 e.Empty(mockMailStore[t.email]) 164 172 } 165 173 } ··· 220 228 email: "wrong@email.com", 221 229 password: password, 222 230 expectedCode: http.StatusBadRequest, 231 + expectedMsg: models.ErrUserWrongCredentials.Error(), 223 232 }, 224 233 { 225 234 name: "wrong password", 226 235 email: email, 227 236 password: "wrong-wrong", 228 - expectedCode: http.StatusUnauthorized, 237 + expectedCode: http.StatusBadRequest, 238 + expectedMsg: models.ErrUserWrongCredentials.Error(), 229 239 }, 230 240 } 231 241
M
internal/transport/http/apiv1/response.go
··· 28 28 errors.Is(err, models.ErrUserInvalidEmail) || 29 29 errors.Is(err, models.ErrUserInvalidPassword) || 30 30 errors.Is(err, models.ErrUserNotFound) || 31 + errors.Is(err, models.ErrUserWrongCredentials) || 31 32 // notes 32 33 errors.Is(err, notesrv.ErrNotePasswordNotProvided) || 33 34 errors.Is(err, models.ErrNoteContentIsEmpty) || ··· 49 50 50 51 if errors.Is(err, ErrUnauthorized) || 51 52 errors.Is(err, jwtutil.ErrTokenExpired) || 52 - errors.Is(err, jwtutil.ErrTokenSignatureInvalid) || 53 - errors.Is(err, models.ErrUserWrongCredentials) { 53 + errors.Is(err, jwtutil.ErrTokenSignatureInvalid) { 54 54 newErrorStatus(c, http.StatusUnauthorized, err.Error()) 55 55 return 56 56 }