def test_ping_exception(self, mock_ping):
     mock_ping.side_effect = ConnectionError(
         "Failed to establish a new connection")
     transmission = StixTransmission("trendmicro_vision_one", CONNECTION,
                                     CONFIG)
     ping_response = transmission.ping()
     self.assertFalse(ping_response["success"])
 def test_ping_unknown_failure(self, mock_ping):
     response = {
         "error": {
             "code": "InternalError",
         }
     }
     mock_ping.side_effect = [MockResponse(503, json.dumps(response))]
     transmission = StixTransmission("trendmicro_vision_one", CONNECTION,
                                     CONFIG)
     ping_response = transmission.ping()
     self.assertFalse(ping_response["success"])
     self.assertEqual(ping_response["code"], "unknown")
 def test_ping(self, mock_ping):
     response = {
         "data": [{
             "modelId": "modelId",
             "name": "name",
             "enabled": False
         }]
     }
     mock_ping.side_effect = [MockResponse(200, json.dumps(response))]
     transmission = StixTransmission("trendmicro_vision_one", CONNECTION,
                                     CONFIG)
     ping_response = transmission.ping()
     self.assertTrue(ping_response["success"])
 def test_ping_failure(self, mock_ping):
     response = {
         "error": {
             "code":
             "Unsupported",
             "message":
             "The specified search parameters are invalid. Verify the parameters and try again."
         }
     }
     mock_ping.side_effect = [MockResponse(400, json.dumps(response))]
     transmission = StixTransmission("trendmicro_vision_one", CONNECTION,
                                     CONFIG)
     ping_response = transmission.ping()
     self.assertFalse(ping_response["success"])
     self.assertEqual(ping_response["code"], "invalid_parameter")
 def test_ping_auth_failure(self, mock_ping):
     response = {
         "error": {
             "code": "Unauthorized",
             "message": "No authorization token was found",
             "innererror": {
                 "code": "InvalidToken",
                 "innererror": {
                     "code": "CredentialsRequired",
                     "service": "svp"
                 }
             }
         }
     }
     mock_ping.side_effect = [MockResponse(401, json.dumps(response))]
     transmission = StixTransmission("trendmicro_vision_one", CONNECTION,
                                     CONFIG)
     ping_response = transmission.ping()
     self.assertFalse(ping_response["success"])
     self.assertEqual(ping_response["code"], "authentication_fail")