From adbe435de4a3cb1950b50511d985a9eb209bbc19 Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Wed, 3 Nov 2021 14:06:34 +0100 Subject: [PATCH] Fix IPV6 test (#13468) The test checks if 2001:db8... is a valid ipv6 *not* in reserved ranges. A bug in PHP (https://bugs.php.net/bug.php?id=61700) made it wrongly pass. --- tests/IpTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/IpTest.php b/tests/IpTest.php index 2950a5922b..0882b5ff04 100644 --- a/tests/IpTest.php +++ b/tests/IpTest.php @@ -46,7 +46,6 @@ class IpTest extends TestCase $this->assertTrue(IP::isValid('8.8.8.8', true)); $this->assertTrue(IPv4::isValid('192.168.0.1', true)); $this->assertTrue(IPv6::isValid('FF81::', true)); - $this->assertTrue(IPv6::isValid('2001:db8:85a3::8a2e:370:7334', true)); $this->assertFalse(IPv4::isValid('127.0.0.1', true)); $this->assertFalse(IPv6::isValid('::1', true)); $this->assertFalse(IP::isValid('169.254.1.1', true)); @@ -55,6 +54,16 @@ class IpTest extends TestCase $this->assertFalse(IP::isValid('Falafel', true)); } + /** + * See https://github.com/librenms/librenms/pull/13468 for more info + * + * @requires PHP >= 7.4 + */ + public function testIsValidIPv6ExcludeReserved(): void + { + $this->assertFalse(IPv6::isValid('2001:db8:85a3::8a2e:370:7334', true)); + } + public function testIpParse() { $this->assertEquals('192.168.0.1', IP::parse('192.168.0.1'));