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

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

server-config.tac: changes to AttAuthorityService? sub class - working
stub code (apart from soap_getHostInfo) and started adding in actual hook
up to AttAuthority? code.

AttAuthorityClientTest?.py: unit tests working with server side stub version.

common/AttAuthority/init.py: change wsdl refs to url. WSDL isn't actually
relevant here, only the url for the service to be accessed.

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