Skip to content

Commit

Permalink
Tests: multihost/basic/test_files converted
Browse files Browse the repository at this point in the history
Reviewed-by: Iker Pedrosa <[email protected]>
Reviewed-by: Sumit Bose <[email protected]>
  • Loading branch information
patriki01 authored and pbrezina committed Oct 3, 2023
1 parent 620af3b commit ea7273b
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tests/multihost/basic/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TestImplicitFilesProvider(object):
Test the files provider. This test runs the implicit files provider
together with another domain to stick close to what users use in Fedora
"""
@pytest.mark.converted('test_files.py', 'test_files__getent_does_not_handle_root')
def test_files_does_not_handle_root(self, multihost):
"""
:title: files: files provider does not handle root
Expand All @@ -39,6 +40,7 @@ def test_files_does_not_handle_root(self, multihost):
exit_status, _ = get_sss_user(multihost, 'root')
assert exit_status == 2

@pytest.mark.converted('test_files.py', 'test_files__simple_getent')
def test_files_sanity(self, multihost):
"""
:title: files: Test that the files provider can resolve a user
Expand All @@ -49,6 +51,7 @@ def test_files_sanity(self, multihost):
exit_status, _ = get_sss_user(multihost, 'lcl1')
assert exit_status == 0

@pytest.mark.converted('test_files.py', 'test_files__enumeration')
def test_files_enumeration(self, multihost):
"""
:title: files: Verify files provider do not enumerate
Expand All @@ -62,6 +65,7 @@ def test_files_enumeration(self, multihost):
cmd = multihost.master[0].run_command('getent passwd -s sss')
assert len(cmd.stdout_text) == 0

@pytest.mark.converted('test_files.py', 'test_files__user_modify')
def test_updated_homedir(self, multihost):
"""
:title: files: Test that homedir is updated
Expand Down
120 changes: 120 additions & 0 deletions src/tests/system/tests/test_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""
Files test provider cases
:requirement: IDM-SSSD-REQ :: SSSD is default for local resolution
"""

from __future__ import annotations

import time

import pytest
from sssd_test_framework.roles.client import Client
from sssd_test_framework.topology import KnownTopology


@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__getent_does_not_handle_root(client: Client):
"""
:title: Getent call doesnt work on root, when service specified as "sss"
:setup:
1. Enable files domain
2. Start SSSD
:steps:
1. getent passwd -s sss root
:expectedresults:
1. Call failed
: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"


@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__simple_getent(client: Client):
"""
:title: Simple getent call
:setup:
1. Add local user "user1"
2. Enable files domain
3. Start SSSD
:steps:
1. getent passwd -s sss user1
2. Check uid of result
:expectedresults:
1. Call was successful
2. Uid is correct
: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"


@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__enumeration(client: Client):
"""
:title: Files provider should not enumerate
:setup:
1. Enable files domain
2. Start SSSD
:steps:
1. getent passwd -s sss without specified user
:expectedresults:
1. Output is empty
:customerscenario: False
"""
client.sssd.sssd["enable_files_domain"] = "true"
client.sssd.start()

result = client.host.ssh.run("getent passwd -s sss")
assert not result.stdout


@pytest.mark.builtwith("files-provider")
@pytest.mark.topology(KnownTopology.Client)
def test_files__user_modify(client: Client):
"""
:title: User have his homedir updated, after passwd
:setup:
1. Add local user "user1" with specified homedir
2. Enable files domain
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
:expectedresults:
1. Call is successful
2. homedir is correct
3. homedir modified successfully
4. Slept well
5. homedir is updated correctly
:customerscenario: False
"""
client.local.user("user1").add(password="Secret123", home="/tmp")
client.sssd.sssd["enable_files_domain"] = "true"
client.sssd.start()

result = client.tools.getent.passwd("user1", service="sss")
assert result is not None
assert result.home == "/tmp"

client.local.user("user1").modify(home="/home/user1")

time.sleep(1)
result = client.tools.getent.passwd("user1", service="sss")
assert result is not None
assert result.home == "/home/user1"

0 comments on commit ea7273b

Please sign in to comment.