source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/AttAuthorityClientTest.py @ 1967

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/AttAuthorityClientTest.py@1967
Revision 1967, 3.4 KB checked in by pjkersha, 14 years ago (diff)

python/ndg.security.test/ndg/security/test/AttAuthority/AttAuthorityClientTest.py: corrected header

python/ndg.security.test/ndg/security/test/AttCert,
python/ndg.security.test/ndg/security/test/AttCert/attCertTest.cfg,
python/ndg.security.test/ndg/security/test/AttCert/init.py,
python/ndg.security.test/ndg/security/test/AttCert/AttCertTest.py: AttCert? unit test

python/ndg.security.test/ndg/security/test/MyProxy/MyProxyClientTest.py: fixes to header

python/ndg.security.common/ndg/security/common/XMLSec.py: fix to str method - missed out return statement.

python/ndg.security.common/ndg/security/common/AttCert.py:

  • fix to XMLSec imports
  • added provenance default to init
  • updates to setitem and getitem
  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2"""NDG Attribute Authority client unit tests
3
4NERC Data Grid Project
5
6@author P J Kershaw 05/05/05
7
8@copyright (C) 2006 CCLRC & NERC
9
10@license This software may be distributed under the terms of the Q Public
11License, version 1.0 or later.
12"""
13
14reposID = '$Id$'
15
16import unittest
17import os
18import sys
19
20from ndg.security.common.AttAuthority import AttAuthorityClient
21
22class AttAuthorityClientTestCase(unittest.TestCase):
23   
24    def setUp(self):
25        # Session Manager WSDL
26        self.uri = 'http://127.0.0.1:5700/AttributeAuthority'
27
28        # Instantiate WS proxy
29        self.clnt = AttAuthorityClient(self.uri, tracefile=sys.stderr)
30   
31   
32    def testGetPubKey(self):
33        '''testGetPubKey: retrieve Attribute Authority's X.509 cert.'''
34        #import pdb;pdb.set_trace()
35        resp = self.clnt.getPubKey()
36        print "Attribute Authority public key:\n" + resp
37       
38
39    def testGetTrustedHostInfo(self):
40        """testGetTrustedHostInfo: retrieve trusted host info matching a
41        given role"""
42        role = 'role'
43        self.clnt.getTrustedHostInfo(role)
44
45
46    def testGetTrustedHostInfoWithNoRole(self):
47        """testGetTrustedHostInfoWithNoRole: retrieve trusted host info
48        irrespective of role"""
49        self.clnt.getTrustedHostInfo()
50
51    def testGetHostInfo(self):
52        """testGetHostInfo: retrieve info for AA host"""
53        self.clnt.getHostInfo()
54
55
56    def testGetAttCert(self):       
57        """testGetAttCert: Request attribute certificate from NDG Attribute
58        Authority Web Service."""
59   
60        # User's proxy certificate
61        userCertFilePath = "/tmp/x509up_u1001"
62   
63        # Existing Attribute Certificate held in user's CredentialWallet. 
64        # This is available for use with trusted data centres to make new
65        # mapped Attribute Certificates
66        userAttCertFilePath = None
67   
68        # Read user Proxy Certificate into a string ready for passing via WS
69        try:
70            userCertFileTxt = open(userCertFilePath, 'r').read()
71           
72        except IOError, ioErr:
73            raise "Error reading proxy certificate file \"%s\": %s" % \
74                                    (ioErr.filename, ioErr.strerror)
75   
76   
77        # Simlarly for Attribute Certificate if present ...
78        if userAttCertFilePath is not None:
79           
80            try:
81                userAttCertFileTxt = open(userAttCertFilePath, 'r').read()
82               
83            except IOError, ioErr:
84                raise "Error reading attribute certificate file \"%s\": %s" %\
85                                        (ioErr.filename, ioErr.strerror)
86        else:
87            userAttCertFileTxt = None
88           
89   
90        # Make attribute certificate request
91        resp = self.clnt.getAttCert(userCertFileTxt)
92        return resp
93       
94 
95#_____________________________________________________________________________       
96class AttAuthorityClientTestSuite(unittest.TestSuite):
97    def __init__(self):
98        map = map(AttAuthorityClientTestCase,
99                  (
100                    "testGetHostInfo",
101                    "testGetTrustedHostInfo",
102                    "testGetTrustedHostInfoWithNoRole",
103                    "testGetAttCert",
104                    "testGetPubKey",
105                  ))
106        unittest.TestSuite.__init__(self, map)
107                                       
108if __name__ == "__main__":
109    unittest.main()
Note: See TracBrowser for help on using the repository browser.