Changeset 3498


Ignore:
Timestamp:
21/02/08 15:57:08 (12 years ago)
Author:
pjkersha
Message:

Added comparison tests for inclusive/exclusive C14N + with/without inclusive
namespace prefixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/Tests/joachim/test.py

    r3272 r3498  
    2222    processorNss = \ 
    2323    { 
    24 #        'xsi':    'http://www.w3.org/2001/XMLSchema-instance', 
    25 #        'ns1':    "http://www.csapi.org/schema/parlayx/payment/amount_charging/v3_1/local", 
    26 #        'ds':     DSIG.BASE,  
    2724        'wsu':    "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", 
    28 #        'wsse':   OASIS.WSSE,  
    29 #        'SOAP-ENV':"http://schemas.xmlsoap.org/soap/envelope/"  
    3025    } 
    3126 
     
    3732    for refNode in refNodes: 
    3833        # Get ref node and all it's children 
    39 #        processorNss = {refNode.prefix: refNode.namespaceURI} 
    40 #        refSubsetQuery='(//. | //@* | //namespace::*)[ancestor-or-self::%s]' %\ 
    41 #                                                            refNode.nodeName 
    42 #        refCtx = Context(docNode, processorNss=processorNss) 
    43 #        refSubsetList = xpath.Evaluate(refSubsetQuery,  
    44 #                                       contextNode=docNode,  
    45 #                                       context=refCtx) 
    4634        refSubsetList = getChildNodes(refNode, [refNode]) 
    47         refC14n = Canonicalize(docNode, None, subset=refSubsetList, 
     35        refExclC14nWithPfx = Canonicalize(docNode, None, subset=refSubsetList, 
     36                               unsuppressedPrefixes=['SOAP-ENV', 'SOAP-ENC', 
     37                               'ZSI', 'ns1', 'wsu', 'xsd', 'xsi', 'ds', 'ec']) 
     38        refExclC14n = Canonicalize(docNode, None, subset=refSubsetList, 
    4839                               unsuppressedPrefixes=[]) 
    49         print refC14n 
    50         import pdb;pdb.set_trace() 
     40        refInclC14n1 = Canonicalize(docNode, None, subset=refSubsetList) 
     41        refInclC14n2 = Canonicalize(refNode) 
     42 
     43        # For inclusive C14N either form of call to Canonicalize above will 
     44        # give the same result: 
     45        assert(refInclC14n1==refInclC14n2) 
     46 
     47        # Expected to be different as Exclusive omits surperfluous ancestor 
     48        # namespace declarations 
     49        assert(refExclC14n != refInclC14n1) 
     50 
     51        # If the right namespace declarations are explicitly included, Exclusive 
     52        # C14N gives the same result as inclusive C14N 
     53        assert(refInclC14n2==refExclC14nWithPfx) 
    5154 
    5255def getChildNodes(node, nodeList=None): 
Note: See TracChangeset for help on using the changeset viewer.