From 86fa418dea646e52929b9df9163902c4728442d1 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Sat, 16 Dec 2023 13:58:58 +0100 Subject: [ruby/ipaddr] Consider IPv4-mapped IPv6 addresses link local/loopback if IPV4 address is private Same as #57 https://github.com/ruby/ipaddr/commit/d56acecb80 --- test/test_ipaddr.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb index 21843a04e7..4829d9620c 100644 --- a/test/test_ipaddr.rb +++ b/test/test_ipaddr.rb @@ -415,6 +415,12 @@ class TC_Operator < Test::Unit::TestCase assert_equal(true, IPAddr.new('::1').loopback?) assert_equal(false, IPAddr.new('::').loopback?) assert_equal(false, IPAddr.new('3ffe:505:2::1').loopback?) + + assert_equal(true, IPAddr.new('::ffff:127.0.0.1').loopback?) + assert_equal(true, IPAddr.new('::ffff:127.127.1.1').loopback?) + assert_equal(false, IPAddr.new('::ffff:0.0.0.0').loopback?) + assert_equal(false, IPAddr.new('::ffff:192.168.2.0').loopback?) + assert_equal(false, IPAddr.new('::ffff:255.0.0.0').loopback?) end def test_private? @@ -482,6 +488,15 @@ class TC_Operator < Test::Unit::TestCase assert_equal(false, IPAddr.new('fb84:8bf7:e905::1').link_local?) assert_equal(true, IPAddr.new('fe80::dead:beef:cafe:1234').link_local?) + + assert_equal(false, IPAddr.new('::ffff:0.0.0.0').link_local?) + assert_equal(false, IPAddr.new('::ffff:127.0.0.1').link_local?) + assert_equal(false, IPAddr.new('::ffff:10.0.0.0').link_local?) + assert_equal(false, IPAddr.new('::ffff:172.16.0.0').link_local?) + assert_equal(false, IPAddr.new('::ffff:192.168.0.0').link_local?) + + assert_equal(true, IPAddr.new('::ffff:169.254.1.1').link_local?) + assert_equal(true, IPAddr.new('::ffff:169.254.254.255').link_local?) end def test_hash -- cgit v1.2.3