mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 00:12:03 +02:00
Merge pull request #2771 from internetee/ipv6-whitelist-support
feat: support IPv6 /64 range in white IP validation
This commit is contained in:
commit
8d33bd5de0
4 changed files with 67 additions and 21 deletions
|
@ -61,7 +61,7 @@ class ReppV1WhiteIpsCreateTest < ActionDispatch::IntegrationTest
|
|||
refute ActionMailer::Base.deliveries.last
|
||||
end
|
||||
|
||||
def test_validates_ip_max_count
|
||||
def test_validates_ipv6_range
|
||||
request_body = {
|
||||
white_ip: {
|
||||
address: '2001:db8::/120',
|
||||
|
@ -73,7 +73,7 @@ class ReppV1WhiteIpsCreateTest < ActionDispatch::IntegrationTest
|
|||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert json[:message].include? 'IP address limit exceeded'
|
||||
assert json[:message].include? 'IPv6 address must be either a single address or a /64 range'
|
||||
end
|
||||
|
||||
def test_returns_error_response_if_throttled
|
||||
|
|
|
@ -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