##// END OF EJS Templates
fix: fixed logging
fix: fixed logging

File last commit:

r5173:95a4b30f default
r5448:d936c57c default
Show More
test_password_reset.py
94 lines | 3.6 KiB | text/x-python | PythonLexer
/ rhodecode / apps / login / tests / test_password_reset.py
copyrights: updated for 2023
r5088 # Copyright (C) 2010-2023 RhodeCode GmbH
global-permissions: ported controller to pyramid view....
r1941 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import pytest
from rhodecode.lib import helpers as h
from rhodecode.tests import (
caches: use dogpile for sql_cache_short region.
r2883 TestController, clear_cache_regions,
global-permissions: ported controller to pyramid view....
r1941 TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS)
from rhodecode.tests.fixture import Fixture
from rhodecode.tests.utils import AssertResponse
tests: refactor code to use a single test url generator
r5173 from rhodecode.tests.routes import route_path
global-permissions: ported controller to pyramid view....
r1941
tests: refactor code to use a single test url generator
r5173 fixture = Fixture()
global-permissions: ported controller to pyramid view....
r1941
class TestPasswordReset(TestController):
@pytest.mark.parametrize(
'pwd_reset_setting, show_link, show_reset', [
('hg.password_reset.enabled', True, True),
('hg.password_reset.hidden', False, True),
('hg.password_reset.disabled', False, False),
])
def test_password_reset_settings(
self, pwd_reset_setting, show_link, show_reset):
caches: use dogpile for sql_cache_short region.
r2883 clear_cache_regions()
global-permissions: ported controller to pyramid view....
r1941 self.log_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS)
params = {
'csrf_token': self.csrf_token,
'anonymous': 'True',
'default_register': 'hg.register.auto_activate',
'default_register_message': '',
'default_password_reset': pwd_reset_setting,
'default_extern_activate': 'hg.extern_activate.auto',
}
auth: login/registration changes for upcomming new rules for login using external identities....
r3386 resp = self.app.post(
route_path('admin_permissions_application_update'), params=params)
global-permissions: ported controller to pyramid view....
r1941 self.logout_user()
login_page = self.app.get(route_path('login'))
asr_login = AssertResponse(login_page)
if show_link:
asr_login.one_element_exists('a.pwd_reset')
else:
asr_login.no_element_exists('a.pwd_reset')
response = self.app.get(route_path('reset_password'))
tests: stabilize tests for mysql/postgres.
r3981 assert_response = response.assert_response()
global-permissions: ported controller to pyramid view....
r1941 if show_reset:
response.mustcontain('Send password reset email')
assert_response.one_element_exists('#email')
assert_response.one_element_exists('#send')
else:
response.mustcontain('Password reset is disabled.')
assert_response.no_element_exists('#email')
assert_response.no_element_exists('#send')
def test_password_form_disabled(self):
self.log_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS)
params = {
'csrf_token': self.csrf_token,
'anonymous': 'True',
'default_register': 'hg.register.auto_activate',
'default_register_message': '',
'default_password_reset': 'hg.password_reset.disabled',
'default_extern_activate': 'hg.extern_activate.auto',
}
self.app.post(route_path('admin_permissions_application_update'), params=params)
self.logout_user()
response = self.app.post(
route_path('reset_password'), {'email': 'lisa@rhodecode.com',}
)
response = response.follow()
response.mustcontain('Password reset is disabled.')