| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2021 William Brown <[email protected]> |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# License: GPL (version 3 or any later version). |
| 6 |
# See LICENSE for details. |
| 7 |
# --- END COPYRIGHT BLOCK --- |
| 8 |
# |
| 9 |
import ldap |
| 10 |
import pytest |
| 11 |
from test389.topologies import topology_st |
| 12 |
from lib389.idm.user import UserAccounts |
| 13 |
from lib389._constants import (DEFAULT_SUFFIX, PASSWORD) |
| 14 |
|
| 15 |
pytestmark = pytest.mark.tier1 |
| 16 |
|
| 17 |
def test_password_crypt_asterisk_is_rejected(topology_st): |
| 18 |
"""It was reported that {CRYPT}* was allowing all passwords to be |
| 19 |
valid in the bind process. This checks that we should be rejecting |
| 20 |
these as they should represent locked accounts. Similar, {CRYPT}! |
| 21 |
|
| 22 |
:id: 0b8f1a6a-f3eb-4443-985e-da14d0939dc3 |
| 23 |
:setup: Single instance |
| 24 |
:steps: 1. Set a password hash in with CRYPT and the content * |
| 25 |
2. Test a bind |
| 26 |
3. Set a password hash in with CRYPT and the content ! |
| 27 |
4. Test a bind |
| 28 |
:expectedresults: |
| 29 |
1. Successfully set the values |
| 30 |
2. The bind fails |
| 31 |
3. Successfully set the values |
| 32 |
4. The bind fails |
| 33 |
""" |
| 34 |
topology_st.standalone.config.set('nsslapd-allow-hashed-passwords', 'on') |
| 35 |
topology_st.standalone.config.set('nsslapd-enable-upgrade-hash', 'off') |
| 36 |
|
| 37 |
users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX) |
| 38 |
user = users.create_test_user() |
| 39 |
|
| 40 |
user.set('userPassword', "{CRYPT}*") |
| 41 |
|
| 42 |
# Attempt to bind with incorrect password. |
| 43 |
with pytest.raises(ldap.INVALID_CREDENTIALS): |
| 44 |
badconn = user.bind('badpassword') |
| 45 |
|
| 46 |
user.set('userPassword', "{CRYPT}!") |
| 47 |
# Attempt to bind with incorrect password. |
| 48 |
with pytest.raises(ldap.INVALID_CREDENTIALS): |
| 49 |
badconn = user.bind('badpassword') |
| 50 |
|