source: TI12-security/trunk/NDGSecurity/python/Tests/m2Crypto/httpsTest.py @ 7681

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDGSecurity/python/Tests/m2Crypto/httpsTest.py@7681
Revision 7681, 2.4 KB checked in by pjkersha, 10 years ago (diff)

Incomplete - task 16: NDG Security 2.0.1 - incl. updated Paster templates

  • Fix mutable keyword defaults
  • Property svn:keywords set to Id
Line 
1#!/use/bin/env python
2from M2Crypto.httpslib import HTTPSConnection
3from M2Crypto import SSL
4
5#hostname = 'gabriel.badc.rl.ac.uk'
6##hostname = 'grid.bodc.nerc.ac.uk'
7#path = '/openid'
8#
9#body = '''<SOAP-ENV:Envelope
10#xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
11#xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
12#xmlns:ns1="urn:ndg.security.sessionMgr">
13#<SOAP-ENV:Header></SOAP-ENV:Header>
14#<SOAP-ENV:Body><ns1:getAttCert/></SOAP-ENV:Body>'''
15body = '''<soap11:Envelope xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
16    <soap11:Header></soap11:Header>
17    <soap11:Body>
18        <samlp:AttributeQuery xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Version="2.0" IssueInstant="2010-10-22T10:32:07.585451Z" ID="bf152f2e-d00f-44a3-93ea-968445bbeb4a">
19            <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName">/O=STFC/OU=BADC/CN=Test</saml:Issuer>
20            <saml:Subject xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
21                <saml:NameID Format="urn:esg:openid">https://ceda.ac.uk/openid/Philip.Kershaw</saml:NameID>
22            </saml:Subject>
23            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="GroupRole" Name="urn:esg:group:role" NameFormat="groupRole"></saml:Attribute>
24            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="LastName" Name="urn:esg:last:name" NameFormat="http://www.w3.org/2001/XMLSchema#string"></saml:Attribute>
25            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="EmailAddress" Name="urn:esg:email:address" NameFormat="http://www.w3.org/2001/XMLSchema#string"></saml:Attribute>
26            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="FirstName" Name="urn:esg:first:name" NameFormat="http://www.w3.org/2001/XMLSchema#string"></saml:Attribute>
27        </samlp:AttributeQuery>
28    </soap11:Body>
29</soap11:Envelope>
30'''
31ctx = SSL.Context()
32ctx.load_verify_locations(capath=caDir)
33ctx.set_verify(SSL.verify_peer, 9)
34con = HTTPSConnection(hostname, ssl_context=ctx)
35con.putrequest('POST', path)
36con.putheader('Content-Type', 'text/xml')
37con.putheader('Content-Length', str(len(body)))
38con.endheaders()
39con.send(body)
40resp = con.getresponse()
41print resp.read()
42
43#con = HTTPSConnection(hostname)
44#con.putrequest('GET', path)
45#con.endheaders()
46#resp = con.getresponse()
47#print resp.read()
Note: See TracBrowser for help on using the repository browser.