2 files changed,
26 insertions(+),
32 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2025-08-31 19:15:21 +0300
Parent:
eb4c605
M
e2e/apiv1_auth_test.go
··· 18 18 } 19 19 20 20 func (e *AppTestSuite) TestAuthV1_SignUP() { 21 - email := e.uuid() + "test@test.com" 22 - password := "password" 21 + email, password := e.randomEmail(), "password" 23 22 24 23 httpResp := e.httpRequest( 25 24 http.MethodPost, ··· 47 46 }{ 48 47 {name: "all fields empty", email: "", password: ""}, 49 48 {name: "non valid email", email: "email", password: "password"}, 50 - {name: "non valid password", email: "test@test.com", password: "12345"}, 49 + {name: "non valid password", email: e.randomEmail(), password: "12345"}, 51 50 } 52 51 for _, t := range tests { 53 52 httpResp := e.httpRequest( ··· 200 199 } 201 200 202 201 func (e *AppTestSuite) TestAuthV1_SignIn_wrong() { 203 - password := "password" 204 - email := e.uuid() + "@test.com" 205 - e.insertUser(email, "password", true) 202 + email, unactivatedEmail, password := e.randomEmail(), e.randomEmail(), e.uuid() 206 203 207 - unactivatedEmail := e.uuid() + "@test.com" 204 + e.insertUser(email, password, true) 208 205 e.insertUser(unactivatedEmail, password, false) 209 206 210 207 //exhaustruct:ignore ··· 228 225 { 229 226 name: "wrong email", 230 227 email: "wrong@email.com", 231 - password: password, 228 + password: e.uuid(), 232 229 expectedCode: http.StatusBadRequest, 233 230 expectedMsg: models.ErrUserWrongCredentials.Error(), 234 231 }, ··· 267 264 } 268 265 269 266 func (e *AppTestSuite) TestAuthV1_RefreshTokens() { 270 - uid, toks := e.createAndSingIn(e.uuid()+"@test.com", "password") 267 + uid, toks := e.createAndSingIn(e.randomEmail(), e.uuid()) 271 268 httpResp := e.httpRequest( 272 269 http.MethodPost, 273 270 "/api/v1/auth/refresh-tokens", ··· 304 301 } 305 302 306 303 func (e *AppTestSuite) TestAuthV1_Logout() { 307 - uid, toks := e.createAndSingIn(e.uuid()+"@test.com", "password") 304 + uid, toks := e.createAndSingIn(e.randomEmail(), e.uuid()) 308 305 309 306 sessionDB := e.getLastSessionByUserID(uid) 310 307 e.NotEmpty(sessionDB.RefreshToken) ··· 324 321 } 325 322 326 323 func (e *AppTestSuite) TestAuthV1_LogoutAll() { 327 - uid, toks := e.createAndSingIn(e.uuid()+"@test.com", "password") 324 + uid, toks := e.createAndSingIn(e.randomEmail(), e.uuid()) 328 325 329 326 var res int 330 327 query := "select count(*) from sessions where user_id = $1" ··· 347 344 } 348 345 349 346 func (e *AppTestSuite) TestAuthV1_ChangePassword() { 350 - oldPassword, newPassword := e.uuid(), e.uuid() 351 - email := e.uuid() + "@test.com" 347 + email, oldPassword, newPassword := e.randomEmail(), e.uuid(), e.uuid() 352 348 _, toks := e.createAndSingIn(email, oldPassword) 353 349 354 350 httpResp := e.httpRequest( ··· 368 364 } 369 365 370 366 func (e *AppTestSuite) TestAuthV1_ChangePassword_wrongPassword() { 371 - password := e.uuid() 372 - newPassword := e.uuid() 373 - email := e.uuid() + "@test.com" 374 - _, toks := e.createAndSingIn(email, password) 367 + email, oldPassword, newPassword := e.randomEmail(), e.uuid(), e.uuid() 368 + _, toks := e.createAndSingIn(email, oldPassword) 375 369 376 370 httpResp := e.httpRequest( 377 371 http.MethodPost, ··· 405 399 ) 406 400 407 401 func (e *AppTestSuite) TestAuthV1_ResetPassword() { 408 - email := e.uuid() + "@test.com" 409 - uid, _ := e.createAndSingIn(email, "password") 402 + email := e.randomEmail() 403 + uid, _ := e.createAndSingIn(email, e.uuid()) 410 404 411 405 httpResp := e.httpRequest( 412 406 http.MethodPost, ··· 441 435 } 442 436 443 437 func (e *AppTestSuite) TestAuthV1_ResetPassword_nonExistentUser() { 444 - _, _ = e.createAndSingIn(e.uuid()+"@test.com", "password") 438 + _, _ = e.createAndSingIn(e.randomEmail(), e.uuid()) 445 439 httpResp := e.httpRequest( 446 440 http.MethodPost, 447 441 "/api/v1/auth/reset-password", ··· 516 510 } 517 511 518 512 func (e *AppTestSuite) TestApiV1_getMe() { 519 - email := e.uuid() + "@test.com" 520 - uid, toks := e.createAndSingIn(email, "password") 513 + email := e.randomEmail() 514 + uid, toks := e.createAndSingIn(email, e.uuid()) 521 515 522 516 httpResp := e.httpRequest(http.MethodGet, "/api/v1/me", nil, toks.AccessToken) 523 517