Commit 123747b9 authored by Federico Sismondi's avatar Federico Sismondi

fixed configuration messages send by testing tool

parent 6f0df315
......@@ -195,7 +195,7 @@ if __name__ == '__main__':
'_type': 'testcoordination.error',
}),
exchange = AMQP_EXCHANGE,
routing_key ='session.error',
routing_key ='control.session.error',
properties=pika.BasicProperties(
content_type='application/json',
)
......
......@@ -389,6 +389,7 @@ class TestCase:
if verbose:
d['testcase_ref'] = self.uri
d['objective'] = self.objective
d['pre_conditions'] = self.pre_conditions
d['state'] = self.state
return d
......@@ -669,14 +670,22 @@ class Coordinator:
with open(json_file, 'w') as f:
f.write(event.to_json())
def notify_current_configuration(self, config_id, node, message):
# TODO get configuration id , node and message from self, and not as param
event = MsgTestCaseConfiguration(
configuration_id=config_id,
node=node,
message=message
)
publish_message(self.channel, event)
def notify_current_configuration(self):
config_id = self.current_tc.configuration_id
config = self.tc_configs[config_id] # Configuration object
for desc in config.description:
message = desc['message']
node = desc['node']
event = MsgTestCaseConfiguration(
configuration_id=config_id,
node=node,
message=message,
testcase_id=self.current_tc.id,
testcase_ref=self.current_tc.uri
)
publish_message(self.channel, event)
def call_service_sniffer_start(self, **kwargs):
......@@ -1093,18 +1102,11 @@ class Coordinator:
self.current_tc.change_state('executing')
# # # CONFIGURATION PHASE # # #
FINISH this!
self.notify_current_configuration()
config_id = self.current_tc.configuration_id
config = self.tc_configs[config_id]
# notify each IUT/user about the current config
# TODO do we need a confirmation for this?
for desc in config.description:
message = desc['message']
node = desc['node']
self.notify_current_configuration(config_id, node, message)
# start sniffing each link
for link in config.topology:
filter_proto = link['capture_filter']
......
......@@ -68,7 +68,7 @@ import json
import uuid
import logging
API_VERSION = '0.1.12'
API_VERSION = '0.1.15'
# TODO use metaclasses instead?
......@@ -247,7 +247,7 @@ class MsgSessionTerminate(Message):
GUI, (or Orchestrator?) -> Testing Tool
Testing tool should stop all it's processes gracefully.
"""
routing_key = 'control.session.terminate'
routing_key = 'control.session'
_msg_data_template = {
'_type': 'session.terminate',
......@@ -269,6 +269,19 @@ class MsgTestSuiteStart(Message):
}
class MsgTestSuiteFinish(Message):
"""
Testing Tool MUST-implement API endpoint
GUI -> Testing Tool
"""
routing_key = "control.testcoordination"
_msg_data_template = {
'_type': "testcoordination.testsuite.finish",
}
class MsgTestCaseReady(Message):
"""
Testing Tool MUST-implement notification.
......@@ -315,6 +328,8 @@ class MsgTestCaseConfiguration(Message):
"_type": "testcoordination.testcase.configuration",
"configuration_id": "COAP_CFG_01_v01",
"node": "coap_server",
"testcase_id": "TBD",
"testcase_ref": "TBD",
"message":
["CoAP servers running service at [bbbb::2]:5683",
"CoAP servers are requested to offer the following resources",
......@@ -384,7 +399,9 @@ class MsgStepExecute(Message):
],
"step_state": "executing",
"node": "coap_client",
"node_execution_mode": "user_assisted"
"node_execution_mode": "user_assisted",
"testcase_id": "TBD",
"testcase_ref": "TBD"
}
......@@ -462,6 +479,7 @@ class MsgTestCaseFinished(Message):
_msg_data_template = {
'_type': 'testcoordination.testcase.finished',
'testcase_id' : 'TD_COAP_CORE_01',
"testcase_ref": "TBD",
'message' : 'Testcase finished'
}
......@@ -967,19 +985,125 @@ class MsgDissectionAutoDissect(Message):
- privacy?
"""
routing_key = 'control.dissection.auto'
routing_key = 'control.dissection'
_frames_example = MsgDissectionDissectCaptureReply._frames_example
_msg_data_template = {
'_type': 'dissection.autotriggered',
'token': '0lzzb_Bx30u8Gu-xkt1DFE1GmB4',
'frames': _frames_example
'frames': _frames_example,
"testcase_id": "TBD",
"testcase_ref": "TBD"
}
###### PRIVACY TESTING TOOL MESSAGES ######
class MsgPrivacyAnalyze(Message):
"""
Testing Tool's MUST-implement.
Analyze PCAP File for Privacy checks.
"""
routing_key = 'control.privacy.service'
# TODO: This message should be update with a valuable privacy example
PCAP_COAP_GET_OVER_TUN_INTERFACE_base64 = "1MOyoQIABAAAAAAAAAAAAMgAAABlAAAAqgl9WK8aBgA7AAAAOwAAAGADPxUAExFAu7s" \
"AAAAAAAAAAAAAAAAAAbu7AAAAAAAAAAAAAAAAAALXvBYzABNZUEABcGO0dGVzdMECqg" \
"l9WMcaBgCQAAAAkAAAAGAAAAAAaDr//oAAAAAAAAAAAAAAAAAAA7u7AAAAAAAAAAAAA" \
"AAAAAGJAAcTAAAAALu7AAAAAAAAAAAAAAAAAAK7uwAAAAAAAAAAAAAAAAACBAgAAAAA" \
"AABgAz8VABMRQLu7AAAAAAAAAAAAAAAAAAG7uwAAAAAAAAAAAAAAAAAC17wWMwATWVB" \
"AAXBjtHRlc6oJfVjSGgYAOwAAADsAAABgAz8VABMRP7u7AAAAAAAAAAAAAAAAAAG7uw" \
"AAAAAAAAAAAAAAAAAC17wWMwATWVBAAXBjtHRlc3TBAg=="
_msg_data_template = {
"_type": "privacy.analyze",
"value": PCAP_COAP_GET_OVER_TUN_INTERFACE_base64,
"file_enc": "pcap_base64",
"filename": "TD_PRIVACY_DEMO_01.pcap",
}
class MsgPrivacyGetConfiguration(Message):
"""
Read Privacy configuration.
GUI MUST display this info during setup
"""
routing_key = 'control.privacy.service'
_msg_data_template = {
"_type": "privacy.configuration.get",
}
class MsgPrivacySetConfiguration(Message):
"""
Write Privacy configuration.
GUI MUST display this info during setup
"""
routing_key = 'control.privacy.service'
CFG_EXAMPLE = {}
_msg_data_template = {
"_type": "privacy.configuration.set",
"configuration": CFG_EXAMPLE,
}
class MsgPrivacyGetStatus(Message):
"""
Testing Tool's MUST-implement.
GUI -> Testing Tool
GUI MUST display this info during execution:
- privacy?
"""
routing_key = 'control.privacy.service'
_msg_data_template = {
"_type": "privacy.getstatus",
}
class MsgPrivacyGetStatusReply(Message):
"""
Testing Tool's MUST-implement.
GUI -> Testing Tool
GUI MUST display this info during execution:
- privacy?
"""
REPORT_EXAMPLE = dict()
routing_key = 'control.privacy.service'
_msg_data_template = {
"_type": "privacy.getstatus.reply",
"verdict": REPORT_EXAMPLE,
"status" : "TBD",
"ok": True,
}
class MsgPrivacyVerdict(Message):
routing_key = 'control.privacy.service'
REPORT_EXAMPLE = dict()
_msg_data_template = {
"_type": "privacy.verdict.reply",
"verdict": REPORT_EXAMPLE,
}
message_types_dict = {
"testcoordination.testsuite.start": MsgTestSuiteStart, # GUI -> TestingTool
"testcoordination.testsuite.finish": MsgTestSuiteFinish, # GUI -> TestingTool
"testcoordination.testcase.ready": MsgTestCaseReady, # TestingTool -> GUI
"testcoordination.testcase.start": MsgTestCaseStart, # GUI -> TestingTool
"testcoordination.step.execute": MsgStepExecute, # TestingTool -> GUI
......@@ -1008,8 +1132,16 @@ message_types_dict = {
"analysis.interop.testcase.analyze.reply": MsgInteropTestCaseAnalyzeReply, # Testing Tool Internal
"dissection.dissectcapture": MsgDissectionDissectCapture, # Testing Tool Internal
"dissection.dissectcapture.reply": MsgDissectionDissectCaptureReply, # Testing Tool Internal
"dissection.autotriggered": MsgDissectionAutoDissect, # TestingTool -> GUI
"session.terminate": MsgSessionTerminate, # GUI (or Orchestrator?) -> TestingTool
"control.dissection.auto": MsgDissectionAutoDissect, # TestingTool -> GUI
# PRIVACY TESTING TOOL -> Reference: Luca Lamorte (UL)
"privacy.analyze": MsgPrivacyAnalyze, # TestingTool internal
"privacy.getstatus": MsgPrivacyGetStatus, # GUI -> TestingTool
"privacy.getstatus.reply": MsgPrivacyGetStatusReply, # GUI -> TestingTool (reply)
"privacy.verdict": MsgPrivacyVerdict, # TestingTool -> GUI,
"privacy.configuration.get": MsgPrivacyGetConfiguration, # TestingTool -> GUI,
"privacy.configuration.set": MsgPrivacySetConfiguration, # GUI -> TestingTool,
# TODO add "testingtool.ready"
}
if __name__ == '__main__':
......
......@@ -155,7 +155,7 @@ class ApiTests(unittest.TestCase):
routing_key='log.error.*')
self.channel.queue_bind(exchange=AMQP_EXCHANGE,
queue=errors_queue_name,
routing_key='session.error')
routing_key='control.session.error')
# for getting the terminate signal
self.channel.queue_bind(exchange=AMQP_EXCHANGE,
......
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