From fcbdb5a65f464cf16322e026530c7b922a0363e0 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Sun, 6 Feb 2022 19:34:10 -0500 Subject: [PATCH] Common: Remove disused get_host_from_network_location() function --- monkey/common/network/network_utils.py | 13 ------------- .../unit_tests/common/network/test_network_utils.py | 13 +------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/monkey/common/network/network_utils.py b/monkey/common/network/network_utils.py index 3c87d5737..c0c04a9d0 100644 --- a/monkey/common/network/network_utils.py +++ b/monkey/common/network/network_utils.py @@ -3,19 +3,6 @@ from typing import Optional, Tuple from urllib.parse import urlparse -def get_host_from_network_location(network_location: str) -> str: - """ - URL structure is ":///;?#" ( - https://tools.ietf.org/html/rfc1808.html) - And the net_loc is ":@:" ( - https://tools.ietf.org/html/rfc1738#section-3.1) - :param network_location: server network location - :return: host part of the network location - """ - url = urlparse("http://" + network_location) - return str(url.hostname) - - def remove_port(url): parsed = urlparse(url) with_port = f"{parsed.scheme}://{parsed.netloc}" diff --git a/monkey/tests/unit_tests/common/network/test_network_utils.py b/monkey/tests/unit_tests/common/network/test_network_utils.py index e7d82e649..969837ee5 100644 --- a/monkey/tests/unit_tests/common/network/test_network_utils.py +++ b/monkey/tests/unit_tests/common/network/test_network_utils.py @@ -1,20 +1,9 @@ from unittest import TestCase -from common.network.network_utils import ( - address_to_ip_port, - get_host_from_network_location, - remove_port, -) +from common.network.network_utils import address_to_ip_port, remove_port class TestNetworkUtils(TestCase): - def test_get_host_from_network_location(self): - assert get_host_from_network_location("127.0.0.1:12345") == "127.0.0.1" - assert get_host_from_network_location("127.0.0.1:12345") == "127.0.0.1" - assert get_host_from_network_location("127.0.0.1") == "127.0.0.1" - assert get_host_from_network_location("www.google.com:8080") == "www.google.com" - assert get_host_from_network_location("user:password@host:8080") == "host" - def test_remove_port_from_url(self): assert remove_port("https://google.com:80") == "https://google.com" assert remove_port("https://8.8.8.8:65336") == "https://8.8.8.8"