fix(tests): fixed 2fa tests and password reset broken by accident

This commit is contained in:
RhodeCode Admin 2024-04-24 10:38:07 +02:00
parent e20aa86d2d
commit 566e572fff
3 changed files with 5 additions and 6 deletions

View file

@ -435,7 +435,7 @@ class TestLoginController(object):
'If such email exists, a password reset link was sent to it.')
# BAD KEY
confirm_url = '{}?key={}'.format(route_path('reset_password_confirmation'), 'badkey')
confirm_url = route_path('reset_password_confirmation', params={'key': 'badkey'})
response = self.app.get(confirm_url, status=302)
assert response.location.endswith(route_path('reset_password'))
assert_session_flash(response, 'Given reset token is invalid')

View file

@ -447,16 +447,14 @@ class LoginView(BaseAppView):
return self._get_template_context(c, **template_context)
@LoginRequired()
@NotAnonymous()
def password_reset_confirmation(self):
self.load_default_context()
if self.request.GET and self.request.GET.get('key'):
if key := self.request.GET.get('key'):
# make this take 2s, to prevent brute forcing.
time.sleep(2)
token = AuthTokenModel().get_auth_token(
self.request.GET.get('key'))
token = AuthTokenModel().get_auth_token(key)
# verify token is the correct role
if token is None or token.role != UserApiKeys.ROLE_PASSWORD_RESET:

View file

@ -106,6 +106,7 @@ def get_url_defs():
+ "/gists/{gist_id}/rev/{revision}/{format}/{f_path}",
"login": ADMIN_PREFIX + "/login",
"logout": ADMIN_PREFIX + "/logout",
"setup_2fa": ADMIN_PREFIX + "/setup_2fa",
"check_2fa": ADMIN_PREFIX + "/check_2fa",
"register": ADMIN_PREFIX + "/register",
"reset_password": ADMIN_PREFIX + "/password_reset",