def test_get_payload_sensor_statuses(self): expected_info = self.get_expected_deployment_info() expected_sensor1 = MagicMock(spec=sensor.Sensor) expected_sensor1.is_connected = True expected_sensor1.platform = 'alienvault-vmware' expected_sensor2 = MagicMock(spec=sensor.Sensor) expected_sensor2.is_connected = False expected_sensor2.platform = None expected_info.sensors = [expected_sensor1, expected_sensor2] expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0][ 'connectionStatus'] = usmcentral_http_proxy.SENSOR_STATUS_CONNECTED expected_payload['sensors'][0][ 'platform'] = usmcentral_http_proxy.PLATFORMS_MAP.get( 'alienvault-vmware') expected_payload['sensors'][1][ 'connectionStatus'] = usmcentral_http_proxy.SENSOR_STATUS_CONNECTION_LOST expected_payload['sensors'][1][ 'platform'] = usmcentral_http_proxy.SENSOR_FALLBACK_PLATFORM actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_no_expiration(self): expected_info = self.get_expected_deployment_info() expected_info.license.expires_on = None expected_payload = self.get_expected_payload_complete(expected_info) del expected_payload['license']['expiresOn'] actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_no_devices(self): expected_info = self.get_expected_deployment_info() expected_info.license.devices = None expected_payload = self.get_expected_payload_complete(expected_info) del expected_payload['license']['devices'] actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_no_contact_email(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.contact_email = None expected_payload = self.get_expected_payload_complete(expected_info) del expected_payload['controlNode']['contactEmail'] actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_no_contact_email(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.contact_email = None expected_payload = self.get_expected_payload_complete(expected_info) del expected_payload['controlNode']['contactEmail'] actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_no_platform(self): expected_info = self.get_expected_deployment_info() expected_info.sensors[0].platform = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0]['platform'] = usmcentral_http_proxy.SENSOR_FALLBACK_PLATFORM actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_no_software_version(self): expected_info = self.get_expected_deployment_info() expected_info.sensors[0].software_version = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0]['softwareVersion'] = usmcentral_http_proxy.SENSOR_FALLBACK_SOFTWARE_VERSION actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_control_node_no_platform(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.platform = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['controlNode']['platform'] = usmcentral_http_proxy.CONTROL_NODE_FALLBACK_PLATFORM actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_control_node_no_appliance_type(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.appliance_type = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['controlNode']['applianceType'] = usmcentral_http_proxy.CONTROL_NODE_FALLBACK_APPLIANCE_TYPE actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_no_devices(self): expected_info = self.get_expected_deployment_info() expected_info.license.devices = None expected_payload = self.get_expected_payload_complete(expected_info) del expected_payload['license']['devices'] actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_no_expiration(self): expected_info = self.get_expected_deployment_info() expected_info.license.expires_on = None expected_payload = self.get_expected_payload_complete(expected_info) del expected_payload['license']['expiresOn'] actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload(self): expected_info = self.get_expected_deployment_info() expected_payload = self.get_expected_payload_complete(expected_info) actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) actual_payload['controlNode']['platform'] = usmcentral_http_proxy.PLATFORMS_MAP.get( expected_info.control_node.platform ) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_control_node_no_intelligence_version(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.intelligence_version = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['controlNode']['threatIntelligenceVersion'] = \ usmcentral_http_proxy.CONTROL_NODE_FALLBACK_INTELLIGENCE_VERSION actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_no_intelligence_version(self): expected_info = self.get_expected_deployment_info() expected_info.sensors[0].threat_intelligence_version = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0]['threatIntelligenceVersion'] = \ usmcentral_http_proxy.SENSOR_FALLBACK_INTELLIGENCE_VERSION actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload(self): expected_info = self.get_expected_deployment_info() expected_payload = self.get_expected_payload_complete(expected_info) actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) actual_payload['controlNode'][ 'platform'] = usmcentral_http_proxy.PLATFORMS_MAP.get( expected_info.control_node.platform) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_no_platform(self): expected_info = self.get_expected_deployment_info() expected_info.sensors[0].platform = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0][ 'platform'] = usmcentral_http_proxy.SENSOR_FALLBACK_PLATFORM actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_no_software_version(self): expected_info = self.get_expected_deployment_info() expected_info.sensors[0].software_version = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0][ 'softwareVersion'] = usmcentral_http_proxy.SENSOR_FALLBACK_SOFTWARE_VERSION actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_no_intelligence_version(self): expected_info = self.get_expected_deployment_info() expected_info.sensors[0].threat_intelligence_version = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0]['threatIntelligenceVersion'] = \ usmcentral_http_proxy.SENSOR_FALLBACK_INTELLIGENCE_VERSION actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_control_node_no_platform(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.platform = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['controlNode'][ 'platform'] = usmcentral_http_proxy.CONTROL_NODE_FALLBACK_PLATFORM actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_control_node_no_appliance_type(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.appliance_type = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['controlNode'][ 'applianceType'] = usmcentral_http_proxy.CONTROL_NODE_FALLBACK_APPLIANCE_TYPE actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_control_node_no_intelligence_version(self): expected_info = self.get_expected_deployment_info() expected_info.control_node.intelligence_version = None expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['controlNode']['threatIntelligenceVersion'] = \ usmcentral_http_proxy.CONTROL_NODE_FALLBACK_INTELLIGENCE_VERSION actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload( expected_info) self.assertEqual(actual_payload, expected_payload)
def test_get_payload_sensor_statuses(self): expected_info = self.get_expected_deployment_info() expected_sensor1 = MagicMock(spec=sensor.Sensor) expected_sensor1.is_connected = True expected_sensor1.platform = 'alienvault-vmware' expected_sensor2 = MagicMock(spec=sensor.Sensor) expected_sensor2.is_connected = False expected_sensor2.platform = None expected_info.sensors = [expected_sensor1, expected_sensor2] expected_payload = self.get_expected_payload_complete(expected_info) expected_payload['sensors'][0]['connectionStatus'] = usmcentral_http_proxy.SENSOR_STATUS_CONNECTED expected_payload['sensors'][0]['platform'] = usmcentral_http_proxy.PLATFORMS_MAP.get('alienvault-vmware') expected_payload['sensors'][1]['connectionStatus'] = usmcentral_http_proxy.SENSOR_STATUS_CONNECTION_LOST expected_payload['sensors'][1]['platform'] = usmcentral_http_proxy.SENSOR_FALLBACK_PLATFORM actual_payload = usmcentral_http_proxy.usmcentral_deployment_payload(expected_info) self.assertEqual(actual_payload, expected_payload)