Commit 22729e9e authored by Federico Sismondi's avatar Federico Sismondi

added message for sending to UI a file to download, updated CLI with more...

added message for sending to UI a file to download, updated CLI with more testing methods, updated version
parent 89f3edc9
Pipeline #2640 passed with stage
in 0 seconds
......@@ -30,7 +30,7 @@ Essentially it allows you to:
>>> from messages import *
>>> m = MsgTestCaseSkip(testcase_id = 'some_testcase_id')
>>> m
MsgTestCaseSkip(_api_version = 1.1.0, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
MsgTestCaseSkip(_api_version = 1.1.3, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
>>> m.routing_key
'testsuite.testcase.skip'
>>> m.message_id # doctest: +SKIP
......@@ -41,24 +41,24 @@ MsgTestCaseSkip(_api_version = 1.1.0, description = Skip testcase, node = someNo
# also we can modify some of the fields (rewrite the default ones)
>>> m = MsgTestCaseSkip(testcase_id = 'TD_COAP_CORE_03')
>>> m
MsgTestCaseSkip(_api_version = 1.1.0, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
MsgTestCaseSkip(_api_version = 1.1.3, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
>>> m.testcase_id
'TD_COAP_CORE_03'
# and even export the message in json format (for example for sending the message though the amqp event bus)
>>> m.to_json()
'{"_api_version": "1.1.0", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
'{"_api_version": "1.1.3", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
# We can use the Message class to import json into Message objects:
>>> m=MsgTestSuiteStart()
>>> m.routing_key
'testsuite.start'
>>> m.to_json()
'{"_api_version": "1.1.0", "description": "Test suite START command"}'
'{"_api_version": "1.1.3", "description": "Test suite START command"}'
>>> json_message = m.to_json()
>>> obj=Message.load(json_message,'testsuite.start', None )
>>> obj
MsgTestSuiteStart(_api_version = 1.1.0, description = Test suite START command, )
MsgTestSuiteStart(_api_version = 1.1.3, description = Test suite START command, )
>>> type(obj) # doctest: +SKIP
<class 'messages.MsgTestSuiteStart'>
......@@ -70,7 +70,7 @@ MsgTestSuiteStart(_api_version = 1.1.0, description = Test suite START command,
# the error reply (note that we pass the message of the request to build the reply):
>>> err = MsgErrorReply(m)
>>> err
MsgErrorReply(_api_version = 1.1.0, error_code = None, error_message = None, ok = False, )
MsgErrorReply(_api_version = 1.1.3, error_code = None, error_message = None, ok = False, )
# properties of the message are auto-generated:
>>> m.reply_to
......@@ -96,10 +96,10 @@ MsgErrorReply(_api_version = 1.1.0, error_code = None, error_message = None, ok
>>> m.routing_key
'sniffing.getcapture.request'
>>> m.to_json()
'{"_api_version": "1.1.0", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.1.3", "capture_id": "TD_COAP_CORE_01"}'
>>> json_message = m.to_json()
>>> json_message
'{"_api_version": "1.1.0", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.1.3", "capture_id": "TD_COAP_CORE_01"}'
>>> obj=Message.load(json_message,'testsuite.start', None )
>>> type(obj) # doctest
<class 'messages.MsgTestSuiteStart'>
......@@ -116,7 +116,7 @@ Build a message from a pika's returned values on consume:
>>> m.routing_key
'sniffing.getcapture.request'
>>> m.to_json()
'{"_api_version": "1.1.0", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.1.3", "capture_id": "TD_COAP_CORE_01"}'
```
......@@ -161,7 +161,7 @@ Sending message..
[Event bus message] [<class 'messages.messages.MsgTestSuiteStart'>]
------------ ------------------------
_api_version 1.1.0
_api_version 1.1.3
description Test suite START command
------------ ------------------------
......@@ -172,22 +172,22 @@ but also for testing internal services provided by the tools
```
> _send_MsgTestSuiteGetTestCases
[User input] trying to send message: MsgTestSuiteGetTestCases(_api_version = 1.1.0, )
[User input] trying to send message: MsgTestSuiteGetTestCases(_api_version = 1.1.3, )
Sending message..
[Event bus message] [<class 'messages.messages.MsgTestSuiteGetTestCases'>]
------------ -----
_api_version 1.1.0
_api_version 1.1.3
------------ -----
[log][test_coordinator|amqp_connector] RECEIVED request: <class 'ioppytest.utils.messages.messages.MsgTestSuiteGetTestCases'>
[log][test_coordinator|amqp_connector] HANDLING request: <class 'ioppytest.utils.messages.messages.MsgTestSuiteGetTestCases'>
[log][test_coordinator|amqp_connector] PUBLISHING to routing_key: testsuite.testcases.list.reply, msg: MsgReply(_api_version = 1.1.0, ok = True, tc_list = [OrderedDict([('te
[log][test_coordinator|amqp_connector] PUBLISHING to routing_key: testsuite.testcases.list.reply, msg: MsgReply(_api_version = 1.1.3, ok = True, tc_list = [OrderedDict([('te
[Event bus message] [<class 'messages.messages.MsgTestSuiteGetTestCasesReply'>]
------------ --------------------------------------------------------------------------------------------------------------------
_api_version 1.1.0
_api_version 1.1.3
ok True
tc_list {'testcase_id': 'TD_COAP_CORE_01', 'testcase_ref': 'http://doc.f-interop.eu/tests/TD_COAP_CORE_01', 'state': None}
{'testcase_id': 'TD_COAP_CORE_02', 'testcase_ref': 'http://doc.f-interop.eu/tests/TD_COAP_CORE_02', 'state': None}
......@@ -221,13 +221,13 @@ other example:
```
> _send_MsgAgentTunStart
[User input] trying to send message: MsgAgentTunStart(_api_version = 1.1.0, ipv4_host = None, ipv4_netmask = None, ipv4_network = None, ipv6_host = :3, ipv6_no_forwarding = False, ipv6_prefix = bbbb, name = agent_TT, re_route_packets_host = None, re_route_packets_if = None, re_route_packets_prefix = None, )
[User input] trying to send message: MsgAgentTunStart(_api_version = 1.1.3, ipv4_host = None, ipv4_netmask = None, ipv4_network = None, ipv6_host = :3, ipv6_no_forwarding = False, ipv6_prefix = bbbb, name = agent_TT, re_route_packets_host = None, re_route_packets_if = None, re_route_packets_prefix = None, )
Sending message..
[Event bus message] [<class 'messages.messages.MsgAgentTunStart'>]
----------------------- --------
_api_version 1.1.0
_api_version 1.1.3
ipv4_host
ipv4_netmask
ipv4_network
......@@ -276,12 +276,12 @@ and the message properties into Message python objects
```
(my_venv) ➜ ioppytest-cli connect
[Test Assistant] Connecting to amqp://paul:iamthewalrus@f-interop.rennes.inria.fr/session05?heartbeat_interval=600&blocked_connection_timeout=300&retry_delay=1&socket_timeout=1&connection_attempts=3
[Test Assistant] Connecting to amqp://paul:iamthewalrus@f-interop.rennes.inria.fr/session05?heartbeat=600&blocked_connection_timeout=300&retry_delay=1&socket_timeout=1&connection_attempts=3
[Event bus message] [<class 'messages.messages.MsgTestingToolComponentReady'>]
------------ -------------------------------
_api_version 1.1.0
_api_version 1.1.3
component amqp_listener_b49d7db4
description amqp_listener_b49d7db4 is READY
------------ -------------------------------
......@@ -298,13 +298,13 @@ No conversion from json to python objects, no data validation
```(my_venv) ➜ ioppytest_cli connect -ll
[Test Assistant] Connecting to amqp://paul:iamthewalrus@f-interop.rennes.inria.fr/session05?heartbeat_interval=600&blocked_connection_timeout=300&retry_delay=1&socket_timeout=1&connection_attempts=3
[Test Assistant] Connecting to amqp://paul:iamthewalrus@f-interop.rennes.inria.fr/session05?heartbeat=600&blocked_connection_timeout=300&retry_delay=1&socket_timeout=1&connection_attempts=3
------------------------------------------------------------------------------------------------------------------------
routing_key : testsuite.testcases.list.request
------------------------------------------------------------------------------------------------------------------------
{
"_api_version": "1.1.0",
"_api_version": "1.1.3",
"content_type": "application/json",
"correlation_id": "00393e9e-d255-4309-8a9b-18ec608602f3",
"message_id": "00393e9e-d255-4309-8a9b-18ec608602f3",
......@@ -336,13 +336,13 @@ routing_key : log.info.test_coordinator|amqp_connector
"_api_version": "1.0.8",
"component": "test_coordinator|amqp_connector",
"content_type": "application/json",
"message": "PUBLISHING to routing_key: testsuite.testcases.list.reply, msg: MsgReply(_api_version = 1.1.0, ok = True, tc_list = [OrderedDict([('te"
"message": "PUBLISHING to routing_key: testsuite.testcases.list.reply, msg: MsgReply(_api_version = 1.1.3, ok = True, tc_list = [OrderedDict([('te"
}
------------------------------------------------------------------------------------------------------------------------
routing_key : testsuite.testcases.list.reply
------------------------------------------------------------------------------------------------------------------------
{
"_api_version": "1.1.0",
"_api_version": "1.1.3",
"content_type": "application/json",
"correlation_id": "00393e9e-d255-4309-8a9b-18ec608602f3",
"message_id": "619283ab-c6a1-4b91-8a65-8697b665e3a1",
......
......@@ -212,6 +212,36 @@ def gui_request_file_upload(path_to_file, text_message, user_id):
_echo_input("saved file {} in path {}".format(filename, path_to_file))
@cli.command()
@click.argument('path-to-file', type=click.Path(exists=True))
@click.option('--text-message', default=None, help="Message to be displayed in GUI")
@click.option('--user-id', default='all', help="User ID in case there are several users in session")
def gui_send_file_to_download(path_to_file, text_message, user_id):
"""
Sends file to user's GUI. Useful for example to enable users to download reports, pcap files, etc..
"""
global state
msg_request = MsgUiSendFileToDownload()
with open(path_to_file, "rb") as file:
enc = base64.b64encode(file.read())
msg_request.fields = [
{
"name": text_message,
"type": "data",
"value": enc.decode("utf-8"),
}
]
if user_id:
msg_request.routing_key = "ui.user.{}.display".format(user_id)
_echo_input("sending file to {}".format(msg_request.routing_key))
_publish_message(msg_request)
@cli.command()
@click.argument('text-message')
@click.option('--user-id', default='all', help="User ID in case there are several users in session")
......@@ -462,6 +492,28 @@ def enter_debug_context():
cli.add_command(c)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@cli.command()
def _agent_serial_message_inject():
data = [65, 216, 206, 205, 171, 255, 255, 156, 237, 51, 4, 0, 75, 18, 0, 65, 96, 0, 0, 0, 0, 6, 58, 64, 254,
128, 0,
0, 0, 0, 0, 0, 2, 18, 75, 0, 4, 51, 237, 156, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 155, 0,
40,
63, 0, 0]
data_slip = [192, 65, 216, 206, 205, 171, 255, 255, 156, 237, 51, 4, 0, 75, 18, 0, 65, 96, 0, 0, 0, 0, 6, 58,
64,
254, 128, 0, 0, 0, 0, 0, 0, 2, 18, 75, 0, 4, 51, 237, 156, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0, 26, 155, 0, 40, 63, 0, 0, 192]
agent_name = click.prompt('enter agent name (e.g. eut2)', type=str)
m = MsgPacketInjectRaw(
timestamp=1488586183.45,
interface_name='/dev/tun/uruguay_noma',
data=data,
data_slip=data_slip
)
m.routing_key = m.routing_key.replace('.*.ip.tun.', ".{}.{}.{}.".format(agent_name, '802154', 'serial'))
_publish_message(m)
# TODO group cmds
@cli.command()
@click.option('-s', '--step-id', default='TD_COAP_CORE_01_step_01', help="step id of the STIMULI")
......
......@@ -26,7 +26,7 @@ Usage:
------
>>> m = MsgTestCaseSkip(testcase_id = 'some_testcase_id')
>>> m
MsgTestCaseSkip(_api_version = 1.1.0, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
MsgTestCaseSkip(_api_version = 1.1.3, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
>>> m.routing_key
'testsuite.testcase.skip'
>>> m.message_id # doctest: +SKIP
......@@ -37,24 +37,24 @@ MsgTestCaseSkip(_api_version = 1.1.0, description = Skip testcase, node = someNo
# also we can modify some of the fields (rewrite the default ones)
>>> m = MsgTestCaseSkip(testcase_id = 'TD_COAP_CORE_03')
>>> m
MsgTestCaseSkip(_api_version = 1.1.0, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
MsgTestCaseSkip(_api_version = 1.1.3, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
>>> m.testcase_id
'TD_COAP_CORE_03'
# and even export the message in json format (for example for sending the message though the amqp event bus)
>>> m.to_json()
'{"_api_version": "1.1.0", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
'{"_api_version": "1.1.3", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
# We can use the Message class to import json into Message objects:
>>> m=MsgTestSuiteStart()
>>> m.routing_key
'testsuite.start'
>>> m.to_json()
'{"_api_version": "1.1.0", "description": "Test suite START command"}'
'{"_api_version": "1.1.3", "description": "Test suite START command"}'
>>> json_message = m.to_json()
>>> obj=Message.load(json_message,'testsuite.start', None )
>>> obj
MsgTestSuiteStart(_api_version = 1.1.0, description = Test suite START command, )
MsgTestSuiteStart(_api_version = 1.1.3, description = Test suite START command, )
>>> type(obj) # doctest: +SKIP
<class 'messages.MsgTestSuiteStart'>
......@@ -66,7 +66,7 @@ MsgTestSuiteStart(_api_version = 1.1.0, description = Test suite START command,
# the error reply (note that we pass the message of the request to build the reply):
>>> err = MsgErrorReply(m)
>>> err
MsgErrorReply(_api_version = 1.1.0, error_code = None, error_message = None, ok = False, )
MsgErrorReply(_api_version = 1.1.3, error_code = None, error_message = None, ok = False, )
# properties of the message are auto-generated:
>>> m.reply_to
......@@ -91,7 +91,7 @@ import time
import json
import uuid
API_VERSION = '1.1.0'
API_VERSION = '1.1.3'
class NonCompliantMessageFormatError(Exception):
......@@ -201,10 +201,10 @@ class Message(object):
>>> m.routing_key
'sniffing.getcapture.request'
>>> m.to_json()
'{"_api_version": "1.1.0", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.1.3", "capture_id": "TD_COAP_CORE_01"}'
>>> json_message = m.to_json()
>>> json_message
'{"_api_version": "1.1.0", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.1.3", "capture_id": "TD_COAP_CORE_01"}'
>>> obj=Message.load(json_message,'testsuite.start', None )
>>> type(obj) # doctest
<class 'messages.MsgTestSuiteStart'>
......@@ -888,6 +888,29 @@ class MsgUiRequestQuestionSelect(MsgUiRequest):
}
class MsgUiSendFileToDownload(MsgUiDisplay):
"""
Requirements: ...
Type: Event
Pub/Sub: TT -> UI
Description: Message for file download on UI
"""
_msg_data_template = {
"tags": {},
"fields": [
{
"name": "some_test_pcap_file.pcap",
"type": "data",
"value": None, # base64_encoded
}
]
}
class MsgUiRequestUploadFile(MsgUiRequest):
"""
Requirements: ...
......
......@@ -6,7 +6,7 @@ from setuptools import setup, find_packages
MAJOR = 1
MINOR = 1
PATCH = 2
PATCH = 3
VERSION = "{}.{}.{}".format(MAJOR, MINOR, PATCH)
name = 'ioppytest-utils'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment