()
| 393 | } |
| 394 | |
| 395 | func (s *UserSuite) Test_UpdatePassword() { |
| 396 | s.db.CreateUser(&model.User{ID: 1, Name: "jmattheis", Pass: password.CreatePassword("old", 5)}) |
| 397 | |
| 398 | test.WithUser(s.ctx, 1) |
| 399 | s.ctx.Request = httptest.NewRequest("POST", "/user/current/password", strings.NewReader(`{"pass": "new"}`)) |
| 400 | s.ctx.Request.Header.Set("Content-Type", "application/json") |
| 401 | |
| 402 | s.a.ChangePassword(s.ctx) |
| 403 | |
| 404 | assert.Equal(s.T(), 200, s.recorder.Code) |
| 405 | user, err := s.db.GetUserByID(1) |
| 406 | assert.NoError(s.T(), err) |
| 407 | assert.NotNil(s.T(), user) |
| 408 | assert.True(s.T(), password.ComparePassword(user.Pass, []byte("new"))) |
| 409 | } |
| 410 | |
| 411 | func (s *UserSuite) Test_UpdatePassword_EmptyPassword() { |
| 412 | s.db.CreateUser(&model.User{ID: 1, Name: "jmattheis", Pass: password.CreatePassword("old", 5)}) |
nothing calls this directly
no test coverage detected