Ignore:
Timestamp:
01/09/08 14:37:03 (12 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.

Location:
TI12-security/trunk/python/ndg.security.test/ndg/security/test
Files:
7 added
8 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/attAuthority/siteAAttAuthorityProperties.xml

    r4139 r4158  
    2222            <caCertFilePathList> 
    2323            <caCertFile>$NDGSEC_AACLNT_UNITTEST_DIR/ca/ndg-test-ca.crt</caCertFile> 
    24                 <caCertFile>$NDGSEC_AACLNT_UNITTEST_DIR/ca/cacert.pem</caCertFile> 
    2524                <!--  
    2625            To also trust certificates issued from your MyProxy CA, replace  
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/attAuthority/siteBAttAuthorityProperties.xml

    r4139 r4158  
    2121            <caCertFilePathList> 
    2222            <caCertFile>$NDGSEC_AACLNT_UNITTEST_DIR/ca/ndg-test-ca.crt</caCertFile> 
    23                 <caCertFile>$NDGSEC_AACLNT_UNITTEST_DIR/ca/cacert.pem</caCertFile> 
    2423                <!--  
    2524            To also trust certificates issued from your MyProxy CA, replace  
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgr/sessionMgrProperties.xml

    r4139 r4158  
    4242    <sessMgrURI>https://localhost:5700/SessionManager</sessMgrURI> 
    4343    <cookieDomain></cookieDomain> 
    44         <myProxyProp> 
     44        <authNServiceProp> 
     45            <moduleFilePath></moduleFilePath> 
     46            <moduleName>ndg.security.test.authenservice.test_authen_service</moduleName> 
     47            <className>TestAutheNService</className> 
     48            <!-- If properties file specified, the contents will augment/override any 
     49            other properties set here --> 
     50            <propertiesFile></propertiesFile> 
    4551                <!--  
    4652                Delete this element and take setting from MYPROXY_SERVER environment  
     
    8591                        --> 
    8692                <proxyCertLifetime>43200</proxyCertLifetime> <!-- in seconds --> 
    87                 <caCertFile>$NDGSEC_SM_UNITTEST_DIR/ndg-test-ca.crt</caCertFile> 
    88         </myProxyProp> 
     93                <caCertFile>$NDGSEC_SM_UNITTEST_DIR/ca/ndg-test-ca.crt</caCertFile> 
     94        </authNServiceProp> 
    8995        <simpleCACltProp> 
    9096            <uri></uri> 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgr/sessionMgrTest.cfg

    r3192 r4158  
    1717# Note also setting for test3ConnectNoCreateServerSess test below.   
    1818username = testuser 
    19 #passphrase = testpassword 
     19passphrase = testpassword 
    2020 
    2121[test2GetSessionStatus] 
     
    2323[test3ConnectNoCreateServerSess]          
    2424username = testuser 
    25 #passphrase = testpassword 
     25passphrase = testpassword 
    2626 
    2727[test6GetAttCertWithSessID] 
    28 aaURI = http://localhost:5000/AttributeAuthority 
     28aaURI = http://localhost:4900/AttributeAuthority 
    2929acOutFilePath = $NDGSEC_SM_UNITTEST_DIR/ac-out.xml 
    3030 
  • 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  
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionMgrClient/sessionMgrProperties.xml

    r4139 r4158  
    4848    <sessMgrURI>https://localhost:5700/SessionManager</sessMgrURI> 
    4949    <cookieDomain></cookieDomain> 
    50         <myProxyProp> 
     50        <simpleCACltProp> 
     51            <uri></uri> 
     52        <xmlSigKeyFile></xmlSigKeyFile> 
     53        <xmlSigCertFile></xmlSigCertFile> 
     54        <xmlSigCertPwd></xmlSigCertPwd> 
     55    </simpleCACltProp> 
     56    <credReposProp> 
     57            <modFilePath></modFilePath> 
     58            <modName>ndg.security.common.CredWallet</modName> 
     59            <className>NullCredRepos</className> 
     60            <propFile></propFile> 
     61    </credReposProp> 
     62    <authNServiceProp> 
     63            <moduleFilePath>$NDGSEC_AACLNT_UNITTEST_DIR</moduleFilePath> 
     64            <moduleName>ndg.security.server.authenservice.session_mgr_my_proxy_client</moduleName> 
     65            <className>SessionMgrMyProxyClient</className> 
     66            <!-- If properties file specified, the contents will augment/override any 
     67            other properties set here --> 
     68            <propertiesFile></propertiesFile> 
    5169                <!--  
    5270                Delete this element and take setting from MYPROXY_SERVER environment  
     
    92110                <proxyCertLifetime>43200</proxyCertLifetime> <!-- in seconds --> 
    93111                <caCertFile>$NDGSEC_SMCLNT_UNITTEST_DIR/ca/cacert.pem</caCertFile> 
    94         </myProxyProp> 
    95         <simpleCACltProp> 
    96             <uri></uri> 
    97         <xmlSigKeyFile></xmlSigKeyFile> 
    98         <xmlSigCertFile></xmlSigCertFile> 
    99         <xmlSigCertPwd></xmlSigCertPwd> 
    100     </simpleCACltProp> 
    101     <credReposProp> 
    102             <modFilePath></modFilePath> 
    103             <modName>ndg.security.common.CredWallet</modName> 
    104             <className>NullCredRepos</className> 
    105             <propFile></propFile> 
    106     </credReposProp> 
     112        </authNServiceProp> 
     113     
    107114</sessMgrProp> 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/utils/sessionMgr.cfg

    r4139 r4158  
    109109 
    110110 
    111 # MyProxy Client properties  
    112 [myProxyProp] 
     111# Authentication service properties  
     112[authNServiceProp] 
     113moduleFilePath:  
     114moduleName: ndg.security.server.authenservice.session_mgr_my_proxy_client 
     115className: SessionMgrMyProxyClient 
     116propertiesFile: 
    113117# Delete this element and take setting from MYPROXY_SERVER environment  
    114118# variable if required 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/utils/sessionMgrProperties.xml

    r4139 r4158  
    6262    <cookieDomain></cookieDomain> 
    6363    <!-- MyProxy Client properties --> 
    64     <myProxyProp> 
     64    <authNServiceProp> 
    6565        <!--  
    6666        Delete this element and take setting from MYPROXY_SERVER environment  
     
    109109        --> 
    110110        <caCertFile>$NDGSEC_DIR/conf/certs/cacert.pem</caCertFile> 
    111     </myProxyProp> 
     111    </authNServiceProp> 
    112112    <!--  
    113113    Properties for a Session Manager client to a Simple CA. 
Note: See TracChangeset for help on using the changeset viewer.