@@ -1313,3 +1313,108 @@ def test_import_no_location():
13131313 document = wsdl .Document (
13141314 wsdl_content , transport , "https://tests.python-zeep.org/content.wsdl"
13151315 )
1316+
1317+
1318+ BASE_WSDL = """
1319+ <?xml version="1.0"?>
1320+ <wsdl:definitions
1321+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
1322+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
1323+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
1324+ xmlns:tns="http://tests.python-zeep.org/xsd-main"
1325+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
1326+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
1327+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
1328+ targetNamespace="http://tests.python-zeep.org/xsd-main">
1329+
1330+ {policy}
1331+
1332+ <wsdl:types>
1333+ <xsd:schema
1334+ targetNamespace="http://tests.python-zeep.org/xsd-main"
1335+ xmlns:tns="http://tests.python-zeep.org/xsd-main">
1336+ <xsd:element name="input" type="xsd:string"/>
1337+ </xsd:schema>
1338+ </wsdl:types>
1339+
1340+ <wsdl:message name="message-1">
1341+ <wsdl:part name="response" element="tns:input"/>
1342+ </wsdl:message>
1343+
1344+ <wsdl:portType name="TestPortType">
1345+ <wsdl:operation name="TestOperation1">
1346+ <wsdl:input message="message-1"/>
1347+ </wsdl:operation>
1348+ </wsdl:portType>
1349+
1350+ <wsdl:binding name="TestBinding" type="tns:TestPortType">
1351+ <wsp:PolicyReference URI="#TestBinding"/>
1352+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
1353+ <wsdl:operation name="TestOperation1">
1354+ <soap:operation soapAction=""/>
1355+ </wsdl:operation>
1356+ </wsdl:binding>
1357+
1358+ <wsdl:service name="TestService">
1359+ <wsdl:documentation>Test service</wsdl:documentation>
1360+ <wsdl:port name="TestPortType" binding="tns:TestBinding">
1361+ <soap:address location="https://tests.python-zeep.org/tests"/>
1362+ </wsdl:port>
1363+ </wsdl:service>
1364+ </wsdl:definitions>
1365+ """
1366+
1367+
1368+ def test_parse_bindings_signed_body ():
1369+ policy = """
1370+ <wsp:Policy wsu:Id="TestBinding_policy">
1371+ <sp:SignedParts>
1372+ <sp:Body/>
1373+ </sp:SignedParts>
1374+ </wsp:Policy>
1375+ """
1376+ content = StringIO (BASE_WSDL .format (policy = policy ).strip ())
1377+ document = wsdl .Document (content , None )
1378+ assert document .bindings [
1379+ "{http://tests.python-zeep.org/xsd-main}TestBinding"
1380+ ].signatures == {"body" : True , "everything" : False , "header" : []}
1381+
1382+
1383+ def test_parse_bindings_signed_everything ():
1384+ policy = """
1385+ <wsp:Policy wsu:Id="TestBinding_policy">
1386+ <sp:SignedParts/>
1387+ </wsp:Policy>
1388+ """
1389+ content = StringIO (BASE_WSDL .format (policy = policy ).strip ())
1390+ document = wsdl .Document (content , None )
1391+ assert document .bindings [
1392+ "{http://tests.python-zeep.org/xsd-main}TestBinding"
1393+ ].signatures == {"body" : True , "everything" : True , "header" : []}
1394+
1395+
1396+ def test_parse_bindings_signed_headers ():
1397+ policy = """
1398+ <wsp:Policy wsu:Id="TestBinding_policy">
1399+ <sp:SignedParts>
1400+ <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
1401+ </sp:SignedParts>
1402+ </wsp:Policy>
1403+ """
1404+ content = StringIO (BASE_WSDL .format (policy = policy ).strip ())
1405+ document = wsdl .Document (content , None )
1406+ assert document .bindings [
1407+ "{http://tests.python-zeep.org/xsd-main}TestBinding"
1408+ ].signatures == {
1409+ "body" : False ,
1410+ "everything" : False ,
1411+ "header" : [{"Name" : "To" , "Namespace" : "http://www.w3.org/2005/08/addressing" }],
1412+ }
1413+
1414+
1415+ def test_parse_bindings_signed_nothing ():
1416+ content = StringIO (BASE_WSDL .format (policy = "" ).strip ())
1417+ document = wsdl .Document (content , None )
1418+ assert document .bindings [
1419+ "{http://tests.python-zeep.org/xsd-main}TestBinding"
1420+ ].signatures == {"body" : False , "everything" : False , "header" : []}
0 commit comments