コード例 #1
0
    def test_build_enum_with_filter(self, mock_uuid):
        expected_payload = """<?xml version="1.0" ?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
            xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
            xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
    <s:Header>
        <wsa:To s:mustUnderstand="true">http://host:443/wsman</wsa:To>
        <wsman:ResourceURI s:mustUnderstand="true">http://resource_uri</wsman:ResourceURI>
        <wsa:MessageID s:mustUnderstand="true">uuid:1234-12</wsa:MessageID>
        <wsa:ReplyTo>
            <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
        </wsa:ReplyTo>
        <wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</wsa:Action>
    </s:Header>
    <s:Body>
        <wsen:Enumerate xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration">
            <wsman:Filter Dialect="http://schemas.dmtf.org/wbem/cql/1/dsp0202.pdf">DROP TABLE users</wsman:Filter>
            <wsman:OptimizeEnumeration/>
            <wsman:MaxElements>100</wsman:MaxElements>
        </wsen:Enumerate>
    </s:Body>
</s:Envelope>
"""  # noqa
        expected_payload_obj = lxml.objectify.fromstring(expected_payload)

        mock_uuid.return_value = '1234-12'
        payload = client._EnumeratePayload(
            'http://host:443/wsman', 'http://resource_uri',
            filter_query='DROP TABLE users', filter_dialect='cql').build()
        payload_obj = lxml.objectify.fromstring(payload)

        self.assertEqual(lxml.etree.tostring(expected_payload_obj),
                         lxml.etree.tostring(payload_obj))
コード例 #2
0
    def test_enumerate_without_optimization(self):
        payload = client._EnumeratePayload(
            'http://host:443/wsman', 'http://resource_uri', optimization=False,
            max_elems=42).build()
        payload_xml = lxml.etree.fromstring(payload)

        optimize_enum_elems = payload_xml.findall(
            './/{%s}OptimizeEnumeration' % client.NS_WSMAN)
        max_elem_elems = payload_xml.findall(
            './/{%s}MaxElements' % client.NS_WSMAN)
        self.assertEqual([], optimize_enum_elems)
        self.assertEqual([], max_elem_elems)