ldap: additional tests for the keep_password function (#50931)

License: MIT
This commit is contained in:
Loïc Dachary 2021-02-07 00:48:26 +01:00 committed by Benjamin Dauvergne
parent 882ce5d930
commit cc02a30b14
1 changed files with 19 additions and 0 deletions

View File

@ -251,6 +251,25 @@ def test_keep_password_in_session(slapd, settings, client, db):
force_bytes(result.context['request'].user.ldap_data['password'][DN.lower()])) == force_bytes(PASS)
def test_keep_password_true_or_false(slapd, settings, db):
settings.LDAP_AUTH_SETTINGS = [{
'url': [slapd.ldap_url],
'basedn': u'o=ôrga',
'use_tls': False,
'keep_password': True,
}]
user = authenticate(username=USERNAME, password=PASS)
assert User.objects.count() == 1
user = User.objects.get()
assert user.check_password(PASS)
settings.LDAP_AUTH_SETTINGS[0]['keep_password'] = False
user = ldap_backend.LDAPBackend().authenticate(username=USERNAME, password=PASS)
assert User.objects.count() == 1
user = User.objects.get()
assert not user.check_password(PASS)
@pytest.mark.django_db
def test_custom_ou(slapd, settings, client):
OU = get_ou_model()