Ignore:
Timestamp:
23/11/07 13:50:10 (13 years ago)
Author:
pjkersha
Message:

SessionMgr? SessionMgrClient? unit tests complete with tests for getSessionStatus included

ndg.security.server/ndg/security/server/conf/sessionMgr.tac:

  • code for getSessionStatus incorporated

ndg.security.server/ndg/security/server/SessionMgr/SessionMgr_services_server.py,
ndg.security.common/ndg/security/common/SessionMgr/SessionMgr_services.py,
ndg.security.common/ndg/security/common/SessionMgr/SessionMgr_services_types.py,
www/html/sessionMgr.wsdl: fixed getSessionStatusResponse - isAlive element needs to be nested within a sequence elem.

ndg.security.test/ndg/security/test/sessionMgrClient/SessionMgrClientTest.py,

ndg.security.test/ndg/security/test/sessionMgrClient/sessionMgrProperties.xml: default to https for tests

ndg.security.test/ndg/security/test/sessionMgrClient/sessionMgrClientTest.cfg: get rid of test1AddUser and added test2GetSessionStatus

ndg.security.test/ndg/security/test/sessionMgr/test.py: SessionMgr? unit tests all working

ndg.security.common/ndg/security/common/SessionMgr/init.py: added getSessionStatus method

ndg.security.common/ndg/security/common/AttAuthority/init.py: fix to getHostInfo - return dict indexed by hostname

ndg.security.common/ndg/security/common/AttAuthority/AttAuthority_services.py: re-ran code generation from WSDL

Makefile: added targets for building ZSI code stubs from AA and SM WSDLs.

Location:
TI12-security/trunk/python/ndg.security.test/ndg/security/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgr/test.py

    r3041 r3044  
    77""" 
    88__author__ = "P J Kershaw" 
    9 __date__ = "23/02/06" 
     9__date__ = "20/11/07" 
    1010__copyright__ = "(C) 2007 STFC & NERC" 
    1111__license__ = \ 
     
    1313License, version 1.0 or later.""" 
    1414__contact__ = "P.J.Kershaw@rl.ac.uk" 
    15 __revision__ = '$Id: SessionMgrTest.py 2909 2007-09-28 14:22:21Z pjkersha $' 
     15__revision__ = '$Id$' 
    1616 
    1717import unittest 
     
    2121from ndg.security.common.X509 import X509CertParse 
    2222from ndg.security.server.SessionMgr import * 
    23      
    2423 
    2524 
     
    5251        """test1Connect: make a new session""" 
    5352         
     53        print "\n\t" + self.test1Connect.__doc__ 
     54         
    5455        if SessionMgrTestCase.test2Passphrase is None: 
    5556            SessionMgrTestCase.test2Passphrase = \ 
     
    7071    def test2GetSessionStatus(self): 
    7172        """test2GetSessionStatus: check a session is alive""" 
     73        print "\n\t" + self.test2GetSessionStatus.__doc__ 
     74         
    7275        self.test1Connect() 
    7376        assert self.sm.getSessionStatus(sessID=self.sessID), "Session is dead" 
     
    8386        sessID should be None""" 
    8487 
     88        print "\n\t" + self.test3ConnectNoCreateServerSess.__doc__ 
     89         
    8590        if SessionMgrTestCase.test3Passphrase is None: 
    8691            SessionMgrTestCase.test3Passphrase = \ 
     
    136141        self.test1Connect() 
    137142         
    138         attCert = self.sm.getAttCert(\ 
     143        attCert, errMsg, extAttCertList = self.sm.getAttCert(\ 
    139144            sessID=self.sessID,  
    140145            aaURI=self.cfg.get('test6GetAttCertUsingSessID', 'aauri')) 
    141          
     146        if errMsg: 
     147            self.fail(errMsg) 
     148             
    142149        print "Attribute Certificate:\n%s" % attCert  
    143150        attCert.filePath = \ 
    144151            self.cfg.get('test6GetAttCertUsingSessID', 'acoutfilepath')  
    145152        attCert.write() 
     153         
     154        return self.sm 
    146155 
    147156 
     
    156165        aaURI = self.cfg.get('test6aGetAttCertRefusedUsingSessID', 'aauri') 
    157166         
    158         attCert, errMsg, e.extAttCertList = self.sm.getAttCert(sessID=self.sessID,  
     167        attCert, errMsg, extAttCertList = self.sm.getAttCert(sessID=self.sessID,  
    159168                                         aaURI=aaURI, 
    160169                                         mapFromTrustedHosts=False) 
     
    173182        self.test1Connect() 
    174183         
     184        # Attribute Certificate cached in test 6 can be used to get a mapped 
     185        # AC for this test ... 
     186        self.sm = self.test6GetAttCertUsingSessID() 
     187 
    175188        aaURI = self.cfg.get('test6bGetMappedAttCertUsingSessID', 'aauri') 
    176189         
    177         attCert=self.sm.getAttCert(sessID=self.sessID,attAuthorityURI=aaURI) 
    178          
     190        attCert, errMsg, extAttCertList=self.sm.getAttCert(sessID=self.sessID, 
     191                                                   aaURI=aaURI, 
     192                                                   mapFromTrustedHosts=True) 
     193        if errMsg: 
     194            self.fail(errMsg) 
     195             
    179196        print "Attribute Certificate:\n%s" % attCert   
    180197 
     
    196213        extAttCert = open(extACFilePath).read() 
    197214         
    198         attCert = self.sm.getAttCert(sessID=self.sessID,  
    199                                        attAuthorityURI=aaURI, 
     215        attCert, errMsg, extAttCertList = self.sm.getAttCert(sessID=self.sessID,  
     216                                       aaURI=aaURI, 
    200217                                       extAttCertList=[extAttCert]) 
     218        if errMsg: 
     219            self.fail(errMsg) 
    201220           
    202221        print "Attribute Certificate:\n%s" % attCert   
     
    209228        self.test1Connect() 
    210229 
    211         self.sm.signatureHandler.reqBinSecTokValType = 'X509PKIPathv1' 
    212         self.sm.signatureHandler.signingPriKey = self.proxyPriKey         
    213         self.sm.signatureHandler.signingCertChain = (self.userCert, 
    214                                                        self.proxyCert) 
    215          
    216230        # Request an attribute certificate from an Attribute Authority  
    217231        # using the proxyCert returned from connect() 
    218232         
    219233        aaURI = self.cfg.get('test7GetAttCertUsingProxyCert', 'aauri') 
    220         attCert = self.sm.getAttCert(attAuthorityURI=aaURI) 
     234        attCert, errMsg, extAttCertList = self.sm.getAttCert(\ 
     235                                     userCert=self.proxyCert, aaURI=aaURI) 
     236        if errMsg: 
     237            self.fail(errMsg) 
    221238           
    222239        print "Attribute Certificate:\n%s" % attCert   
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgrClient/SessionMgrClientTest.py

    r2909 r3044  
    129129         
    130130 
    131     def test2Connect(self): 
    132         """test2Connect: Connect as if acting as a browser client -  
     131    def test1Connect(self): 
     132        """test1Connect: Connect as if acting as a browser client -  
    133133        a session ID is returned""" 
    134134         
    135135        if self.__class__.test2Passphrase is None: 
    136136            self.__class__.test2Passphrase = \ 
    137                                     self.cfg['test2Connect'].get('passphrase') 
     137                                    self.cfg['test1Connect'].get('passphrase') 
    138138         
    139139        if not self.__class__.test2Passphrase: 
     
    142142 
    143143        self.proxyCert, self.proxyPriKey, self.userCert, self.sessID = \ 
    144             self.clnt.connect(self.cfg['test2Connect']['username'],  
     144            self.clnt.connect(self.cfg['test1Connect']['username'],  
    145145                              passphrase=self.__class__.test2Passphrase) 
    146146 
    147147        print "User '%s' connected to Session Manager:\n%s" % \ 
    148             (self.cfg['test2Connect']['username'], self.sessID) 
    149              
     148            (self.cfg['test1Connect']['username'], self.sessID) 
     149             
     150             
     151    def test2GetSessionStatus(self): 
     152        """test2GetSessionStatus: check a session is alive""" 
     153        print "\n\t" + self.test2GetSessionStatus.__doc__ 
     154         
     155        self.test1Connect() 
     156        assert self.clnt.getSessionStatus(sessID=self.sessID), \ 
     157                "Session is dead" 
     158                 
     159        print "User connected to Session Manager with sessID=%s" % self.sessID 
     160 
     161        assert not self.clnt.getSessionStatus(sessID='abc'), \ 
     162            "sessID=abc shouldn't exist!" 
     163             
     164        print "CORRECT: sessID=abc doesn't exist" 
     165 
    150166 
    151167    def test3ConnectNoCreateServerSess(self): 
     
    180196         
    181197        print "\n\t" + self.test4DisconnectUsingSessID.__doc__ 
    182         self.test2Connect() 
     198        self.test1Connect() 
    183199         
    184200        self.clnt.disconnect(sessID=self.sessID) 
     
    192208         
    193209        print "\n\t" + self.test5DisconnectUsingProxyCert.__doc__ 
    194         self.test2Connect() 
     210        self.test1Connect() 
    195211         
    196212        # Use proxy cert / private key just obtained from connect call for 
     
    212228 
    213229        print "\n\t" + self.test6GetAttCertUsingSessID.__doc__         
    214         self.test2Connect() 
     230        self.test1Connect() 
    215231         
    216232        attCert = self.clnt.getAttCert(\ 
     
    230246 
    231247        print "\n\t" + self.test6aGetAttCertRefusedUsingSessID.__doc__         
    232         self.test2Connect() 
     248        self.test1Connect() 
    233249         
    234250        aaURI = self.cfg['test6aGetAttCertRefusedUsingSessID']['aauri'] 
     
    250266 
    251267        print "\n\t" + self.test6bGetMappedAttCertUsingSessID.__doc__         
    252         self.test2Connect() 
     268        self.test1Connect() 
    253269         
    254270        aaURI = self.cfg['test6bGetMappedAttCertUsingSessID']['aauri'] 
     
    265281        print "\n\t" + \ 
    266282            self.test6cGetAttCertWithExtAttCertListUsingSessID.__doc__         
    267         self.test2Connect() 
     283        self.test1Connect() 
    268284         
    269285        aaURI = \ 
     
    286302        a proxy cert as authentication credential""" 
    287303        print "\n\t" + self.test7GetAttCertUsingProxyCert.__doc__ 
    288         self.test2Connect() 
     304        self.test1Connect() 
    289305 
    290306        self.clnt.signatureHandler.reqBinSecTokValType = 'X509PKIPathv1' 
     
    315331        map = map(SessionMgrClientTestCase, 
    316332                  ( 
    317                     "test1AddUser", 
    318                     "test2Connect", 
     333                    "test1Connect", 
     334                    "test2GetSessionStatus", 
    319335                    "test3ConnectNoCreateServerSess", 
    320336                    "test4DisconnectUsingSessID", 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgrClient/sessionMgrClientTest.cfg

    r3028 r3044  
    1010# $Id:$ 
    1111[setUp] 
    12 smuri = https://localhost/SessionManager 
    13 #smuri = https://localhost:5700/SessionManager 
     12#smuri = https://localhost/SessionManager 
     13smuri = https://localhost:5700/SessionManager 
    1414#smuri = https://glue.badc.rl.ac.uk:50000/SessionManager 
    1515 
     
    4848cacertfilepathlist = ./cacert.pem 
    4949 
    50 [test1AddUser] 
    51 username = BugsBunny  
    52 # Comment out to prompt for on tty. 
    53 #passphrase = 
    54   
    55 [test2Connect]          
     50[test1Connect]          
    5651#username = lawrence 
    5752username = raphaelTest 
     
    6257username = raphaelTest 
    6358#username = gabriel 
    64 passphrase =  
     59passphrase = testpassword 
    6560 
    6661[test6GetAttCertUsingSessID] 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgrClient/sessionMgrProperties.xml

    r3028 r3044  
    22<sessMgrProp> 
    33    <portNum>5700</portNum> 
    4     <useSSL></useSSL> <!-- leave blank to use http --> 
     4    <useSSL>Yes</useSSL> <!-- leave blank to use http --> 
    55    <!--<useSSL>Yes</useSSL>  leave blank to use http --> 
    66    <sslCertFile>$NDGSEC_SM_UNITTEST_DIR/sm-cert.pem</sslCertFile> 
Note: See TracChangeset for help on using the changeset viewer.