Ignore:
Timestamp:
01/09/08 14:37:03 (11 years ago)
Author:
cbyrom
Message:

Create new utility module, ClassFactory? - to allow generic instantiation
of classes dynamically.

Implement use of this in the AttAuth? and SessionMgr? services + adjust
the config files for these accordingly + abstract use of MyProxy? in
SessionMgr? to generic authNService - and create packages with real
and test authN services. Adjust the SessionMgr? tests to use the
test authN service.

File:
1 edited

Legend:

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

    r4120 r4158  
    2929 
    3030import logging 
    31 logging.basicConfig(level=logging.ERROR) 
     31logging.basicConfig(level=logging.DEBUG) 
    3232 
    3333 
     
    5959        propFilePath = xpdVars(self.cfg.get('setUp', 'propFilePath')) 
    6060        self.sm = SessionMgr(propFilePath=propFilePath) 
    61          
    62                                    
    63     def test1Connect(self): 
    64         """test1Connect: make a new session""" 
    65          
    66         print "\n\t" + self.test1Connect.__doc__ 
    67          
     61 
     62    def sessionMgrConnect(self): 
     63        print "Connecting to session manager..." 
    6864        username = self.cfg.get('test1Connect', 'username') 
    69          
    7065        if SessionMgrTestCase.test1Passphrase is None and \ 
    7166           self.cfg.has_option('test1Connect', 'passphrase'): 
     
    7772                prompt="\ntest1Connect pass-phrase for user %s: " % username) 
    7873 
     74        print "Connecting to session manager as user: %s..." %username 
    7975        userCert, self.userPriKey, self.issuingCert, self.sessID = \ 
    8076            self.sm.connect(username=username,  
     
    8884                         self.userPriKey)) 
    8985        open(mkPath("user.creds"), "w").write(creds) 
     86        print "Finished setting up connection" 
     87         
     88                                   
     89    def test1Connect(self): 
     90        """test1Connect: make a new session""" 
     91         
     92        username = self.cfg.get('test1Connect', 'username') 
     93        if SessionMgrTestCase.test1Passphrase is None and \ 
     94           self.cfg.has_option('test1Connect', 'passphrase'): 
     95            SessionMgrTestCase.test1Passphrase = \ 
     96                                    self.cfg.get('test1Connect', 'passphrase') 
     97         
     98        if not SessionMgrTestCase.test1Passphrase: 
     99            SessionMgrTestCase.test1Passphrase = getpass.getpass(\ 
     100                prompt="\ntest1Connect pass-phrase for user %s: " % username) 
     101 
     102        print "Connecting to session manager as user: %s..." %username 
     103        userCert, self.userPriKey, self.issuingCert, self.sessID = \ 
     104            self.sm.connect(username=username,  
     105                            passphrase=SessionMgrTestCase.test1Passphrase) 
     106        self.userCert = X509CertParse(userCert) 
     107         
     108        print "User '%s' connected to Session Manager:\n%s" % \ 
     109                                                        (username, self.sessID) 
     110        creds='\n'.join((self.issuingCert or '', 
     111                         self.userCert.asPEM().strip(), 
     112                         self.userPriKey)) 
     113        open(mkPath("user.creds"), "w").write(creds) 
    90114     
    91115             
    92116    def test2GetSessionStatus(self): 
    93117        """test2GetSessionStatus: check a session is alive""" 
    94         print "\n\t" + self.test2GetSessionStatus.__doc__ 
    95          
    96         self.test1Connect() 
     118         
     119        self.sessionMgrConnect() 
    97120        assert self.sm.getSessionStatus(sessID=self.sessID), "Session is dead" 
    98121        print "User connected to Session Manager with sessID=%s" % self.sessID 
     
    107130        sessID should be None""" 
    108131 
    109         print "\n\t" + self.test3ConnectNoCreateServerSess.__doc__ 
    110          
    111132        username = self.cfg.get('test3ConnectNoCreateServerSess', 'username') 
    112133 
     
    138159        """ 
    139160         
    140         print "\n\t" + self.test4DisconnectWithSessID.__doc__ 
    141         self.test1Connect()         
     161        self.sessionMgrConnect()         
    142162        self.sm.deleteUserSession(sessID=self.sessID) 
    143163         
     
    149169        """ 
    150170         
    151         print "\n\t" + self.test5DisconnectWithUserCert.__doc__ 
    152         self.test1Connect() 
     171        self.sessionMgrConnect() 
    153172         
    154173        # Proxy cert in signature determines ID of session to 
     
    162181        a session ID as authentication credential""" 
    163182 
    164         print "\n\t" + self.test6GetAttCertWithSessID.__doc__         
    165         self.test1Connect() 
     183        self.sessionMgrConnect() 
    166184         
    167185        attCert, errMsg, extAttCertList = self.sm.getAttCert(\ 
     
    184202        Attribute Authority where the user is NOT registered""" 
    185203 
    186         print "\n\t" + self.test6aGetAttCertRefusedWithSessID.__doc__         
    187         self.test1Connect() 
     204        self.sessionMgrConnect() 
    188205         
    189206        aaURI = self.cfg.get('test6aGetAttCertRefusedWithSessID', 'aauri') 
     
    203220        a session ID as authentication credential""" 
    204221 
    205         print "\n\t" + self.test6bGetMappedAttCertWithSessID.__doc__         
    206         self.test1Connect() 
     222        self.sessionMgrConnect() 
    207223         
    208224        # Attribute Certificate cached in test 6 can be used to get a mapped 
     
    225241        a session ID as authentication credential""" 
    226242         
    227         print "\n\t" + \ 
    228             self.test6cGetAttCertWithExtAttCertListWithSessID.__doc__         
    229         self.test1Connect() 
     243        self.sessionMgrConnect() 
    230244         
    231245        aaURI = \ 
     
    251265        """test7GetAttCertWithUserCert: make an attribute request using 
    252266        a user cert as authentication credential""" 
    253         print "\n\t" + self.test7GetAttCertWithUserCert.__doc__ 
    254         self.test1Connect() 
     267        self.sessionMgrConnect() 
    255268 
    256269        # Request an attribute certificate from an Attribute Authority  
Note: See TracChangeset for help on using the changeset viewer.