lab7: исправления по независимому ревью

This commit is contained in:
Vladislav Kunetskiy
2026-11-10 14:22:47 +03:00
parent d1dc6d6b78
commit 30b6672058
18 changed files with 20572 additions and 20366 deletions
+4 -4
View File
@@ -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 {