source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/wsSecurity/client/echoClientTest.py @ 3122

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/wsSecurity/client/echoClientTest.py@3122
Revision 3122, 2.1 KB checked in by pjkersha, 12 years ago (diff)

security/python/ndg.security.test/ndg/security/test/wsSecurity/client: complete unit test

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2#
3# Exampe echo client, to show extended code generation in ZSI
4#
5# Import the client proxy object
6from Echo_services import EchoLocator
7
8import unittest
9import os
10import sys
11import getpass
12import traceback
13
14from ConfigParser import SafeConfigParser
15from ndg.security.common import wsSecurity
16
17class EchoClientTestCase(unittest.TestCase):
18   
19    def setUp(self):
20       
21        self.cfg = SafeConfigParser()
22        self.cfg.read("./echoClientTest.cfg")
23        uri = self.cfg.get('setUp', 'uri')
24        signingPriKeyFilePath = self.cfg.get('setUp', 'signingPriKeyFilePath')
25        signingPriKeyPwd = self.cfg.get('setUp', 'signingPriKeyPwd')
26        signingCertFilePath = self.cfg.get('setUp', 'signingCertFilePath')
27        caCertFilePathList = self.cfg.get('setUp', 
28                                          'caCertFilePathList').split()
29       
30        # Signature handler object is passed to binding
31        sigHandler = wsSecurity.SignatureHandler(
32                                 signingPriKeyFilePath=signingPriKeyFilePath,
33                                 signingPriKeyPwd=signingPriKeyPwd,
34                                 signingCertFilePath=signingCertFilePath,
35                                 caCertFilePathList=caCertFilePathList)
36
37        locator = EchoLocator()
38        self.clnt = locator.getEcho(uri, 
39                                    sig_handler=sigHandler,
40                                    tracefile=sys.stderr)
41       
42
43    def test1Echo(self):
44        '''test1Echo: test signed message and signed response from server'''
45           
46        try:
47            resp = self.clnt.Echo("Hello from client")
48            print "Message returned was: %s" % resp
49        except:
50            self.fail(traceback.print_exc())
51     
52#_____________________________________________________________________________       
53class EchoClientTestSuite(unittest.TestSuite):
54    def __init__(self):
55        map = map(EchoClientTestCase,
56                  (
57                    "test1Echo",
58                  ))
59        unittest.TestSuite.__init__(self, map)
60                                       
61if __name__ == "__main__":
62    unittest.main()
Note: See TracBrowser for help on using the repository browser.