summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
diff options
context:
space:
mode:
authorichebyki <igrche@gmail.com>2016-12-20 12:57:59 +0700
committerYaroslav Brustinov <ybrustin@cisco.com>2017-01-05 16:36:29 +0200
commit10a1d2e33a110a091f539bdf3de5e5c69e5887f8 (patch)
tree1e80e38d349aa82a897509708a524f5a0ec5af0d /scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
parent3484a1699e36953d8c8dc95743b468eb026a09e1 (diff)
Add support for predefined packet templates.
Change-Id: Ib2bdcbe6ea18933394527f06be001607344c75e4 Signed-off-by: Igor Chebykin <igrche@gmail.com>
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.py40
1 files changed, 40 insertions, 0 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 e1094a79..1ece5d1e 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
@@ -289,3 +289,43 @@ def test_generate_vm_instructions():
ttl_instruction = res['field_engine']['instructions']['instructions'][2]
assert(ttl_instruction['min_value'] == 32)
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_get_template():
+ tt = get_templates()
+ t = tt[0]
+ res = get_template(t)
+ res2 = base64.b64decode(res)
+ obj = json.loads(res2)
+ 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)
+ assert(obj['packet'][0]['id'] == 'Ether')
+ assert(obj['packet'][1]['id'] == 'IPv6')
+ assert(obj['packet'][2]['id'] == 'UDP')
+
+
+def test_get_template3():
+ tt = get_templates()
+ t = tt[7]
+ t["id"] = "../../" + t["id"]
+ res = get_template(t)
+ assert(res == '')