MCPcopy Index your code
hub / github.com/gotify/server / Test_UpdatePassword

Method Test_UpdatePassword

api/user_test.go:395–409  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

393}
394
395func (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
411func (s *UserSuite) Test_UpdatePassword_EmptyPassword() {
412 s.db.CreateUser(&model.User{ID: 1, Name: "jmattheis", Pass: password.CreatePassword("old", 5)})

Callers

nothing calls this directly

Calls 6

CreatePasswordFunction · 0.92
WithUserFunction · 0.92
ComparePasswordFunction · 0.92
ChangePasswordMethod · 0.80
CreateUserMethod · 0.65
GetUserByIDMethod · 0.65

Tested by

no test coverage detected