Skip to content

Commit

Permalink
Tests:alltests/test_rfc2307.py converted to test_ldap.py
Browse files Browse the repository at this point in the history
Reviewed-by: Iker Pedrosa <[email protected]>
Reviewed-by: Jakub Vávra <[email protected]>
(cherry picked from commit 8ecfe20)
  • Loading branch information
patriki01 authored and alexey-tikhonov committed Oct 6, 2023
1 parent c6ea805 commit a9617cf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tests/multihost/alltests/test_rfc2307.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Testrfc2307(object):
1. Configure SSSD to authenticate against directory server
2. Enable debug_level to 9 in the 'nss', 'pam' and domain section
"""
@pytest.mark.converted('test_ldap.py', 'test_ldap__user_with_whitespace')
@pytest.mark.tier2
def test_0001_bz1362023(self, multihost, backupsssdconf):
"""
Expand Down
44 changes: 44 additions & 0 deletions src/tests/system/tests/test_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,47 @@ def test_ldap__change_password_wrong_current(client: Client, ldap: LDAP, modify_
client.sssd.start()

assert not client.auth.passwd.password("user1", "wrong123", "Newpass123"), "Password change did not fail"


@pytest.mark.ticket(bz=[1067476, 1065534])
@pytest.mark.topology(KnownTopology.LDAP)
def test_ldap__user_with_whitespace(client: Client, ldap: LDAP):
"""
:title: user with a whitespace at beginning is able to login and "id"
:setup:
1. Add users " space1" and "user1" to LDAP
2. Set uids and passwords to users
3. Clear memcache, logs and db
4. Start SSSD
:steps:
1. Fetch user " space1" information using 'id'
2. Login user " space1" via ssh
3. Login user "space1" via ssh
4. Fetch "user1" user information using 'id'
5. Fetch " user1" user information using 'id'
:expectedresults:
1. " space1" is fetched and has correct id
2. " space1" is able to login
3. "space1" is not able to login
4. "user1" is fetched and has correct id
5. " user1" is not fetched
:customerscenario: True
"""
ldap.user(" space1").add(uid=10011, password="Secret123")
ldap.user("user1").add(uid=10012, password="Secret123")
client.sssd.clear(db=True, memcache=True, logs=True)
client.sssd.start()

result = client.tools.id(" space1")
assert result is not None, "User ' space1' was not found"
assert result.user.id == 10011, "User ' space1' has wrong id"

assert client.auth.ssh.password(" space1", "Secret123"), "Authentication for user ' space1' failed"
assert not client.auth.ssh.password("space1", "Secret123"), "Authentication for user 'space1' did not fail"

result = client.tools.id("user1")
assert result is not None, "User 'user1' was not found"
assert result.user.id == 10012, "User 'user1' has wrong id"

result = client.tools.id(" user1")
assert result is None, "User ' user1' was found, not expected"

0 comments on commit a9617cf

Please sign in to comment.