source: TI12-security/trunk/python/Tests/etreewss/client/fred_eg.py @ 4035

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/etreewss/client/fred_eg.py@4035
Revision 4035, 1.1 KB checked in by pjkersha, 12 years ago (diff)

Fixes following update to NOCS deployment.

  • m2CryptoSSLUtility.HTTPSConnection now overrides putrequest in order to ensure that the URL path is string type. unicode type gives an error
  • added a unit test for BrowsePDP - gatekeeper for MOLES/CSML access control.
Line 
1#!/usr/bin/env python
2import re
3from elementtree import ElementTree, ElementC14N
4from StringIO import StringIO
5
6   
7soapNSURI = 'http://schemas.xmlsoap.org/soap/envelope/'
8
9env = ElementTree.Element("{%s}Envelope" % soapNSURI) 
10env.set("xmlns:SOAP-ENV", soapNSURI)
11
12hdr = ElementTree.Element("{%s}Header" % soapNSURI)
13env.set("xmlns:SOAP-ENV", soapNSURI)
14env.append(hdr)
15
16body = ElementTree.Element("{%s}Body" % soapNSURI)
17env.set("xmlns:SOAP-ENV", soapNSURI)
18env.append(body)
19wsuNS='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
20env.set('xmlns:wsu', wsuNS)
21body.set('wsu:Id', '#body')
22ns = {'wsu': wsuNS}
23print "wsu:Id elements = %s" % env.findall('.//*[@wsu:Id]', namespaces=ns)
24print "Calling C14N 1st time ..."
25f = StringIO()
26ElementC14N.write(ElementC14N.build_scoped_tree(env), f)
27print f.getvalue()
28
29print "Calling C14N 2nd time ..."
30g = StringIO()
31ElementC14N.write(ElementC14N.build_scoped_tree(env), g)
32c14n = g.getvalue()
33print c14n
34filePath = './c14n.xml'
35open(filePath, 'w').write(c14n)
36
37env2 = ElementC14N.parse(filePath)
38print "wsu:Id elements = %s" % env2.findall('.//*[@wsu:Id]', namespaces=ns)
39
40
41
Note: See TracBrowser for help on using the repository browser.