php icon indicating copy to clipboard operation
php copied to clipboard

Fix ipv6 notations and add tests

Open rvalitov opened this issue 9 months ago • 5 comments

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 get method to normalize and return IPv6 addresses in the same notation as the input, ensuring consistency between user input and cached data.
    • Added a new getIpAddress method to extract and normalize IP addresses from cache keys.
    • Enhanced the sanitizeName method to normalize IPv6 addresses by converting them into a standard notation and replacing forbidden characters in cache keys.

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 testLookup and testGetBatchDetails to reflect updated data received from the API.
  • Tests For Users With Free Token:

    • Adjusted tests so that they can run for tokens with least privileges.

rvalitov avatar Apr 25 '25 12:04 rvalitov

All tests fail automatically because of outdated action upload-artifact, see https://github.com/ipinfo/php/pull/86

rvalitov avatar Apr 25 '25 12:04 rvalitov

@rvalitov please rebase your PR with the latest from master

max-ipinfo avatar May 13 '25 17:05 max-ipinfo

@max-ipinfo done!

rvalitov avatar May 14 '25 10:05 rvalitov

@max-ipinfo is it OK now?

rvalitov avatar May 21 '25 11:05 rvalitov

@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.

max-ipinfo avatar May 21 '25 14:05 max-ipinfo