0001-ldap-make-.build_external_id-resilient-to-missing-at.patch
src/authentic2/backends/ldap_backend.py | ||
---|---|---|
1370 | 1370 |
if ':' in attribute: |
1371 | 1371 |
attribute, param = attribute.split(':') |
1372 | 1372 |
quote = 'noquote' not in param.split(',') |
1373 |
part = attributes[attribute] |
|
1373 |
try: |
|
1374 |
part = attributes[attribute] |
|
1375 |
except KeyError: |
|
1376 |
return None |
|
1374 | 1377 |
if isinstance(part, list): |
1375 | 1378 |
part = part[0] |
1376 | 1379 |
if quote: |
tests/test_ldap.py | ||
---|---|---|
1744 | 1744 |
assert app.session['_auth_user_backend'] == 'authentic2.backends.ldap_backend.LDAPBackendPasswordLost' |
1745 | 1745 |
template_user = response.context['user'] |
1746 | 1746 |
assert 'carlicense' in template_user.get_attributes(object(), {}) |
1747 | ||
1748 | ||
1749 |
def test_build_external_id(slapd, settings, client, db): |
|
1750 |
backend = ldap_backend.LDAPBackend() |
|
1751 | ||
1752 |
assert backend.build_external_id(['uid'], {'uid': 'john.doe'}) == 'john.doe' |
|
1753 |
assert backend.build_external_id(['uid'], {}) is None |
|
1747 |
- |