Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion modules/test/base/python/src/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Base class for all core test module functions"""
import json
import logger
Expand Down Expand Up @@ -102,11 +101,26 @@ def run_tests(self):
else:
if result[0] is None:
test['result'] = 'skipped'
if len(result)>1:
test['result_details'] = result[1]
else:
test['result'] = 'compliant' if result[0] else 'non-compliant'
test['result_details'] = result[1]
else:
test['result'] = 'skipped'

# Generate the short result description based on result value
if test['result'] == 'compliant':
test['result_description'] = test[
'short_description'] if 'short_description' in test else test[
'name'] + ' passed - see result details for more info'
elif test['result'] == 'non-compliant':
test['result_description'] = test[
'name'] + ' failed - see result details for more info'
else:
test['result_description'] = test[
'name'] + ' skipped - see result details for more info'

test['end'] = datetime.now().isoformat()
duration = datetime.fromisoformat(test['end']) - datetime.fromisoformat(
test['start'])
Expand Down
9 changes: 6 additions & 3 deletions modules/test/baseline/conf/module_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
{
"name": "baseline.pass",
"description": "Simulate a compliant test",
"expected_behavior": "A compliant test result is generated"
"expected_behavior": "A compliant test result is generated",
"short_description": "A compliant test result is generated"
},
{
"name": "baseline.fail",
"description": "Simulate a non-compliant test",
"expected_behavior": "A non-compliant test result is generated"
"expected_behavior": "A non-compliant test result is generated",
"short_description": "A non-compliant test result is generated"
},
{
"name": "baseline.skip",
"description": "Simulate a skipped test",
"expected_behavior": "A skipped test result is generated"
"expected_behavior": "A skipped test result is generated",
"short_description": "A skipped test result is generated"
}
]
}
Expand Down
19 changes: 10 additions & 9 deletions modules/test/baseline/python/src/baseline_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Baseline test module"""
from test_module import TestModule

LOG_NAME = "test_baseline"
LOG_NAME = 'test_baseline'
LOGGER = None


Expand All @@ -28,15 +28,16 @@ def __init__(self, module):
LOGGER = self._get_logger()

def _baseline_pass(self):
LOGGER.info("Running baseline pass test")
LOGGER.info("Baseline pass test finished")
return True
LOGGER.info('Running baseline pass test')
LOGGER.info('Baseline pass test finished')
return True, 'Baseline pass test ran successfully'

def _baseline_fail(self):
LOGGER.info("Running baseline pass test")
LOGGER.info("Baseline pass test finished")
return False
LOGGER.info('Running baseline fail test')
LOGGER.info('Baseline fail test finished')
return False, 'Baseline fail test ran successfully'

def _baseline_skip(self):
LOGGER.info("Running baseline pass test")
LOGGER.info("Baseline pass test finished")
LOGGER.info('Running baseline skip test')
LOGGER.info('Baseline skip test finished')
return None, 'Baseline skip test ran successfully'
44 changes: 34 additions & 10 deletions modules/test/conn/conf/module_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,48 @@
"description": "Connection tests"
},
"network": true,
"interface_control": true,
"docker": {
"depends_on": "base",
"enable_container": true,
"timeout": 600
},
"tests": [
{
"name": "connection.dhcp.disconnect",
"description": "The device under test has received an IP address from the DHCP server and responds to an ICMP echo (ping) request",
"expected_behavior": "The device is not setup with a static IP address. The device accepts an IP address from a DHCP server (RFC 2131) and responds succesfully to an ICMP echo (ping) request.",
"short_description": "Device has received an IP address after port disconnect"
},
{
"name": "connection.dhcp.disconnect_ip_change",
"description": "Update device IP on the DHCP server and reconnect the device. Does the device receive the new IP address?",
"expected_behavior": "Device recieves a new IP address within the range that is specified on the DHCP server. Device should respond to aping on this new address.",
"short_description": "Device has received new IP address after port disconnect"
},
{
"name": "connection.dhcp_address",
"description": "The device under test has received an IP address from the DHCP server and responds to an ICMP echo (ping) request",
"expected_behavior": "The device is not setup with a static IP address. The device accepts an IP address from a DHCP server (RFC 2131) and responds succesfully to an ICMP echo (ping) request."
"expected_behavior": "The device is not setup with a static IP address. The device accepts an IP address from a DHCP server (RFC 2131) and responds succesfully to an ICMP echo (ping) request.",
"short_description": "Device has received a DHCP provided IP address"
},
{
"name": "connection.mac_address",
"description": "Check and note device physical address.",
"expected_behavior": "N/A"
"expected_behavior": "N/A",
"short_description": "Device MAC address resolved"
},
{
"name": "connection.mac_oui",
"description": "The device under test hs a MAC address prefix that is registered against a known manufacturer.",
"expected_behavior": "The MAC address prefix is registered in the IEEE Organizationally Unique Identifier database."
"expected_behavior": "The MAC address prefix is registered in the IEEE Organizationally Unique Identifier database.",
"short_description": "OUI for MAC address resolved"
},
{
"name": "connection.private_address",
"description": "The device under test accepts an IP address that is compliant with RFC 1918 Address Allocation for Private Internets.",
"expected_behavior": "The device under test accepts IP addresses within all ranges specified in RFC 1918 and communicates using these addresses. The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets. 10.0.0.0 - 10.255.255.255.255 (10/8 prefix). 172.16.0.0 - 172.31.255.255 (172.16/12 prefix). 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)",
"short_description": "Device supports private addresses",
"config": {
"ranges": [
{
Expand All @@ -52,6 +69,7 @@
"name": "connection.shared_address",
"description": "Ensure the device supports RFC 6598 IANA-Reserved IPv4 Prefix for Shared Address Space",
"expected_behavior": "The device under test accepts IP addresses within the ranges specified in RFC 6598 and communicates using these addresses",
"short_description": "Device supports shared address space",
"config": {
"ranges": [
{
Expand All @@ -64,32 +82,38 @@
{
"name": "connection.single_ip",
"description": "The network switch port connected to the device reports only one IP address for the device under test.",
"expected_behavior": "The device under test does not behave as a network switch and only requets one IP address. This test is to avoid that devices implement network switches that allow connecting strings of daisy chained devices to one single network port, as this would not make 802.1x port based authentication possible."
"expected_behavior": "The device under test does not behave as a network switch and only requets one IP address. This test is to avoid that devices implement network switches that allow connecting strings of daisy chained devices to one single network port, as this would not make 802.1x port based authentication possible.",
"short_description": "Device only reports one IP address"
},
{
"name": "connection.target_ping",
"description": "The device under test responds to an ICMP echo (ping) request.",
"expected_behavior": "The device under test responds to an ICMP echo (ping) request."
"expected_behavior": "The device under test responds to an ICMP echo (ping) request.",
"short_description": "Device responds to a ping request"
},
{
"name": "connection.ipaddr.ip_change",
"description": "The device responds to a ping (ICMP echo request) to the new IP address it has received after the initial dHCP lease has expired.",
"expected_behavior": "If the lease expires before the client receiveds a DHCPACK, the client moves to INIT state, MUST immediately stop any other network processing and requires network initialization parameters as if the client were uninitialized. If the client then receives a DHCPACK allocating the client its previous network addres, the client SHOULD continue network processing. If the client is given a new network address, it MUST NOT continue using the previous network address and SHOULD notify the local users of the problem."
"description": "The device responds to a ping (ICMP echo request) to the new IP address it has received after the initial DHCP lease has expired.",
"expected_behavior": "If the lease expires before the client receiveds a DHCPACK, the client moves to INIT state, MUST immediately stop any other network processing and requires network initialization parameters as if the client were uninitialized. If the client then receives a DHCPACK allocating the client its previous network addres, the client SHOULD continue network processing. If the client is given a new network address, it MUST NOT continue using the previous network address and SHOULD notify the local users of the problem.",
"short_description": "Device receives an IP change from the DHCP server"
},
{
"name": "connection.ipaddr.dhcp_failover",
"description": "The device has requested a DHCPREQUEST/REBIND to the DHCP failover server after the primary DHCP server has been brought down.",
"expected_behavior": ""
"expected_behavior": "",
"short_description": "Device receives IP address from primary and failover DHCP servers"
},
{
"name": "connection.ipv6_slaac",
"description": "The device forms a valid IPv6 address as a combination of the IPv6 router prefix and the device interface identifier",
"expected_behavior": "The device under test complies with RFC4862 and forms a valid IPv6 SLAAC address"
"expected_behavior": "The device under test complies with RFC4862 and forms a valid IPv6 SLAAC address",
"short_description": "Device uses an IPv6 address using SLAAC"
},
{
"name": "connection.ipv6_ping",
"description": "The device responds to an IPv6 ping (ICMPv6 Echo) request to the SLAAC address",
"expected_behavior": "The device responds to the ping as per RFC4443"
"expected_behavior": "The device responds to the ping as per RFC4443",
"short_description": "Device responds to an IPv6 SLAAC address ping request"
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion modules/test/conn/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyOpenSSL
pyOpenSSL
scapy
35 changes: 20 additions & 15 deletions modules/test/conn/python/src/connection_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _get_oui_manufacturer(self, mac_address):

def _connection_ipv6_slaac(self):
LOGGER.info('Running connection.ipv6_slaac')
result = None
packet_capture = rdpcap(MONITOR_CAPTURE_FILE)

sends_ipv6 = False
Expand All @@ -265,27 +266,31 @@ def _connection_ipv6_slaac(self):
if ipv6_addr.startswith(SLAAC_PREFIX):
self._device_ipv6_addr = ipv6_addr
LOGGER.info(f'Device has formed SLAAC address {ipv6_addr}')
return True

if sends_ipv6:
LOGGER.info('Device does not support IPv6 SLAAC')
else:
LOGGER.info('Device does not support IPv6')
return False
result = True, f'Device has formed SLAAC address {ipv6_addr}'
if result is None:
if sends_ipv6:
LOGGER.info('Device does not support IPv6 SLAAC')
result = False, 'Device does not support IPv6 SLAAC'
else:
LOGGER.info('Device does not support IPv6')
result = False, 'Device does not support IPv6'
return result

def _connection_ipv6_ping(self):
LOGGER.info('Running connection.ipv6_ping')

result = None

if self._device_ipv6_addr is None:
LOGGER.info('No IPv6 SLAAC address found. Cannot ping')
return

if self._ping(self._device_ipv6_addr):
LOGGER.info(f'Device responds to IPv6 ping on {self._device_ipv6_addr}')
return True
result = None, 'No IPv6 SLAAc address found. Cannot ping'
else:
LOGGER.info('Device does not respond to IPv6 ping')
return False
if self._ping(self._device_ipv6_addr):
LOGGER.info(f'Device responds to IPv6 ping on {self._device_ipv6_addr}')
result = True, f'Device responds to IPv6 ping on {self._device_ipv6_addr}'
else:
LOGGER.info('Device does not respond to IPv6 ping')
result = False, 'Device does not respond to IPv6 ping'
return result

def _ping(self, host):
cmd = 'ping -c 1 ' + str(host)
Expand Down
9 changes: 6 additions & 3 deletions modules/test/dns/conf/module_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
{
"name": "dns.network.from_device",
"description": "Verify the device sends DNS requests",
"expected_behavior": "The device sends DNS requests."
"expected_behavior": "The device sends DNS requests.",
"short_description": "The device sends DNS requests."
},
{
"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"
"expected_behavior": "The device sends DNS requests to the DNS server provided by the DHCP server",
"short_description": "The device sends DNS requests to local DNS server."
},
{
"name": "dns.mdns",
"description": "If the device has MDNS (or any kind of IP multicast), can it be disabled"
"description": "If the device has MDNS (or any kind of IP multicast), can it be disabled",
"short_description": "MDNS traffic detected from device"
}
]
}
Expand Down
Loading