Add tests for IPv4/IPv6 with CIDR mask in sudoHost#32
Open
shridhargadekar wants to merge 1 commit into
Open
Conversation
Reviewer's GuideAdds two critical BareLDAP sudo tests that validate sudoHost behavior for IPv4/IPv6 addresses with and without CIDR masks, covering both allowed and denied access cases based on client IP matching. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The two tests share a lot of setup/teardown logic (configuring client IP, adding user/sudorule, starting SSSD, and deleting IP); consider extracting this into a helper or fixture and parameterizing only the expected outcome to reduce duplication and make future changes easier.
- Using
if "ipv6" in ip_typeto decide whether to use IPv6-specific commands is a bit fragile; switching to an explicit enum or boolean flag (e.g.,is_ipv6) in the parametrization would make the logic clearer and less error-prone if additional IP types are added later.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The two tests share a lot of setup/teardown logic (configuring client IP, adding user/sudorule, starting SSSD, and deleting IP); consider extracting this into a helper or fixture and parameterizing only the expected outcome to reduce duplication and make future changes easier.
- Using `if "ipv6" in ip_type` to decide whether to use IPv6-specific commands is a bit fragile; switching to an explicit enum or boolean flag (e.g., `is_ipv6`) in the parametrization would make the logic clearer and less error-prone if additional IP types are added later.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
7f7b275 to
a689f6e
Compare
- test_sudo__host_ipv4_ipv6_with_mask_allowed:
allowed access when client IP matches sudoHost
(IPv4 with mask, IPv6, IPv6 with mask)
- test_sudo__host_ipv4_ipv6_with_mask_denied:
Tests denied access when client IP doesn't match sudoHost
Each test is parameterized to cover 3 scenarios (6 total test runs).
Tests verify that sudoHost works correctly with IPv4/IPv6 addresses and CIDR notation
Signed-off-by: shridhargadekar <shridhar.always@gmail.com>
a689f6e to
00c7b82
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_sudo__host_ipv4_ipv6_with_mask_allowed: allowed access when client IP matches sudoHost (IPv4 with mask, IPv6, IPv6 with mask)
test_sudo__host_ipv4_ipv6_with_mask_denied: Tests denied access when client IP doesn't match sudoHost
Each test is parameterized to cover 3 scenarios (6 total test runs). Tests verify that sudoHost works correctly with IPv4/IPv6 addresses and CIDR notation
Summary by Sourcery
Add critical sudoHost IP-based sudo rule tests covering IPv4/IPv6 address and CIDR mask handling for allowed and denied access scenarios.
Tests: