@@ -75,7 +75,7 @@ def test_rebuild_xml():
7575 assert_nodes_equal (etree .tostring (document ), expected )
7676
7777
78- def test_xop ():
78+ def get_client_service ():
7979 wsdl_main = StringIO (
8080 """
8181 <?xml version="1.0"?>
@@ -172,6 +172,11 @@ def test_xop():
172172 "http://tests.python-zeep.org/test" ,
173173 )
174174
175+ return service
176+
177+
178+ def test_xop ():
179+ service = get_client_service ()
175180 content_type = 'multipart/related; boundary="boundary"; type="application/xop+xml"; start="<soap:Envelope>"; start-info="application/soap+xml; charset=utf-8"'
176181
177182 response1 = "\r \n " .join (
@@ -252,3 +257,48 @@ def test_xop():
252257 )
253258 result = service .TestOperation1 ("" )
254259 assert result == "BINARYDATA" .encode ()
260+
261+
262+ def test_xop_cid_encoded ():
263+ service = get_client_service ()
264+ content_type = 'multipart/related; boundary="boundary"; type="application/xop+xml"; start="<soap:Envelope>"; start-info="application/soap+xml; charset=utf-8"'
265+
266+ response_encoded_cid = "\r \n " .join (
267+ line .strip ()
268+ for line in """
269+ Content-Type: application/xop+xml; charset=utf-8; type="application/soap+xml"
270+ Content-Transfer-Encoding: binary
271+ Content-ID: <soap:Envelope>
272+
273+ <?xml version="1.0" encoding="UTF-8"?>
274+ <soap:Envelope
275+ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
276+ xmlns:xop="http://www.w3.org/2004/08/xop/include"
277+ xmlns:test="http://tests.python-zeep.org/xsd-main">
278+ <soap:Body>
279+ <test:resultComplex>
280+ <test:BinaryData>
281+ <xop:Include href="cid:test_encoding%20cid%25%24%7D%40"/>
282+ </test:BinaryData>
283+ </test:resultComplex>
284+ </soap:Body>
285+ </soap:Envelope>
286+ --boundary
287+ Content-Type: application/binary
288+ Content-Transfer-Encoding: binary
289+ Content-ID: <test_encoding cid%$}@>
290+
291+ BINARYDATA
292+
293+ --boundary--
294+ """ .splitlines ()
295+ )
296+
297+ with requests_mock .mock () as m :
298+ m .post (
299+ "http://tests.python-zeep.org/test" ,
300+ content = response_encoded_cid .encode ("utf-8" ),
301+ headers = {"Content-Type" : content_type },
302+ )
303+ result = service .TestOperation2 ("" )
304+ assert result ["_value_1" ] == "BINARYDATA" .encode ()
0 commit comments