Commit bb3d5e5c authored by Romain Courteaud's avatar Romain Courteaud

Test root url with the ending /

This is the default Chrome behaviour
parent 389b5eba
......@@ -173,7 +173,7 @@ def filterWarningStatus(
domain_list = [
x
for x in domain_list
if "%s%s" % (prefix, x) not in not_critical_url_list
if "%s%s/" % (prefix, x) not in not_critical_url_list
]
if status_dict["tcp_server"][i]["port"] == 25:
has_intersection = (
......@@ -199,7 +199,7 @@ def filterWarningStatus(
< (parsedate_to_datetime(not_after) - now).total_seconds()
)
) or (
("https://%s" % status_dict["ssl_certificate"][i]["hostname"])
("https://%s/" % status_dict["ssl_certificate"][i]["hostname"])
in not_critical_url_list
):
# Warn 2 weeks before expiration
......@@ -291,7 +291,7 @@ class WebBot:
# Domain not explicitely checked
# Skip both root url
for protocol in ("http", "https"):
not_critical_url = "%s://%s" % (protocol, hostname)
not_critical_url = "%s://%s/" % (protocol, hostname)
if not_critical_url not in url_list:
not_critical_url_list.append(not_critical_url)
return not_critical_url_list
......@@ -373,7 +373,7 @@ class WebBot:
# If certificate is not valid,
# no need to do another query
continue
url = "%s://%s" % (protocol, hostname)
url = "%s://%s/" % (protocol, hostname)
if url not in url_dict:
url_dict[url] = []
url_dict[url].append(server_ip)
......@@ -637,7 +637,9 @@ class WebBot:
protocol = {80: "http", 443: "https", 25: "smtp"}[
network_change["port"]
]
url = "%s://%s" % (protocol, hostname)
# Chrome automatically add the trailing /
# when user enter the domain name
url = "%s://%s/" % (protocol, hostname)
if url not in url_dict:
url_dict[url] = []
url_dict[url].append(network_change["ip"])
......
......@@ -37,7 +37,7 @@ def getUrlHostname(url):
def getRootUrl(url):
parsed_url = urlparse(url)
return "%s://%s" % (parsed_url.scheme, parsed_url.hostname)
return "%s://%s/" % (parsed_url.scheme, parsed_url.hostname)
def getUserAgent(version):
......
......@@ -212,8 +212,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://example.org"),
("1.2.3.4", "https://example.org"),
("1.2.3.4", "http://example.org/"),
("1.2.3.4", "https://example.org/"),
],
)
......@@ -323,8 +323,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://example.org"),
("1.2.3.4", "https://example.org"),
("1.2.3.4", "http://example.org/"),
("1.2.3.4", "https://example.org/"),
],
)
......@@ -440,10 +440,10 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://%s" % domain_1),
("1.2.3.4", "http://%s" % domain_2),
("1.2.3.4", "https://%s" % domain_1),
("1.2.3.4", "https://%s" % domain_2),
("1.2.3.4", "http://%s/" % domain_1),
("1.2.3.4", "http://%s/" % domain_2),
("1.2.3.4", "https://%s/" % domain_1),
("1.2.3.4", "https://%s/" % domain_2),
],
)
......@@ -558,10 +558,10 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://%s" % domain),
("1.2.3.5", "http://%s" % domain),
("1.2.3.4", "https://%s" % domain),
("1.2.3.5", "https://%s" % domain),
("1.2.3.4", "http://%s/" % domain),
("1.2.3.5", "http://%s/" % domain),
("1.2.3.4", "https://%s/" % domain),
("1.2.3.5", "https://%s/" % domain),
],
)
......@@ -677,10 +677,10 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://%s" % domain),
("1.2.3.4", "http://%s" % sub_domain),
("1.2.3.4", "https://%s" % domain),
("1.2.3.4", "https://%s" % sub_domain),
("1.2.3.4", "http://%s/" % domain),
("1.2.3.4", "http://%s/" % sub_domain),
("1.2.3.4", "https://%s/" % domain),
("1.2.3.4", "https://%s/" % sub_domain),
],
)
......@@ -783,8 +783,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://%s" % sub_domain),
("1.2.3.4", "https://%s" % sub_domain),
("1.2.3.4", "http://%s/" % sub_domain),
("1.2.3.4", "https://%s/" % sub_domain),
],
)
......@@ -883,8 +883,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange(
bot,
[
("1.2.3.4", "http://%s" % domain),
("1.2.3.4", "https://%s" % domain),
("1.2.3.4", "http://%s/" % domain),
("1.2.3.4", "https://%s/" % domain),
("1.2.3.4", "https://example.org/foo"),
],
)
......
......@@ -52,7 +52,7 @@ class SurykatkaHttpTestCase(unittest.TestCase):
################################################
def test_getRootUrl(self):
result = getRootUrl("https://example.org/foo?bar=1")
assert result == "https://example.org"
assert result == "https://example.org/"
################################################
# getUserAgent
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment