예제 #1
0
    def test_process_output_invalid_sensor_alert_id(self):
        """
        Tests an invalid sensor alert id output processing of an instrumentation script.
        """
        instrumentation = self._create_instrumentation_dummy()
        sensor_alert = instrumentation._sensor_alert

        invalid_sensor_alert = SensorAlert().deepcopy(sensor_alert)
        invalid_sensor_alert.sensorAlertId = sensor_alert.sensorAlertId + 1

        # Test instrumentation script output processing.
        was_success, new_sensor_alert = instrumentation._process_output(
            json.dumps(invalid_sensor_alert.convert_to_dict()))
        self.assertFalse(was_success)
        self.assertIsNone(new_sensor_alert)
예제 #2
0
    def test_process_output_invalid_triggered_alert_levels(self):
        """
        Tests an invalid triggered alert levels output processing of an instrumentation script.
        """
        instrumentation = self._create_instrumentation_dummy()
        sensor_alert = instrumentation._sensor_alert

        invalid_sensor_alert = SensorAlert().deepcopy(sensor_alert)
        invalid_sensor_alert.triggeredAlertLevels.append(22)

        # Test instrumentation script output processing.
        was_success, new_sensor_alert = instrumentation._process_output(
            json.dumps(invalid_sensor_alert.convert_to_dict()))
        self.assertFalse(was_success)
        self.assertIsNone(new_sensor_alert)
예제 #3
0
    def test_process_output_invalid_instrumentation_alert_level(self):
        """
        Tests an invalid instrumentation alert level output processing of an instrumentation script.
        """
        instrumentation = self._create_instrumentation_dummy()
        sensor_alert = instrumentation._sensor_alert

        invalid_sensor_alert = SensorAlert().deepcopy(sensor_alert)

        arg = invalid_sensor_alert.convert_to_dict()
        arg["instrumentationAlertLevel"] = 22

        # Test instrumentation script output processing.
        was_success, new_sensor_alert = instrumentation._process_output(
            json.dumps(arg))
        self.assertFalse(was_success)
        self.assertIsNone(new_sensor_alert)
예제 #4
0
    def test_process_output_invalid_time_received(self):
        """
        Tests an invalid time received output processing of an instrumentation script.
        """
        instrumentation = self._create_instrumentation_dummy()
        sensor_alert = instrumentation._sensor_alert

        invalid_sensor_alert = SensorAlert().deepcopy(sensor_alert)
        invalid_sensor_alert.timeReceived = sensor_alert.timeReceived + 1

        arg = invalid_sensor_alert.convert_to_dict()
        arg["instrumentationAlertLevel"] = sensor_alert.alertLevels[0]

        # Test instrumentation script output processing.
        was_success, new_sensor_alert = instrumentation._process_output(
            json.dumps(arg))
        self.assertFalse(was_success)
        self.assertIsNone(new_sensor_alert)
예제 #5
0
    def test_process_output_invalid_data_type(self):
        """
        Tests an invalid data type output processing of an instrumentation script.
        """
        instrumentation = self._create_instrumentation_dummy()
        sensor_alert = instrumentation._sensor_alert

        invalid_sensor_alert = SensorAlert().deepcopy(sensor_alert)
        invalid_sensor_alert.dataType = SensorDataType.INT
        invalid_sensor_alert.sensorData = 1

        arg = invalid_sensor_alert.convert_to_dict()
        arg["instrumentationAlertLevel"] = sensor_alert.alertLevels[0]

        # Test instrumentation script output processing.
        was_success, new_sensor_alert = instrumentation._process_output(
            json.dumps(arg))
        self.assertFalse(was_success)
        self.assertIsNone(new_sensor_alert)
예제 #6
0
    def test_process_output_invalid_data_none(self):
        """
        Tests an invalid data output processing of an instrumentation script (None expected, integer received).
        """
        instrumentation = self._create_instrumentation_dummy()
        sensor_alert = instrumentation._sensor_alert
        sensor_alert.dataType = SensorDataType.NONE
        sensor_alert.sensorData = None

        invalid_sensor_alert = SensorAlert().deepcopy(sensor_alert)
        invalid_sensor_alert.sensorData = 1337

        arg = invalid_sensor_alert.convert_to_dict()
        arg["instrumentationAlertLevel"] = sensor_alert.alertLevels[0]

        # Test instrumentation script output processing.
        was_success, new_sensor_alert = instrumentation._process_output(
            json.dumps(arg))
        self.assertFalse(was_success)
        self.assertIsNone(new_sensor_alert)