Browse Source

Add test for IPv6 in deny list (#41517)

Alexander Tarasov 2 years ago
parent
commit
9708ac751a
1 changed files with 11 additions and 0 deletions
  1. 11 0
      tests/sentry/net/test_socket.py

+ 11 - 0
tests/sentry/net/test_socket.py

@@ -17,6 +17,17 @@ class SocketTest(TestCase):
         is_ipaddress_allowed.cache_clear()
         assert is_ipaddress_allowed("1.1.1.1") is True
 
+    @override_blacklist("::ffff:10.0.0.0/104", "::1/128")
+    def test_is_ipaddress_allowed_ipv6(self):
+        is_ipaddress_allowed.cache_clear()
+        assert is_ipaddress_allowed("::1") is False
+        is_ipaddress_allowed.cache_clear()
+        assert is_ipaddress_allowed("::ffff:10.0.1.2") is False
+        is_ipaddress_allowed.cache_clear()
+        assert is_ipaddress_allowed("::ffff:1.1.1.1") is True
+        is_ipaddress_allowed.cache_clear()
+        assert is_ipaddress_allowed("2001:db8:a::123") is True
+
     @override_blacklist("10.0.0.0/8", "127.0.0.1")
     @patch("socket.getaddrinfo")
     def test_is_safe_hostname(self, mock_getaddrinfo):