forked from mtusi2026/mtusi2026lab7
lab7: исправления по независимому ревью
This commit is contained in:
@@ -177,16 +177,16 @@ func (s *ServiceSuite) TestWrongLegacyPasswordDoesNotUpgrade() {
|
||||
s.sessions.AssertNotCalled(s.T(), "UpdatePasswordHash", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
|
||||
}
|
||||
|
||||
func (s *ServiceSuite) TestPasswordUpgradeFailureIsNotAuthenticationFailure() {
|
||||
func (s *ServiceSuite) TestPasswordUpgradeFailureDoesNotBlockLogin() {
|
||||
oldHash := obsoleteHash("secret-password-123", false)
|
||||
s.sessions.EXPECT().Credentials(mock.Anything, "alice").
|
||||
Return(domain.UserCredentials{User: s.user, PasswordHash: oldHash}, nil).Once()
|
||||
s.sessions.On("UpdatePasswordHash", mock.Anything, s.user.ID, oldHash, mock.Anything).
|
||||
Return(false, domain.ErrUnavailable).Once()
|
||||
|
||||
_, err := s.service.Authenticate(s.T().Context(), "alice", "secret-password-123")
|
||||
s.Require().ErrorIs(err, domain.ErrUnavailable)
|
||||
s.Require().NotErrorIs(err, domain.ErrUnauthenticated)
|
||||
got, err := s.service.Authenticate(s.T().Context(), "alice", "secret-password-123")
|
||||
s.Require().NoError(err)
|
||||
s.Equal(s.user, got)
|
||||
}
|
||||
|
||||
func obsoleteHash(plain string, legacy bool) string {
|
||||
|
||||
Reference in New Issue
Block a user