|
| 1 | +""" |
| 2 | +SUDO Responder Tests. |
| 3 | +
|
| 4 | +:requirement: sudo |
| 5 | +""" |
| 6 | + |
| 7 | +from __future__ import annotations |
| 8 | +from sssd_test_framework.roles.client import Client |
| 9 | +from sssd_test_framework.roles.generic import GenericProvider |
| 10 | +from sssd_test_framework.topology import KnownTopology |
| 11 | + |
| 12 | +import pytest |
| 13 | + |
| 14 | + |
| 15 | +@pytest.mark.importance("critical") |
| 16 | +@pytest.mark.topology(KnownTopology.BareAD) |
| 17 | +@pytest.mark.topology(KnownTopology.BareIPA) |
| 18 | +@pytest.mark.topology(KnownTopology.BareLDAP) |
| 19 | +@pytest.mark.ticket(jira=["RHEL-59136", "RHEL-127359", "RHEL-127360"]) |
| 20 | +def test__env_shell_once(client: Client, provider: GenericProvider): |
| 21 | + """ |
| 22 | + :title: Environment variable SHELL is not duplicated |
| 23 | + :setup: |
| 24 | + 1. Create user "user-1" with shell /bin/zsh |
| 25 | + 2. Create sudorule to allow "user-1" run "/usr/bin/env on all hosts |
| 26 | + 3. Enable SSSD sudo responder and start SSSD |
| 27 | + :steps: |
| 28 | + 1. Run "sudo /usr/bin/env" as user-1 |
| 29 | + 2. Check if variable SHELL is present only once |
| 30 | + :expectedresults: |
| 31 | + 1. Command is executed successfully |
| 32 | + 2. Variable SHELL is present only once |
| 33 | + :customerscenario: True |
| 34 | + """ |
| 35 | + client.host.ssh.run("dnf install zsh -y") |
| 36 | + u = provider.user("user-1").add(uid=10001, gid=10001, shell="/bin/zsh") |
| 37 | + provider.sudorule("test").add(user=u, host="ALL", command="/bin/env") |
| 38 | + |
| 39 | + client.sssd.common.sudo() |
| 40 | + client.sssd.start() |
| 41 | + result = client.auth.sudo.run("user-1", "Secret123", command="/usr/bin/env") |
| 42 | + assert result.returncode == 0, "Sudo command failed!" |
| 43 | + assert result.stdout.count("SHELL") == 1, "Variable SHELL is duplicated!" |
0 commit comments