Skip to content

tests: Add incomplete triples and complex hierarchy netgroup tests#8262

Merged
ikerexxe merged 2 commits intoSSSD:masterfrom
madhuriupadhye:netgroup1
Dec 9, 2025
Merged

tests: Add incomplete triples and complex hierarchy netgroup tests#8262
ikerexxe merged 2 commits intoSSSD:masterfrom
madhuriupadhye:netgroup1

Conversation

@madhuriupadhye
Copy link
Contributor

Adds two new netgroup tests.

  1. test_netgroup__incomplete_triples - Verifies netgroups with missing host/user/domain fields work correctly

  2. test_netgroups__complex_hierarchy - Verifies multi-level nested netgroups resolve inherited members correctly

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds two valuable system tests for netgroups, covering incomplete triples and complex hierarchies. The tests are well-structured and improve coverage. I've identified a correctness issue in the assertions of test_netgroup__incomplete_triples and suggested a fix to make it more robust. Additionally, I've proposed refactoring the assertions in test_netgroups__complex_hierarchy for better conciseness and reliability. With these changes, the new tests will be excellent additions to the suite.

:customerscenario: False
"""
if not isinstance(provider, (LDAP, Samba, AD)):
raise ValueError("IPA does not support domain in netgroups")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pytest skip instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in all test cases.


# Level 1: Base netgroups with only triples (no nested members)
ng_base1 = provider.netgroup("ng-base1").add()
ng_base1.add_member(host="host1", user="user1", domain="ldap.test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is everywhere hardcoded ldap.test domain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in all test cases.

Copy link
Contributor

@jakub-vavra-cz jakub-vavra-cz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this. I noticed the commit structure, and I think we need to clean it up before merging to maintain a clear git history and simplify cherry-picking for maintenance branches.

Commit number 2 changes code introduced in commit number 1 and it also refactors already existing code. My suggestion would be to:

  • Commit 1: pure refactoring of the original, existing tests. This commit must pass tests on its own.
  • Commit 2: add the two new test cases using the new, refactored structure.

@madhuriupadhye madhuriupadhye force-pushed the netgroup1 branch 12 times, most recently from c5415b7 to 2048c0c Compare December 8, 2025 12:51
@madhuriupadhye madhuriupadhye force-pushed the netgroup1 branch 2 times, most recently from 1c98a62 to bbc14e9 Compare December 8, 2025 13:01
@madhuriupadhye madhuriupadhye force-pushed the netgroup1 branch 6 times, most recently from 6a7e6b0 to 2692665 Compare December 8, 2025 16:33
Copy link
Contributor

@jakub-vavra-cz jakub-vavra-cz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Replace hardcoded "ldap.test" domain strings with dynamic `provider.domain`
and fix type checking errors in netgroup tests.

Changes:
- Remove `raise ValueError` and `pytest.skip` isinstance checks since
  topology markers already restrict tests to LDAP, AD, and Samba providers
- Change function signatures from `GenericProvider` to `AD | LDAP | Samba`
  to match the topology decorators
- Replace all hardcoded "ldap.test" with `provider.domain` for dynamic
  domain resolution across different provider topologies
- Rework parametrized test to use boolean flag and format string with
  `{domain}` placeholder for runtime substitution
- Fix type errors by passing netgroup names as strings instead of objects
  to `add_member(ng=...)` calls
- Fix type conflict by using separate variable names (`passwd_result`,
  `group_result`) for different entry types

Affected tests:
- test_netgroup__user_attribute_membernisnetgroup_uses_group_dn
- test_netgroup__lookup_nested_groups
- test_netgroup__lookup_nested_groups_with_host_and_domain_values_present
- test_netgroup__uid_gt_2147483647

Signed-off-by: Madhuri Upadhye <mupadhye@redhat.com>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Jakub Vávra <jvavra@redhat.com>
Add new test cases to verify netgroup functionality with incomplete
triples and complex nested hierarchies.

New tests:
- test_netgroup__incomplete_triples: Verify netgroups with various
  incomplete triple combinations (empty, only host, only user, only
  domain, missing host, missing user, missing domain)
- test_netgroups__complex_hierarchy: Verify netgroups with multiple
  levels of nesting (base -> mid -> top) work correctly and return
  the expected combination of direct triples and inherited members

Signed-off-by: Madhuri Upadhye <mupadhye@redhat.com>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Jakub Vávra <jvavra@redhat.com>
@sssd-bot
Copy link
Contributor

sssd-bot commented Dec 9, 2025

The pull request was accepted by @ikerexxe with the following PR CI status:


🟢 CodeFactor (success)
🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-41-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / cppcheck (success)
🔴 ci / intgcheck (centos-10) (failure)
🟢 ci / intgcheck (fedora-41) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-41) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (success)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / codeql (success)
🟢 Static code analysis / pre-commit (success)
🟢 Static code analysis / python-system-tests (success)


There are unsuccessful or unfinished checks. Make sure that the failures are not related to this pull request before merging.

@ikerexxe
Copy link
Contributor

ikerexxe commented Dec 9, 2025

Failure in intgcheck (centos-10) is unrelated, so merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants