diff --git a/modules/test/tls/python/src/tls_module.py b/modules/test/tls/python/src/tls_module.py index 6831ad00c..42245dfb9 100644 --- a/modules/test/tls/python/src/tls_module.py +++ b/modules/test/tls/python/src/tls_module.py @@ -36,6 +36,7 @@ GATEWAY_CAPTURE_FILE = '/runtime/network/gateway.pcap' LOGGER = None REPORT_TEMPLATE_FILE = 'report_template.jinja2' +OUTBOUND_CONNS_PER_PAGE = 18 class TLSModule(TestModule): @@ -193,12 +194,21 @@ def generate_module_report(self): device_mac=self._device_mac, capture_files=pcap_files) if outbound_conns: - out_page = template.render( - base_template=self._base_template_file, - ountbound_headers=outbound_headers, - outbound_conns=outbound_conns - ) - report_jinja += out_page + # Splitting Outbound Coonestions table to pages + pages = len(outbound_conns) // OUTBOUND_CONNS_PER_PAGE + if pages * OUTBOUND_CONNS_PER_PAGE < len(outbound_conns): + pages += 1 + for page in range(pages): + start = page * OUTBOUND_CONNS_PER_PAGE + end = min(page * OUTBOUND_CONNS_PER_PAGE + OUTBOUND_CONNS_PER_PAGE, + len(outbound_conns)) + outbound_conns_chunk = outbound_conns[start:end] + out_page = template.render( + base_template=self._base_template_file, + ountbound_headers=outbound_headers, + outbound_conns=outbound_conns_chunk + ) + report_jinja += out_page LOGGER.debug('Module report:\n' + report_jinja) diff --git a/testing/unit/tls/reports/tls_report_local.html b/testing/unit/tls/reports/tls_report_local.html index 3100aaf69..a1cc9f2d5 100644 --- a/testing/unit/tls/reports/tls_report_local.html +++ b/testing/unit/tls/reports/tls_report_local.html @@ -465,6 +465,155 @@

Outbound Connections

52.94.225.110 443 + + 224.0.0.251 + 5353 + + + 209.244.0.3 + Unknown + + + 3.227.250.136 + 443 + + + 3.227.203.88 + 443 + + + 34.226.101.252 + 8883 + + + 3.227.250.208 + 443 + + + 52.94.225.110 + 443 + + + 224.0.0.251 + 5353 + + + 209.244.0.3 + Unknown + + + 3.227.250.136 + 443 + + + 3.227.203.88 + 443 + + + + + + + +
+ +
+
+
+ {# Badge #} +

+ + {{ name }} +

+ {{ title }} +
+ + {{ device['manufacturer'] }} + {{ device['model']}} + + Testrun +
+
+

Outbound Connections

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Destination IPPort
34.226.101.2528883
3.227.250.208443
52.94.225.110443
224.0.0.2515353
209.244.0.3Unknown
3.227.250.136443
3.227.203.88443
34.226.101.2528883
3.227.250.208443
52.94.225.110443
224.0.0.2515353
209.244.0.3Unknown
3.227.250.136443
3.227.203.88443
34.226.101.2528883
3.227.250.208443
52.94.225.110443
diff --git a/testing/unit/tls/tls_module_test.py b/testing/unit/tls/tls_module_test.py index d0271a404..cd849a773 100644 --- a/testing/unit/tls/tls_module_test.py +++ b/testing/unit/tls/tls_module_test.py @@ -17,6 +17,7 @@ from common import logger import os import unittest +import unittest.mock from scapy.all import sniff, wrpcap import threading import time @@ -635,10 +636,14 @@ def tls_module_report_multi_page_test(self): startup_capture_file=startup_pcap_file, monitor_capture_file=monitor_pcap_file, tls_capture_file=tls_pcap_file) + conns_orig = TLS_UTIL.get_all_outbound_connections( + device_mac='68:5e:1c:cb:6e:cb', capture_files=[monitor_pcap_file]) * 5 + conns_mock = unittest.mock.MagicMock() + conns_mock.get_all_outbound_connections.return_value = conns_orig + tls._tls_util = conns_mock # pylint: disable=W0212 report_out_path = tls.generate_module_report() with open(report_out_path, 'r', encoding='utf-8') as file: report_out = file.read() - # Read the local good report with open(LOCAL_REPORT, 'r', encoding='utf-8') as file: report_local = file.read()