mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
feat: support IPv6 /64 range in white IP validation
- Split IP validation logic for IPv4 and IPv6 addresses - Add specific validation for IPv6 to allow only single addresses (/128) or /64 ranges - Remove old network address calculation for IPv6 - Keep IPv4 address limit validation unchanged - Add localization for new IPv6 validation error message - Add test coverage for IPv6 validation: * Test for valid /64 range * Test for valid single address * Test for invalid ranges (/48 and /96)
This commit is contained in:
parent
66619f12fe
commit
bc01dfaa3a
3 changed files with 65 additions and 19 deletions
|
@ -53,6 +53,35 @@ class WhiteIpTest < ActiveSupport::TestCase
|
|||
assert_not WhiteIp.include_ip?('192.168.1.1')
|
||||
end
|
||||
|
||||
def test_validates_ipv6_64_range
|
||||
white_ip = WhiteIp.new
|
||||
white_ip.registrar = registrars(:bestnames)
|
||||
white_ip.ipv6 = '2001:db8::/64'
|
||||
|
||||
assert white_ip.valid?, 'IPv6 /64 range should be valid'
|
||||
end
|
||||
|
||||
def test_validates_ipv6_single_address
|
||||
white_ip = WhiteIp.new
|
||||
white_ip.registrar = registrars(:bestnames)
|
||||
white_ip.ipv6 = '2001:db8::1'
|
||||
|
||||
assert white_ip.valid?, 'Single IPv6 address should be valid'
|
||||
end
|
||||
|
||||
def test_rejects_invalid_ipv6_range
|
||||
white_ip = WhiteIp.new
|
||||
white_ip.registrar = registrars(:bestnames)
|
||||
|
||||
white_ip.ipv6 = '2001:db8::/48'
|
||||
assert white_ip.invalid?, 'IPv6 /48 range should be invalid'
|
||||
assert_includes white_ip.errors.full_messages, 'IPv6 address must be either a single address or a /64 range'
|
||||
|
||||
white_ip.ipv6 = '2001:db8::/96'
|
||||
assert white_ip.invalid?, 'IPv6 /96 range should be invalid'
|
||||
assert_includes white_ip.errors.full_messages, 'IPv6 address must be either a single address or a /64 range'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_white_ip
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue