0001-utils-set-LDAP-auth-backend-when-resetting-password-.patch
src/authentic2/utils/__init__.py | ||
---|---|---|
1150 | 1150 |
return True |
1151 | 1151 | |
1152 | 1152 | |
1153 |
def simulate_authentication( |
|
1154 |
request, user, method, backend='authentic2.backends.models_backend.ModelBackend', service=None, **kwargs |
|
1155 |
): |
|
1156 |
'''Simulate a normal login by forcing a backend attribute on the user instance''' |
|
1157 |
# do not modify the passed user |
|
1158 |
user = copy.deepcopy(user) |
|
1159 |
user.backend = backend |
|
1153 |
def simulate_authentication(request, user, method, backend=None, service=None, **kwargs): |
|
1154 |
'''Simulate a normal login by eventually forcing a backend attribute on the |
|
1155 |
user instance''' |
|
1156 |
if not getattr(user, 'backend', None) and not backend: |
|
1157 |
backend = 'authentic2.backends.models_backend.ModelBackend' |
|
1158 |
if backend: |
|
1159 |
user = copy.deepcopy(user) |
|
1160 |
user.backend = backend |
|
1160 | 1161 |
return login(request, user, method, service=service, record=False, **kwargs) |
1161 | 1162 | |
1162 | 1163 |
tests/test_ldap.py | ||
---|---|---|
878 | 878 |
response.form['new_password1'] = new_password |
879 | 879 |
response.form['new_password2'] = new_password |
880 | 880 |
response = response.form.submit(status=302).maybe_follow() |
881 |
assert app.session['_auth_user_backend'] == 'authentic2.backends.ldap_backend.LDAPBackendPasswordLost' |
|
882 |
template_user = response.context['user'] |
|
883 |
assert 'carlicense' in template_user.get_attributes(object(), {}) |
|
881 | 884 |
# logout |
882 | 885 |
response = response.click('Logout').maybe_follow() |
883 | 886 |
return new_password |
... | ... | |
891 | 894 |
'bindpw': force_text(slapd.root_bind_password), |
892 | 895 |
'basedn': u'o=ôrga', |
893 | 896 |
'use_tls': False, |
897 |
'attributes': ['uid', 'carLicense'], |
|
894 | 898 |
} |
895 | 899 |
] |
896 | 900 |
new_password = reset_password_ldap_user(settings, app) |
... | ... | |
1291 | 1295 |
'bindpw': force_text(slapd_ppolicy.root_bind_password), |
1292 | 1296 |
'basedn': u'o=ôrga', |
1293 | 1297 |
'use_tls': False, |
1298 |
'attributes': ['carLicense'], |
|
1294 | 1299 |
} |
1295 | 1300 |
] |
1296 | 1301 | |
1297 |
- |