diff --git a/test_orc/modules/dns/conf/module_config.json b/test_orc/modules/dns/conf/module_config.json index b8ff36c97..177537b69 100644 --- a/test_orc/modules/dns/conf/module_config.json +++ b/test_orc/modules/dns/conf/module_config.json @@ -21,6 +21,10 @@ "name": "dns.network.from_dhcp", "description": "Verify the device allows for a DNS server to be entered automatically", "expected_behavior": "The device sends DNS requests to the DNS server provided by the DHCP server" + }, + { + "name": "dns.mdns", + "description": "If the device has MDNS (or any kind of IP multicast), can it be disabled" } ] } diff --git a/test_orc/modules/dns/python/src/dns_module.py b/test_orc/modules/dns/python/src/dns_module.py index cd7261da0..8d32d4dfb 100644 --- a/test_orc/modules/dns/python/src/dns_module.py +++ b/test_orc/modules/dns/python/src/dns_module.py @@ -17,7 +17,9 @@ from test_module import TestModule LOG_NAME = 'test_dns' -CAPTURE_FILE = '/runtime/network/dns.pcap' +DNS_SERVER_CAPTURE_FILE = '/runtime/network/dns.pcap' +STARTUP_CAPTURE_FILE = '/runtime/device/startup.pcap' +MONITOR_CAPTURE_FILE = '/runtime/device/monitor.pcap' LOGGER = None @@ -31,14 +33,24 @@ def __init__(self, module): LOGGER = self._get_logger() def _check_dns_traffic(self, tcpdump_filter): - to_dns = self._exec_tcpdump(tcpdump_filter) - num_query_dns = len(to_dns) + dns_server_queries = self._exec_tcpdump(tcpdump_filter,DNS_SERVER_CAPTURE_FILE) + LOGGER.info('DNS Server queries found: ' + str(len(dns_server_queries))) + + dns_startup_queries = self._exec_tcpdump(tcpdump_filter,STARTUP_CAPTURE_FILE) + LOGGER.info('Startup DNS queries found: ' + str(len(dns_startup_queries))) + + dns_monitor_queries = self._exec_tcpdump(tcpdump_filter,MONITOR_CAPTURE_FILE) + LOGGER.info('Monitor DNS queries found: ' + str(len(dns_monitor_queries))) + + num_query_dns = len(dns_server_queries) + len(dns_startup_queries) + len(dns_monitor_queries) + LOGGER.info('DNS queries found: ' + str(num_query_dns)) - dns_traffic_detected = len(to_dns) > 0 + dns_traffic_detected = num_query_dns > 0 LOGGER.info('DNS traffic detected: ' + str(dns_traffic_detected)) return dns_traffic_detected def _dns_network_from_dhcp(self): + LOGGER.info("Running dns.network.from_dhcp") LOGGER.info('Checking DNS traffic for configured DHCP DNS server: ' + self._dns_server) @@ -53,6 +65,7 @@ def _dns_network_from_dhcp(self): return result def _dns_network_from_device(self): + LOGGER.info("Running dns.network.from_device") LOGGER.info('Checking DNS traffic from device: ' + self._device_mac) # Check if the device DNS traffic is to appropriate server @@ -63,7 +76,19 @@ def _dns_network_from_device(self): LOGGER.info('DNS traffic detected from device: ' + str(result)) return result - def _exec_tcpdump(self, tcpdump_filter): + def _dns_mdns(self): + LOGGER.info("Running dns.mdns") + + # Check if the device sends any MDNS traffic + tcpdump_filter = f'udp port 5353 and ether src {self._device_mac}' + + result = self._check_dns_traffic(tcpdump_filter=tcpdump_filter) + + LOGGER.info('MDNS traffic detected from device: ' + str(result)) + return not result + + + def _exec_tcpdump(self, tcpdump_filter, capture_file): """ Args tcpdump_filter: Filter to pass onto tcpdump file @@ -71,7 +96,7 @@ def _exec_tcpdump(self, tcpdump_filter): Returns List of packets matching the filter """ - command = f'tcpdump -tttt -n -r {CAPTURE_FILE} {tcpdump_filter}' + command = f'tcpdump -tttt -n -r {capture_file} {tcpdump_filter}' LOGGER.debug('tcpdump command: ' + command) diff --git a/test_orc/python/src/test_orchestrator.py b/test_orc/python/src/test_orchestrator.py index e122221f5..b8b7a3af2 100644 --- a/test_orc/python/src/test_orchestrator.py +++ b/test_orc/python/src/test_orchestrator.py @@ -133,6 +133,15 @@ def _run_test_module(self, module, device): network_runtime_dir = os.path.join(self._root_path, "runtime/network") os.makedirs(container_runtime_dir) + device_startup_capture = os.path.join( + self._root_path, "runtime/test/" + device.mac_addr.replace(":", "") + + "/startup.pcap") + + device_monitor_capture = os.path.join( + self._root_path, "runtime/test/" + device.mac_addr.replace(":", "") + + "/monitor.pcap") + + client = docker.from_env() module.container = client.containers.run( @@ -151,6 +160,14 @@ def _run_test_module(self, module, device): source=network_runtime_dir, type="bind", read_only=True), + Mount(target="/runtime/device/startup.pcap", + source=device_startup_capture, + type="bind", + read_only=True), + Mount(target="/runtime/device/monitor.pcap", + source=device_monitor_capture, + type="bind", + read_only=True), ], environment={ "HOST_USER": self._get_host_user(),