Ejemplo n.º 1
0
 def test_metadata_deserializer(self):
     """Should throw a 400 error on corrupt xml."""
     deserializer = common.MetadataXMLDeserializer()
     self.assertRaises(
             exception.MalformedRequestBody,
             deserializer.deserialize,
             utils.killer_xml_body())
Ejemplo n.º 2
0
 def test_metadata_deserializer(self):
     """Should throw a 400 error on corrupt xml."""
     deserializer = common.MetadataXMLDeserializer()
     self.assertRaises(
             exception.MalformedRequestBody,
             deserializer.deserialize,
             utils.killer_xml_body())
Ejemplo n.º 3
0
    def test_get_method_action_corrupt_xml(self):
        class Controller(wsgi.Controller):
            @wsgi.action('fooAction')
            def _action_foo(self, req, id, body):
                return body

        controller = Controller()
        resource = wsgi.Resource(controller)
        self.assertRaises(exception.MalformedRequestBody, resource.get_method,
                          None, 'action', 'application/xml',
                          utils.killer_xml_body())
Ejemplo n.º 4
0
    def test_safe_parse_xml(self):

        normal_body = ('<?xml version="1.0" ?>'
                       '<foo><bar><v1>hey</v1><v2>there</v2></bar></foo>')

        dom = xmlutil.safe_minidom_parse_string(normal_body)
        # Some versions of minidom inject extra newlines so we ignore them
        result = str(dom.toxml()).replace('\n', '')
        self.assertEqual(normal_body, result)

        self.assertRaises(exception.MalformedRequestBody,
                          xmlutil.safe_minidom_parse_string,
                          tests_utils.killer_xml_body())
Ejemplo n.º 5
0
    def test_get_method_action_corrupt_xml(self):
        class Controller(wsgi.Controller):
            @wsgi.action('fooAction')
            def _action_foo(self, req, id, body):
                return body

        controller = Controller()
        resource = wsgi.Resource(controller)
        self.assertRaises(
                exception.MalformedRequestBody,
                resource.get_method,
                None, 'action',
                'application/xml',
                utils.killer_xml_body())
Ejemplo n.º 6
0
    def test_safe_parse_xml(self):

        normal_body = ("""
                 <?xml version="1.0" ?><foo>
                    <bar>
                        <v1>hey</v1>
                        <v2>there</v2>
                    </bar>
                </foo>""").strip()

        dom = xmlutil.safe_minidom_parse_string(normal_body)
        self.assertEqual(normal_body, str(dom.toxml()))

        self.assertRaises(exception.MalformedRequestBody,
                          xmlutil.safe_minidom_parse_string,
                          tests_utils.killer_xml_body())
Ejemplo n.º 7
0
    def test_safe_parse_xml(self):

        normal_body = ("""
                 <?xml version="1.0" ?><foo>
                    <bar>
                        <v1>hey</v1>
                        <v2>there</v2>
                    </bar>
                </foo>""").strip()

        dom = xmlutil.safe_minidom_parse_string(normal_body)
        self.assertEqual(normal_body, str(dom.toxml()))

        self.assertRaises(exception.MalformedRequestBody,
                          xmlutil.safe_minidom_parse_string,
                          tests_utils.killer_xml_body())
Ejemplo n.º 8
0
 def test_corrupt_xml(self):
     """Should throw a 400 error on corrupt xml."""
     self.assertRaises(exception.MalformedRequestBody,
                       self.deserializer.deserialize,
                       utils.killer_xml_body())
 def test_corrupt_xml(self):
     """Should throw a 400 error on corrupt xml."""
     self.assertRaises(
             exception.MalformedRequestBody,
             self.deserializer.deserialize,
             utils.killer_xml_body())
Ejemplo n.º 10
0
 def test_with_corrupt_xml(self):
     deserializer = cells_ext.CellDeserializer()
     self.assertRaises(exception.MalformedRequestBody,
                       deserializer.deserialize, utils.killer_xml_body())
Ejemplo n.º 11
0
 def test_corrupt_xml(self):
     self.assertRaises(exception.MalformedRequestBody,
                       self.deserializer.deserialize,
                       utils.killer_xml_body())
Ejemplo n.º 12
0
 def test_corrupt_xml(self):
     self.assertRaises(exception.MalformedRequestBody, self.deserializer.deserialize, utils.killer_xml_body())
Ejemplo n.º 13
0
 def test_with_corrupt_xml(self):
     deserializer = cells_ext.CellDeserializer()
     self.assertRaises(
             exception.MalformedRequestBody,
             deserializer.deserialize,
             utils.killer_xml_body())