summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py52
1 files changed, 25 insertions, 27 deletions
diff --git a/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py b/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
index 1ece5d1e..7d70931b 100644
--- a/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
+++ b/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
@@ -124,6 +124,9 @@ def test_get_definitions_all():
for instruction in fe_instructions:
print(instruction['help'])
assert("help" in instruction)
+ assert(len(defs['feInstructionParameters']) > 0)
+ assert(len(defs['feParameters']) > 0)
+ assert(len(defs['feTemplates']) > 0)
def test_get_definitions_ether():
res = get_definitions(["Ether"])
@@ -291,41 +294,36 @@ def test_generate_vm_instructions():
assert(ttl_instruction['max_value'] == 64)
-def test_get_templates():
- tt = get_templates()
- assert(tt[0]['id'])
- assert(tt[7]["meta"]['name'])
- try:
- assert(tt[9]['id'])
- except:
- pass
+def test_list_templates_hierarchy():
+ ids = []
+ for template_info in get_templates():
+ assert(template_info["meta"]["name"])
+ assert("description" in template_info["meta"])
+ ids.append(template_info['id'])
+ assert('IPv4/TCP' in ids)
+ assert('IPv4/UDP' in ids)
+ assert('TCP-SYN' in ids)
+ assert('ICMP echo request' in ids)
+def test_get_template_root():
+ obj = json.loads(get_template_by_id('TCP-SYN'))
+ assert(obj['packet'][0]['id'] == 'Ether')
+ assert(obj['packet'][1]['id'] == 'IP')
+ assert(obj['packet'][2]['id'] == 'TCP')
-def test_get_template():
- tt = get_templates()
- t = tt[0]
- res = get_template(t)
- res2 = base64.b64decode(res)
- obj = json.loads(res2)
+def test_get_template_IP_ICMP():
+ obj = json.loads(get_template_by_id('IPv4/ICMP'))
assert(obj['packet'][0]['id'] == 'Ether')
assert(obj['packet'][1]['id'] == 'IP')
assert(obj['packet'][2]['id'] == 'ICMP')
-
-def test_get_template2():
- tt = get_templates()
- t = tt[7]
- res = get_template(t)
- res2 = base64.b64decode(res)
- obj = json.loads(res2)
+def test_get_template_IPv6_UDP():
+ obj = json.loads(get_template_by_id('IPv6/UDP'))
assert(obj['packet'][0]['id'] == 'Ether')
assert(obj['packet'][1]['id'] == 'IPv6')
assert(obj['packet'][2]['id'] == 'UDP')
+def test_templates_no_relative_path():
+ res = get_template_by_id("../templates/IPv6/UDP")
+ assert(res == "")
-def test_get_template3():
- tt = get_templates()
- t = tt[7]
- t["id"] = "../../" + t["id"]
- res = get_template(t)
- assert(res == '')