Skip to content

Commit d62eab6

Browse files
committed
Tests: Test trasformation SSSD does not crash in nss responder after netgroup timeout when backend is offline
SSSD does not crash in nss responder after netgroup timeout when backend is offline
1 parent 196ad92 commit d62eab6

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

src/tests/system/tests/test_netgroups.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
from __future__ import annotations
88

9+
import time
10+
911
import pytest
1012
from sssd_test_framework.roles.ad import AD
1113
from sssd_test_framework.roles.client import Client
1214
from sssd_test_framework.roles.generic import GenericProvider
15+
from sssd_test_framework.roles.ipa import IPA
1316
from sssd_test_framework.roles.ldap import LDAP
1417
from sssd_test_framework.roles.samba import Samba
1518
from sssd_test_framework.topology import KnownTopology, KnownTopologyGroup
@@ -309,3 +312,107 @@ def test_netgroup__uid_gt_2147483647(client: Client, provider: GenericProvider):
309312
result = client.tools.getent.group(grpname)
310313
assert result is not None, f"getent group for group '{grpname}' is empty!"
311314
assert result.name == grpname, f"Group name '{grpname}' did not match result '{result.name}'!"
315+
316+
317+
@pytest.mark.importance("low")
318+
@pytest.mark.ticket(bz=1576852)
319+
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
320+
def test_netgroup__nss_responder(client: Client, provider: GenericProvider):
321+
"""
322+
:title: SSSD nss responder handles correctly netgroup timeout when backend is offline
323+
:setup:
324+
1. A user (user-1) and a netgroup (ng-1) are created, and the user is added as a member of the netgroup
325+
:steps:
326+
1. Update SSSD configuration with an incorrect server URI (e.g., typo.dc.hostname).
327+
2. SSSD is restarted to apply the new configuration
328+
3. Checks the status of the SSSD domain
329+
4. Capture the process ID (PID) of the sssd_nss process
330+
5. Try to retrieve the netgroup information again, expecting it to fail since the SSSD domain is offline
331+
6. Verify that the sssd_nss process ID has not changed, indicating that SSSD has not
332+
crashed or restarted unexpectedly
333+
:expectedresults:
334+
1. SSSD configured with incorrect server uri
335+
2. SSSD restarted
336+
3. SSSD domain is offline
337+
4. Pid of sssd_nss captured
338+
5. Netgroup info can't be retrieved
339+
6. SSSD nss responder has the same pid as before
340+
:customerscenario: True
341+
"""
342+
user = provider.user("user-1").add()
343+
netgroup = provider.netgroup("ng-1").add().add_member(user=user)
344+
345+
hostname = client.host.hostname
346+
if isinstance(provider, (AD)) or isinstance(provider, (Samba)):
347+
bad_ldap_uri = "typo.dc.%s" % hostname
348+
client.sssd.dom("test").update(ad_server=bad_ldap_uri)
349+
350+
elif isinstance(provider, (IPA)):
351+
bad_ldap_uri = "typo.master.%s" % hostname
352+
client.sssd.dom("test").update(ipa_server=bad_ldap_uri)
353+
354+
elif isinstance(provider, (LDAP)):
355+
bad_ldap_uri = "ldaps://typo.%s" % hostname
356+
client.sssd.dom("test").update(ldap_uri=bad_ldap_uri)
357+
358+
client.sssd.restart(clean=True)
359+
360+
# Check backend status
361+
assert client.sssd.default_domain is not None, "Failed to load default domain!"
362+
assert not client.sssctl.domain_status(client.sssd.default_domain)
363+
364+
pid_nss = "pidof sssd_nss"
365+
pid_nss1 = client.host.conn.run(pid_nss).stdout
366+
367+
# request for netgroup
368+
assert not client.tools.getent.netgroup(netgroup.name), f"Netgroup {netgroup.name} was unexpectedly retrieved."
369+
370+
pid_nss2 = client.host.conn.run(pid_nss).stdout
371+
assert pid_nss1 == pid_nss2, "sssd_nss process id changed!"
372+
373+
374+
@pytest.mark.importance("low")
375+
@pytest.mark.ticket(bz=1779486)
376+
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
377+
def test_netgroup__background_refresh(client: Client, provider: GenericProvider):
378+
"""
379+
:title: Verify Netgroup Membership Updates in SSSD Cache After User Addition and Cache Expiry
380+
:setup:
381+
1. Update SSSD configuration
382+
2. Restart SSSD
383+
3. Create a user and netgroup
384+
4. A second user is created and added to the netgroup
385+
:steps:
386+
1. The getent command succeeds in retrieving the netgroup
387+
2. Verify that user is member of the netgroup
388+
3. Wait for 30 seconds to allow the cache to expire and be refreshed
389+
4. The ldbsearch command is used to query the SSSD cache database (cache_test.ldb)
390+
to verify that second user is now part of the netgroup in the cache
391+
:expectedresults:
392+
1. Retrieves the netgroup information
393+
2. User is member of the netgroup
394+
3. Cache to expire and be refreshed
395+
4. Second user is now part of the netgroup in the cache
396+
:customerscenario: True
397+
"""
398+
client.sssd.dom("test").update(entry_cache_timeout="10", refresh_expired_interval="5")
399+
client.sssd.restart(clean=True)
400+
user = provider.user("user-1").add()
401+
netgroup = provider.netgroup("ng-1").add().add_member(user=user)
402+
403+
result = client.tools.getent.netgroup(netgroup.name)
404+
assert result is not None, "Could not get netgroup ng-1"
405+
assert result.members[0].user == "user-1"
406+
407+
user2 = provider.user("user-2").add()
408+
netgroup.add_member(user=user2.name)
409+
410+
time.sleep(30)
411+
412+
search_result = client.ldb.search("/var/lib/sss/db/cache_test.ldb", "cn=Netgroups,cn=test,cn=sysdb")
413+
assert search_result is not None, "Empty search result!"
414+
netgrp = search_result.get("name=ng-1,cn=Netgroups,cn=test,cn=sysdb")
415+
assert netgrp is not None, "Netgroup ng-1 not present in search result!"
416+
triple = netgrp.get("netgroupTriple")
417+
assert triple is not None, "Empty tripple!"
418+
assert user2.name in triple[1]

0 commit comments

Comments
 (0)