Skip to content

Commit

Permalink
Tests: sudo rule defaults
Browse files Browse the repository at this point in the history
A sudo rule defaults (special condition) is tested here. The rule
with 'defaults' cn is added and additional option of '!authenticate'
  • Loading branch information
shridhargadekar committed Mar 22, 2024
1 parent f0fc17a commit e0b362b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/tests/system/tests/test_sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,39 @@ def test_sudo__local_users_negative_cache(client: Client, provider: LDAP, sssd_s

result = client.tools.tshark(["-r", "/tmp/sssd.pcap", "-V", "-2", "-R", "ldap.filter"])
assert "uid=user-1" not in result.stdout



@pytest.mark.importance("critical")
@pytest.mark.authorization
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
@pytest.mark.parametrize("sssd_service_user", ("root", "sssd"))
@pytest.mark.require(
lambda client, sssd_service_user: ((sssd_service_user == "root") or client.features["non-privileged"]),
"SSSD was built without support for running under non-root",
)
def test_sudo__defaults_rule(client: Client, provider: GenericProvider, sssd_service_user: str):
"""
:title: Defautls rule behavior
:setup:
1. Create user "user-1"
2. Create sudorule named default with option '!authenticate'
3. Enable SSSD sudo responder
4. Start SSSD
:steps:
1. List sudo rules for "user-1"
2. Run "sudo /bin/ls root" as user-1
:expectedresults:
1. User is able to run sudo commands on client
2. Command is successful
:customerscenario: False
"""
u = provider.user("user-1").add()

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable u is not used.
provider.sudorule("defaults").add(option="!authenticate", command="/bin/ls")

client.sssd.set_service_user(sssd_service_user)
client.sssd.common.sudo()
client.sssd.start()

assert client.auth.sudo.list("user-1", expected=["(root) /bin/ls"])
assert client.auth.sudo.list("user-1", "Secret123", expected=["(root) /bin/ls"])

0 comments on commit e0b362b

Please sign in to comment.