Skip to content

Commit

Permalink
tests: housekeeping, test_files.py
Browse files Browse the repository at this point in the history
* fixed typos and standardized formatting
* renamed test cases to improve the clarity of what the test does
* improved docstring language, setup, steps and expected results
* added pytest.mark.importance to test cases
* the tests are simple, removed the error messages

* root lookup test updated with an additional assertion
  • Loading branch information
Dan Lavu committed Jun 27, 2024
1 parent b44cb57 commit 24c9e6a
Showing 1 changed file with 49 additions and 35 deletions.
84 changes: 49 additions & 35 deletions src/tests/system/tests/test_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
SSSD File Provider Test Case
Files Provider Test Cases
The files provider allows SSSD to use system users to authenticate.
This feature has been removed in SSSD 2.9.0 for the proxy provider.
:requirement: IDM-SSSD-REQ :: SSSD is default for local resolution
"""
Expand All @@ -13,65 +16,75 @@
from sssd_test_framework.topology import KnownTopology


@pytest.mark.importance("low")
@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__lookup_root(client: Client):
def test_files__get_entry_using_sss_service_should_not_work_looking_for_root(client: Client):
"""
:title: Getent call doesnt work on root, when service specified as "sss"
:title: Get entry using sss service should not work looking for root
:setup:
1. Enable files domain
1. Configure SSSD with files provider
2. Start SSSD
:steps:
1. getent passwd -s sss root
1. Lookup root user using sss service
2. Lookup root user without the sss service
:expectedresults:
1. Call failed
1. The root user is not found
2. The root user is found
:customerscenario: False
"""
client.sssd.sssd["enable_files_domain"] = "true"
client.sssd.start()

result = client.tools.getent.passwd("root", service="sss")
assert result is None, "Getent call was successful, which is not expected"
assert result is None

result = client.tools.getent.passwd("root")
assert result


@pytest.mark.importance("low")
@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__lookup_user(client: Client):
"""
:title: Simple getent call
:title: Lookup user
:setup:
1. Add local user "user1"
2. Enable files domain
1. Create user
2. Configure SSSD with files provider
3. Start SSSD
:steps:
1. getent passwd -s sss user1
2. Check uid of result
1. Lookup user
2. Check results
:expectedresults:
1. Call was successful
2. Uid is correct
1. User is found
2. The uid matches
:customerscenario: False
"""
client.local.user("user1").add(uid=10001)
client.sssd.sssd["enable_files_domain"] = "true"
client.sssd.start()

result = client.tools.getent.passwd("user1", service="sss")
assert result is not None, "Getent failed"
assert result.uid == 10001, "Uid is not correct"
assert result is not None
assert result.uid == 10001


@pytest.mark.importance("low")
@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__lookup_should_not_enumerate_users(client: Client):
def test_files__enumeration_should_not_work(client: Client):
"""
:title: Files provider should not enumerate
:title: Enumeration should not work
:description: Enumeration pulls down the directory data and stores it locally.
Running an unspecified getent will return all users or groups.
:setup:
1. Enable files domain
1. Configure SSSD with files provider
2. Start SSSD
:steps:
1. getent passwd -s sss without specified user
1. Run getent with nothing specified
:expectedresults:
1. Output is empty
1. Nothing found
:customerscenario: False
"""
client.sssd.sssd["enable_files_domain"] = "true"
Expand All @@ -81,27 +94,28 @@ def test_files__lookup_should_not_enumerate_users(client: Client):
assert not result.stdout


@pytest.mark.importance("low")
@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__lookup_user_shows_updated_user_info(client: Client):
def test_files__lookup_returns_the_latest_data(client: Client):
"""
:title: User have his homedir updated, after passwd
:title: Looking up a user returns the latest data
:setup:
1. Add local user "user1" with specified homedir
2. Enable files domain
1. Create user and specify home directory
2. Configure SSSD with files provider
3. Start SSSD
:steps:
1. getent passwd -s sss user1
2. Check that homedir is correct
3. Modify user1's homedir
4. Wait for changes to be propagated
5. Check that homedir is correct
1. Lookup user
2. Check results
3. Change user's home directory
4. Lookup user again
5. Check results
:expectedresults:
1. Call is successful
2. homedir is correct
3. homedir modified successfully
4. Slept well
5. homedir is updated correctly
1. User is found
2. The homedir matches
3. Home directory is changed
4. User is found
5. Home directory reflects the new value
:customerscenario: False
"""
client.local.user("user1").add(password="Secret123", home="/home/user1-tmp")
Expand Down

0 comments on commit 24c9e6a

Please sign in to comment.