-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a39161b
commit 225d4f4
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|