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

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

python/Tests/MyProxyClient/m2CryptoMyPxClnt.py: add test for globus host cert/key in store method
Tests/Echo/EchoClient?.py, Echo/wsSecurity.py: tests for WebSphere? WS-Security encryption compatibility.

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