00001
00002
00003
00004
00005
00006 import os, sys, unittest
00007 from ServiceTest import main, ServiceTestCase, ServiceTestSuite
00008 from ZSI import FaultException
00009
00010 """
00011 Unittest for contacting Clearspace blog webservice
00012
00013 WSDL:
00014 """
00015
00016
00017 def dispatch():
00018 """Run all dispatch tests"""
00019 suite = ServiceTestSuite()
00020 suite.addTest(unittest.makeSuite(ServiceTest, 'test_dispatch'))
00021 return suite
00022
00023 def local():
00024 """Run all local tests"""
00025 suite = ServiceTestSuite()
00026 suite.addTest(unittest.makeSuite(ServiceTest, 'test_local'))
00027 return suite
00028
00029 def net():
00030 """Run all network tests"""
00031 suite = ServiceTestSuite()
00032 suite.addTest(unittest.makeSuite(ServiceTest, 'test_net'))
00033 return suite
00034
00035 def all():
00036 """Run all tests"""
00037 suite = ServiceTestSuite()
00038 suite.addTest(unittest.makeSuite(ServiceTest, 'test_'))
00039 return suite
00040
00041
00042
00043 from ZSI.generate.commands import wsdl2py
00044 if not os.path.isdir('stubs'): os.makedirs('stubs')
00045 wsdl2py(['--complexType', '--schema','--output-dir=stubs', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'])
00046
00047
00048 class BlogServiceTest(ServiceTestCase):
00049 """Test case for Clearspace sandbox, example how to use client WSSE:Security UsernameToken Profile
00050
00051 <wsdl:Envelope xmlns:soap="..." xmlns:wsse="..." >
00052 <wsdl:Header>
00053 <wsse:Security>
00054 <wsse:UsernameToken>
00055 <wsse:Username>admin</wsse:Username>
00056 <wsse:Password>password</wsse:Password>
00057 </wsse:UsernameToken>
00058 </wsse:Security>
00059 </wsdl:Header>
00060 </wsdl:Envelope>
00061
00062 """
00063 name = "test_Clearspace"
00064 client_file_name = "BlogService_client.py"
00065 types_file_name = "BlogService_types.py"
00066 server_file_name = "BlogService_server.py"
00067
00068 def __init__(self, methodName):
00069 ServiceTestCase.__init__(self, methodName)
00070 self.wsdl2py_args.append('-b')
00071
00072 def _get_soap_headers(self):
00073 import oasis_200401_wss_wssecurity_secext_1_0_xsd_types
00074 from ZSI.schema import GED
00075 security = GED("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security").pyclass()
00076 token = GED("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken").pyclass()
00077 security.Any = [token]
00078 token.Username = 'billy'
00079 klass = GED("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Password").pyclass
00080 token.Any = [klass('guest'),]
00081
00082 return (security,)
00083
00084 def test_net_Blogcount(self):
00085 loc = self.client_module.BlogServiceLocator()
00086 msg = self.client_module.getBlogCountRequest()
00087 port = loc.getBlogServiceHttpPort(**self.getPortKWArgs())
00088 rsp = port.getBlogCount(msg, soapheaders=self._get_soap_headers(),)
00089
00090 def test_local_(self):
00091 import oasis_200401_wss_wssecurity_secext_1_0_xsd_types
00092 return
00093
00094 ServiceTest = BlogServiceTest
00095
00096 if __name__ == "__main__" :
00097 main()
00098