test: add tests for IpRestrictionService #3

Open
opened 2026-02-20 03:13:33 +00:00 by Clotho · 0 comments
Member

Missing Test Coverage

File: src/Api/Services/IpRestrictionService.php

What Needs Testing

  • CIDR notation validation (IPv4 and IPv6)
  • IP normalization and canonicalization
  • Whitelist input parsing (multi-line, comma-separated)
  • Edge cases:
    • Invalid CIDR ranges
    • IPv4-mapped IPv6 addresses
    • Localhost/private IP handling
    • Empty whitelist behavior

Context

This service handles security-critical IP validation for API key access control. Comprehensive test coverage is essential to ensure:

  • No bypass vulnerabilities
  • Proper handling of all IP formats
  • Correct CIDR bit masking

Implementation Notes

Create src/Api/Tests/Feature/IpRestrictionServiceTest.php with test cases for:

  1. isAllowed() with various IP/CIDR combinations
  2. ipv4MatchesCidr() edge cases
  3. ipv6MatchesCidr() with different prefix lengths
  4. parseWhitelistInput() with malformed input

Priority

High - Security feature requires thorough testing

## Missing Test Coverage **File**: `src/Api/Services/IpRestrictionService.php` ### What Needs Testing - CIDR notation validation (IPv4 and IPv6) - IP normalization and canonicalization - Whitelist input parsing (multi-line, comma-separated) - Edge cases: - Invalid CIDR ranges - IPv4-mapped IPv6 addresses - Localhost/private IP handling - Empty whitelist behavior ### Context This service handles security-critical IP validation for API key access control. Comprehensive test coverage is essential to ensure: - No bypass vulnerabilities - Proper handling of all IP formats - Correct CIDR bit masking ### Implementation Notes Create `src/Api/Tests/Feature/IpRestrictionServiceTest.php` with test cases for: 1. `isAllowed()` with various IP/CIDR combinations 2. `ipv4MatchesCidr()` edge cases 3. `ipv6MatchesCidr()` with different prefix lengths 4. `parseWhitelistInput()` with malformed input ### Priority High - Security feature requires thorough testing
Clotho added the
discovery
label 2026-02-20 03:13:33 +00:00
Charon added the
clotho
label 2026-02-20 10:57:38 +00:00
Charon added
PHP
testing
P2
and removed
clotho
discovery
labels 2026-02-20 12:17:10 +00:00
Clotho was assigned by Charon 2026-02-20 12:21:05 +00:00
Charon added the
agent-ready
label 2026-02-21 01:30:32 +00:00
Sign in to join this conversation.
No description provided.