Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: ldap search base does not fully limit the Netgroup search base #7754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/tests/system/tests/test_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
from sssd_test_framework.topology import KnownTopology


def clean_restart_sssd(client):
"""
This function will clean cache and restart sssd
"""
client.sssd.stop()
client.sssd.clear(db=True, memcache=True, logs=True)
client.sssd.start()
time.sleep(5)


@pytest.mark.ticket(bz=[795044, 1695574])
@pytest.mark.importance("critical")
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify", "exop_force"])
Expand Down Expand Up @@ -538,3 +548,56 @@ def test_ldap__empty_attribute(client: Client, ldap: LDAP):
for grp in ["Group_1", "Group_2"]:
assert client.tools.getent.group(grp) is not None
assert client.auth.ssh.password(user.name, "Secret123"), "User login failed!"


@pytest.mark.importance("low")
@pytest.mark.topology(KnownTopology.LDAP)
def test_netgroup_search_base(client: Client, provider: LDAP):
"""
:title: ldap search base does not fully limit the netgroup search base
:setup:
1. Netgroups are created in different ous
2. Members are added to netgroups
:steps:
1. Assert the Seceng netgroup exists
2. The ldap search base is reconfigured to only include ou=Netgroup1
3. The same Seceng netgroup verification is performed after restarting SSSD and ldap
search base limits the netgroup search base
:expectedresults:
1. Netgroup look up should success
1. The ldap search base is reconfigured
1. Netgroup look up should success but with search base limits
:customerscenario: True
"""
ou1 = provider.ou("Netgroup1").add()
ou2 = provider.ou("Netgroup2").add()

qe_eng = provider.netgroup("QEeng", basedn=ou1).add()
qe_eng.add_member(host="h1", user="QEuser", domain="ldap.test")

sys_admin = provider.netgroup("Sysadmin", basedn=ou2).add()
sys_admin.add_member(host="h2", user="Sysuser", domain="ldap.test")

core = provider.netgroup("Core", basedn=ou2).add()
core.add_member(host="h3", user="Coreuser", domain="ldap.test")

deveng = provider.netgroup("Deveng", basedn=ou2).add()
deveng.add_member(ng=core)

seceng = provider.netgroup("Seceng", basedn=ou1).add()
seceng.add_member(ng=deveng)
seceng.add_member(ng=qe_eng)

client.sssd.start()
result = client.tools.getent.netgroup("Seceng")
assert result is not None and result.name == "Seceng", "Netgroup Seceng was not found!"
assert "(h1,QEuser,ldap.test)" in result.members, "Member (h1, QEuser, ldap.test) not part of Seceng!"
assert "(h3,Coreuser,ldap.test)" in result.members, "Member (h3, Coreuser, ldap.test) not part of Seceng!"

client.sssd.dom("test")["ldap_search_base"] = "ou=Netgroup1,dc=ldap,dc=test"
clean_restart_sssd(client)

result = client.tools.getent.netgroup("Seceng")
assert result is not None and result.name == "Seceng", "Netgroup Seceng was not found!"
assert "(h1,QEuser,ldap.test)" in result.members, "Member (h1, QEuser, ldap.test) not part of Seceng!"
assert "(h3,Coreuser,ldap.test)" not in result.members, "Member (h3, Coreuser, ldap.test) part of Seceng!"
Loading