Пример #1
0
    def testXMLValidationGoodXML(self):
        """A simple end-to-end test of the valid XML case."""
        valid_input_file = StringIO.StringIO(_DSPL_CONTENT_VALID)

        result = xml_validation.RunValidation(valid_input_file)
        self.assertTrue(re.search('validates successfully', result))

        valid_input_file.close()
Пример #2
0
    def testXMLValidationXMLError(self):
        """A simple end-to-end test of the bad XML case."""
        xml_error_input_file = StringIO.StringIO(_DSPL_CONTENT_XML_ERROR)

        result = xml_validation.RunValidation(xml_error_input_file)
        self.assertTrue(
            re.search('not valid XML.*line 1', result, flags=re.DOTALL))

        xml_error_input_file.close()
Пример #3
0
  def testXMLBillionLaughsAttack(self):
    """A simple test to verify that the validation routine is not susceptible
    to the billion laughs attack.
    """
    billion_laughs_input_file = StringIO.StringIO(_DSPL_BILLION_LAUGHS)
    result = xml_validation.RunValidation(billion_laughs_input_file)
    self.assertTrue(re.search('Detected an entity reference loop', result))

    billion_laughs_input_file.close()
Пример #4
0
    def testXMLValidationSchemaError(self):
        """A simple end-to-end test of the non-conforming XML case."""
        schema_error_input_file = StringIO.StringIO(_DSPL_CONTENT_SCHEMA_ERROR)

        result = xml_validation.RunValidation(schema_error_input_file)
        self.assertTrue(
            re.search('does not validate against DSPL schema.*line 6',
                      result,
                      flags=re.DOTALL))

        schema_error_input_file.close()
Пример #5
0
  def testXMLValidationSchemaError(self):
    """A simple end-to-end test of the non-conforming XML case."""
    schema_error_input_file = StringIO.StringIO(_DSPL_CONTENT_SCHEMA_ERROR)

    result = xml_validation.RunValidation(schema_error_input_file)
    # TODO: this validation failure has lineno 0; look into why lxml is not
    #       returning the right location.
    self.assertTrue(re.search('The attribute \'illegalproperty\' is not allowed',
                              result, flags=re.DOTALL))

    schema_error_input_file.close()