Skip to content

Commit

Permalink
Added tests for private networks
Browse files Browse the repository at this point in the history
  • Loading branch information
quintindunn committed Jun 29, 2024
1 parent a39161b commit 225d4f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/tests/private_ip_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import socket
from unittest import TestCase

import sys

sys.path.append("..")

from crawler.networking import is_host_private


class TestURLs(TestCase):
def test_private_ips(self):
private = True
public = False

cases = [
["google.com", public],
["8.8.8.8", public],
["1.1.1.1", public],
["example.com", public],
["github.com", public],
["localhost", private],
["127.0.0.1", private],
[socket.gethostbyname(socket.gethostname()), private],
]

for host, expected in cases:
is_private = is_host_private(host=host)
self.assertEqual(is_private, expected)
2 changes: 0 additions & 2 deletions src/tests/url_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os.path
import shutil
from unittest import TestCase

import sys
Expand Down

0 comments on commit 225d4f4

Please sign in to comment.