def test_veracode_xml_api_app_id(self): """ Test the VeracodeXMLAPI app_id property """ with patch("veracode.api.get_app_id", return_value=constants.VALID_UPLOAD_API["app_id"]): veracode_xml_api = VeracodeXMLAPI(app_name="TestApp") # Fail when attempting to set the app_id property to an invalid value self.assertRaises( ValueError, setattr, veracode_xml_api, "app_id", constants.INVALID_RESULTS_API_INCORRECT_APP_ID["app_id"], ) # Succeed when setting the app_id property to a valid value self.assertIsNone( setattr(veracode_xml_api, "app_id", constants.VALID_UPLOAD_API["app_id"])) # Fail when attempting to delete the app_id property, because the # deleter is intentionally missing self.assertRaises(AttributeError, delattr, veracode_xml_api, "app_id")
def test_veracode_xml_api_base_url(self): """ Test the VeracodeXMLAPI base_url property """ with patch("veracode.api.get_app_id", return_value=constants.VALID_UPLOAD_API["app_id"]): veracode_xml_api = VeracodeXMLAPI(app_name="TestApp") # Succeed when getting a valid base_url property self.assertIsInstance(getattr(veracode_xml_api, "base_url"), str) # Fail when attempting to set the base_url property to an invalid value self.assertRaises( ValueError, setattr, veracode_xml_api, "base_url", constants.INVALID_UPLOAD_API_MISSING_DOMAIN["base_url"], ) # Succeed when setting the base_url property to a valid value self.assertIsNone( setattr(veracode_xml_api, "base_url", constants.VALID_UPLOAD_API["base_url"])) # Fail when attempting to delete the base_url property, because the # deleter is intentionally missing self.assertRaises(AttributeError, delattr, veracode_xml_api, "base_url")
def test_veracode_xml_api_version(self): """ Test the VeracodeXMLAPI version property """ with patch("veracode.api.get_app_id", return_value=constants.VALID_UPLOAD_API["app_id"]): veracode_xml_api = VeracodeXMLAPI(app_name="TestApp") # Fail when attempting to get the version property because version is # hard coded to an invalid value to discourage direct use of this class self.assertRaises(ValueError, getattr, veracode_xml_api, "version") # Fail when attempting to set the version property to an invalid value self.assertRaises( ValueError, setattr, veracode_xml_api, "version", constants.INVALID_UPLOAD_API_INCORRECT_VERSION_VALUES["version"], ) # Succeed when setting the version property to a valid value self.assertIsNone( setattr(veracode_xml_api, "version", constants.VALID_RESULTS_API["version"])) # Fail when attempting to delete the version property, because the # deleter is intentionally missing self.assertRaises(AttributeError, delattr, veracode_xml_api, "version")
def test_veracode_xml_api_app_id(self): """ Test the VeracodeXMLAPI app_id property """ veracode_xml_api = VeracodeXMLAPI() # Fail when attempting to get the app_id property because app_id is # hard coded to an invalid value to discourage direct use of this class self.assertRaises(ValueError, getattr, veracode_xml_api, "app_id") # Fail when attempting to set the app_id property to an invalid value self.assertRaises( ValueError, setattr, veracode_xml_api, "app_id", constants.INVALID_RESULTS_API_INCORRECT_APP_ID["app_id"], ) # Succeed when setting the app_id property to a valid value self.assertIsNone( setattr(veracode_xml_api, "app_id", constants.VALID_UPLOAD_API["app_id"])) # Fail when attempting to delete the app_id property, because the # deleter is intentionally missing self.assertRaises(AttributeError, delattr, veracode_xml_api, "app_id")
def test_veracode_xml_api_http_post(self): """ Test the VeracodeXMLAPI http_post method """ veracode_xml_api = VeracodeXMLAPI() # Fail when attempting to delete the http_post method, because the # deleter is intentionally missing self.assertRaises(AttributeError, delattr, veracode_xml_api, "http_get")
def test_veracode_xml_api_http_post(self): """ Test the VeracodeXMLAPI http_post method """ with patch("veracode.api.get_app_id", return_value=constants.VALID_UPLOAD_API["app_id"]): veracode_xml_api = VeracodeXMLAPI(app_name="TestApp") # Fail when attempting to delete the http_post method, because the # deleter is intentionally missing self.assertRaises(AttributeError, delattr, veracode_xml_api, "http_get")
def test_veracode_xml_api__validate(self, mock_is_valid_attribute): """ Test the VeracodeXMLAPI _validate method """ veracode_xml_api = VeracodeXMLAPI() # Mock all attributes are invalid mock_is_valid_attribute.return_value = False # Fail when attempting to call the _validate method, given that the # attributes are invalid self.assertRaises( ValueError, veracode_xml_api._validate, # pylint: disable=protected-access key="key", value="patched to be invalid", ) # pylint: disable=protected-access # Mock all attributes are valid mock_is_valid_attribute.return_value = True
def test_veracode_xml_api__validate(self, mock_is_valid_attribute): """ Test the VeracodeXMLAPI _validate method """ with patch("veracode.api.get_app_id", return_value=constants.VALID_UPLOAD_API["app_id"]): veracode_xml_api = VeracodeXMLAPI(app_name="TestApp") # Mock all attributes are invalid mock_is_valid_attribute.return_value = False # Fail when attempting to call the _validate method, given that the # attributes are invalid self.assertRaises( ValueError, veracode_xml_api._validate, # pylint: disable=protected-access key="key", value="patched to be invalid", ) # pylint: disable=protected-access # Mock all attributes are valid mock_is_valid_attribute.return_value = True