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( ...@@ -173,7 +173,7 @@ def filterWarningStatus(
domain_list = [ domain_list = [
x x
for x in domain_list 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: if status_dict["tcp_server"][i]["port"] == 25:
has_intersection = ( has_intersection = (
...@@ -199,7 +199,7 @@ def filterWarningStatus( ...@@ -199,7 +199,7 @@ def filterWarningStatus(
< (parsedate_to_datetime(not_after) - now).total_seconds() < (parsedate_to_datetime(not_after) - now).total_seconds()
) )
) or ( ) or (
("https://%s" % status_dict["ssl_certificate"][i]["hostname"]) ("https://%s/" % status_dict["ssl_certificate"][i]["hostname"])
in not_critical_url_list in not_critical_url_list
): ):
# Warn 2 weeks before expiration # Warn 2 weeks before expiration
...@@ -291,7 +291,7 @@ class WebBot: ...@@ -291,7 +291,7 @@ class WebBot:
# Domain not explicitely checked # Domain not explicitely checked
# Skip both root url # Skip both root url
for protocol in ("http", "https"): 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: if not_critical_url not in url_list:
not_critical_url_list.append(not_critical_url) not_critical_url_list.append(not_critical_url)
return not_critical_url_list return not_critical_url_list
...@@ -373,7 +373,7 @@ class WebBot: ...@@ -373,7 +373,7 @@ class WebBot:
# If certificate is not valid, # If certificate is not valid,
# no need to do another query # no need to do another query
continue continue
url = "%s://%s" % (protocol, hostname) url = "%s://%s/" % (protocol, hostname)
if url not in url_dict: if url not in url_dict:
url_dict[url] = [] url_dict[url] = []
url_dict[url].append(server_ip) url_dict[url].append(server_ip)
...@@ -637,7 +637,9 @@ class WebBot: ...@@ -637,7 +637,9 @@ class WebBot:
protocol = {80: "http", 443: "https", 25: "smtp"}[ protocol = {80: "http", 443: "https", 25: "smtp"}[
network_change["port"] 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: if url not in url_dict:
url_dict[url] = [] url_dict[url] = []
url_dict[url].append(network_change["ip"]) url_dict[url].append(network_change["ip"])
......
...@@ -37,7 +37,7 @@ def getUrlHostname(url): ...@@ -37,7 +37,7 @@ def getUrlHostname(url):
def getRootUrl(url): def getRootUrl(url):
parsed_url = urlparse(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): def getUserAgent(version):
......
...@@ -212,8 +212,8 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -212,8 +212,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://example.org"), ("1.2.3.4", "http://example.org/"),
("1.2.3.4", "https://example.org"), ("1.2.3.4", "https://example.org/"),
], ],
) )
...@@ -323,8 +323,8 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -323,8 +323,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://example.org"), ("1.2.3.4", "http://example.org/"),
("1.2.3.4", "https://example.org"), ("1.2.3.4", "https://example.org/"),
], ],
) )
...@@ -440,10 +440,10 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -440,10 +440,10 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://%s" % domain_1), ("1.2.3.4", "http://%s/" % domain_1),
("1.2.3.4", "http://%s" % domain_2), ("1.2.3.4", "http://%s/" % domain_2),
("1.2.3.4", "https://%s" % domain_1), ("1.2.3.4", "https://%s/" % domain_1),
("1.2.3.4", "https://%s" % domain_2), ("1.2.3.4", "https://%s/" % domain_2),
], ],
) )
...@@ -558,10 +558,10 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -558,10 +558,10 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://%s" % domain), ("1.2.3.4", "http://%s/" % domain),
("1.2.3.5", "http://%s" % domain), ("1.2.3.5", "http://%s/" % domain),
("1.2.3.4", "https://%s" % domain), ("1.2.3.4", "https://%s/" % domain),
("1.2.3.5", "https://%s" % domain), ("1.2.3.5", "https://%s/" % domain),
], ],
) )
...@@ -677,10 +677,10 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -677,10 +677,10 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://%s" % domain), ("1.2.3.4", "http://%s/" % domain),
("1.2.3.4", "http://%s" % sub_domain), ("1.2.3.4", "http://%s/" % sub_domain),
("1.2.3.4", "https://%s" % domain), ("1.2.3.4", "https://%s/" % domain),
("1.2.3.4", "https://%s" % sub_domain), ("1.2.3.4", "https://%s/" % sub_domain),
], ],
) )
...@@ -783,8 +783,8 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -783,8 +783,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://%s" % sub_domain), ("1.2.3.4", "http://%s/" % sub_domain),
("1.2.3.4", "https://%s" % sub_domain), ("1.2.3.4", "https://%s/" % sub_domain),
], ],
) )
...@@ -883,8 +883,8 @@ class SurykatkaBotTestCase(unittest.TestCase): ...@@ -883,8 +883,8 @@ class SurykatkaBotTestCase(unittest.TestCase):
checkHttpCodeChange( checkHttpCodeChange(
bot, bot,
[ [
("1.2.3.4", "http://%s" % domain), ("1.2.3.4", "http://%s/" % domain),
("1.2.3.4", "https://%s" % domain), ("1.2.3.4", "https://%s/" % domain),
("1.2.3.4", "https://example.org/foo"), ("1.2.3.4", "https://example.org/foo"),
], ],
) )
......
...@@ -52,7 +52,7 @@ class SurykatkaHttpTestCase(unittest.TestCase): ...@@ -52,7 +52,7 @@ class SurykatkaHttpTestCase(unittest.TestCase):
################################################ ################################################
def test_getRootUrl(self): def test_getRootUrl(self):
result = getRootUrl("https://example.org/foo?bar=1") result = getRootUrl("https://example.org/foo?bar=1")
assert result == "https://example.org" assert result == "https://example.org/"
################################################ ################################################
# getUserAgent # 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