diff --git a/modules/test/ntp/conf/module_config.json b/modules/test/ntp/conf/module_config.json index ca69898d1..81b7bd8a1 100644 --- a/modules/test/ntp/conf/module_config.json +++ b/modules/test/ntp/conf/module_config.json @@ -23,8 +23,8 @@ }, { "name": "ntp.network.ntp_dhcp", - "test_description": "Accept NTP address over DHCP", - "expected_behavior": "Device can accept NTP server address, provided by the DHCP server (DHCP OFFER PACKET)", + "test_description": "Accept NTP address over DHCP or from public trusted sources", + "expected_behavior": "Device can accept NTP server address, provided by the DHCP server (DHCP OFFER PACKET) or from public trusted sources.", "config": { "pools_with_subdomains": [ "pool.ntp.org", @@ -101,7 +101,11 @@ ] }, "recommendations": [ - "Install an NTP client that supports fetching the NTP servers from DHCP options" + "Install an NTP client that supports fetching the NTP servers from DHCP options", + "Verify that the device is configured to accept DHCP Option 42", + "Delete any hardcoded public IPs", + "Change the NTP setting from 'Static/Manual' to 'Authomatic/DCHP'", + "Restart the NTP daemon" ] } ] diff --git a/modules/test/ntp/python/src/ntp_module.py b/modules/test/ntp/python/src/ntp_module.py index 91a5f9376..f003f7b1d 100644 --- a/modules/test/ntp/python/src/ntp_module.py +++ b/modules/test/ntp/python/src/ntp_module.py @@ -365,31 +365,44 @@ def _ntp_network_ntp_dhcp(self, config): ntp_whitelist_resolver.is_ip_whitelisted(ip) for ip in ntp_to_remote_ips ) + result_details = [f'NTP request to {self._ntp_server}'] + for ip in ntp_to_remote_ips: if ntp_whitelist_resolver.is_ip_whitelisted(ip): LOGGER.info(f'NTP server {ip} is in the trusted whitelist') else: LOGGER.info(f'NTP server {ip} is NOT in the trusted whitelist') + result_details.append(f'NTP request to {ip}') + + result_state = 'Feature Not Detected' + result_message = 'Device has not sent any NTP requests' - result = 'Feature Not Detected', 'Device has not sent any NTP requests' if device_sends_ntp: if ntp_to_local and ntp_to_remote: if ntp_to_remote_trusted: - result = True, ('Device sent NTP request to DHCP provided ' + + result_state = True + result_message = ('Device sent NTP request to DHCP provided ' + 'server and trusted non-DHCP provided servers') else: - result = False, ('Device sent NTP request to DHCP provided ' + + result_state = False + result_message = ('Device sent NTP request to DHCP provided ' + 'server and to untrusted non-DHCP provided server') elif ntp_to_remote: if ntp_to_remote_trusted: - result = False, ('Device sent NTP request to trusted ' + + result_state = False + result_message = ('Device sent NTP request to trusted ' + 'non-DHCP provided server') else: - result = False, ('Device sent NTP request to untrusted ' + + result_state = False + result_message = ('Device sent NTP request to untrusted ' + 'non-DHCP provided server') elif ntp_to_local: - result = True, 'Device sent NTP request to DHCP provided server' + result_state = True + result_message ='Device sent NTP request to DHCP provided server' - LOGGER.info(result[1]) - return result + if not ntp_to_local: + result_details.pop(0) + + LOGGER.info(result_state) + return result_state, result_message, result_details