Fix ipv6 notations and add tests
This pull request introduces enhancements to the DefaultCache class to handle IPv6 addresses with various notations, adds new methods for IP normalization, and significantly expands test coverage to ensure correctness. The changes focus on improving cache key handling, ensuring consistent behavior for IP addresses with different notations, and extending test cases for both IPv4 and IPv6 scenarios. Supersedes and closes #78 and fixes #70 .
Enhancements to DefaultCache:
-
Improved IPv6 Handling:
- Updated the
getmethod to normalize and return IPv6 addresses in the same notation as the input, ensuring consistency between user input and cached data. - Added a new
getIpAddressmethod to extract and normalize IP addresses from cache keys. - Enhanced the
sanitizeNamemethod to normalize IPv6 addresses by converting them into a standard notation and replacing forbidden characters in cache keys.
- Updated the
Expanded Test Coverage:
-
New Test Cases for IPv6 Handling:
- Added tests to verify that the cache correctly handles IPv6 addresses with different notations (e.g., compressed, expanded, uppercase).
- Introduced tests for IPv6 addresses with postfixes to ensure unique cache entries for variations.
- Added tests to validate caching behavior for IPv6 notations, ensuring cache hits for equivalent addresses.
-
Updated Test Data:
- Adjusted test data in
testLookupandtestGetBatchDetailsto reflect updated data received from the API.
- Adjusted test data in
-
Tests For Users With Free Token:
- Adjusted tests so that they can run for tokens with least privileges.
All tests fail automatically because of outdated action upload-artifact, see https://github.com/ipinfo/php/pull/86
@rvalitov please rebase your PR with the latest from master
@max-ipinfo done!
@max-ipinfo is it OK now?
@max-ipinfo is it OK now?
Sorry @rvalitov for my latency.
I am planning on taking a final look. Once that's done, I'll approve and will submit your PR to cut a brand new release.