Changeset 3176 for TI12-security


Ignore:
Timestamp:
04/01/08 15:32:01 (12 years ago)
Author:
pjkersha
Message:

Improvements to MyProxy? Client unit tests - added certs and openssl config file to make test more autonomous.

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

Legend:

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

    r2909 r3176  
    2222from ndg.security.server.MyProxy import MyProxyClient 
    2323 
     24xpdVars = os.path.expandvars 
     25jnPath = os.path.join 
     26mkPath = lambda file: jnPath(os.environ['NDGSEC_MYPROXY_UNITTEST_DIR'], file) 
     27 
    2428class MyProxyClientTestCase(unittest.TestCase): 
    2529     
    2630    def setUp(self): 
    2731         
     32        if 'NDGSEC_INT_DEBUG' in os.environ: 
     33            import pdb 
     34            pdb.set_trace() 
     35         
     36        if 'NDGSEC_MYPROXY_UNITTEST_DIR' not in os.environ: 
     37            os.environ['NDGSEC_MYPROXY_UNITTEST_DIR'] = \ 
     38                os.path.abspath(os.path.dirname(__file__)) 
     39                 
    2840        configParser = SafeConfigParser() 
    29         configParser.read("./myProxyClientTest.cfg") 
     41        configFilePath = jnPath(os.environ['NDGSEC_MYPROXY_UNITTEST_DIR'], 
     42                                "myProxyClientTest.cfg") 
     43        configParser.read(configFilePath) 
    3044         
    3145        self.cfg = {} 
     
    3448             
    3549        self.clnt = MyProxyClient(\ 
    36                           propFilePath=self.cfg['setUp']['propfilepath']) 
     50                    propFilePath=xpdVars(self.cfg['setUp']['propfilepath'])) 
    3751         
    3852 
     
    4963            ownerPassphrase = getpass.getpass(\ 
    5064                              prompt="\ntest1Store cred. owner pass-phrase: ") 
     65 
     66        certFile = xpdVars(self.cfg['test1Store']['certfile']) 
     67        keyFile = xpdVars(self.cfg['test1Store']['keyfile']) 
     68        ownerCertFile = xpdVars(self.cfg['test1Store']['ownercertfile']) 
     69        ownerKeyFile = xpdVars(self.cfg['test1Store']['ownerkeyfile']) 
    5170             
    5271        try: 
    5372            self.clnt.store(self.cfg['test1Store']['username'], 
    54                         passphrase, 
    55                         self.cfg['test1Store']['certfile'], 
    56                         self.cfg['test1Store']['keyfile'], 
    57                         ownerCertFile=self.cfg['test1Store']['ownercertfile'], 
    58                         ownerKeyFile=self.cfg['test1Store']['ownerkeyfile'], 
    59                         ownerPassphrase=ownerPassphrase, 
    60                         force=False) 
     73                            passphrase, 
     74                            certFile, 
     75                            keyFile, 
     76                            ownerCertFile=ownerCertFile, 
     77                            ownerKeyFile=ownerKeyFile, 
     78                            ownerPassphrase=ownerPassphrase, 
     79                            force=False) 
    6180            print "Store creds for user %s" % \ 
    6281                                            self.cfg['test1Store']['username'] 
     
    7392          
    7493        try: 
     94            proxyCertFile = \ 
     95                xpdVars(self.cfg['test2GetDelegation']['proxycertfileout']) 
     96            proxyKeyFile = \ 
     97                xpdVars(self.cfg['test2GetDelegation']['proxykeyfileout']) 
     98 
    7599            creds = self.clnt.getDelegation(\ 
    76100                                  self.cfg['test2GetDelegation']['username'],  
     
    78102            print "proxy credentials:"  
    79103            print ''.join(creds) 
    80             open('proxy-cert.pem', 'w').write(creds[0]+''.join(creds[2:])) 
    81             open('proxy-key.pem', 'w').write(creds[1]) 
     104            open(proxyCertFile, 'w').write(creds[0]+''.join(creds[2:]))             
     105            open(proxyKeyFile, 'w').write(creds[1]) 
    82106        except: 
    83107            self.fail(traceback.print_exc()) 
     
    96120        try: 
    97121            credExists, errorTxt, fields = self.clnt.info( 
    98                                  self.cfg['test3Info']['username'], 
    99                                  self.cfg['test3Info']['ownercertfile'], 
    100                                  self.cfg['test3Info']['ownerkeyfile'], 
    101                                  ownerPassphrase=ownerPassphrase) 
     122                             self.cfg['test3Info']['username'], 
     123                             xpdVars(self.cfg['test3Info']['ownercertfile']), 
     124                             xpdVars(self.cfg['test3Info']['ownerkeyfile']), 
     125                             ownerPassphrase=ownerPassphrase) 
    102126            print "test3Info... " 
    103127            print "credExists: %s" % credExists 
     
    134158     
    135159            self.clnt.changePassphrase( 
    136                          self.cfg['test4ChangePassphrase']['username'], 
    137                          passphrase, 
    138                          newPassphrase,  
    139                          self.cfg['test4ChangePassphrase']['ownercertfile'], 
    140                          self.cfg['test4ChangePassphrase']['ownerkeyfile'], 
    141                          ownerPassphrase=ownerPassphrase) 
     160                self.cfg['test4ChangePassphrase']['username'], 
     161                passphrase, 
     162                newPassphrase,  
     163                xpdVars(self.cfg['test4ChangePassphrase']['ownercertfile']), 
     164                xpdVars(self.cfg['test4ChangePassphrase']['ownerkeyfile']), 
     165                ownerPassphrase=ownerPassphrase) 
    142166            print "Change pass-phrase" 
    143167        except: 
     
    155179        try: 
    156180            self.clnt.destroy(self.cfg['test5Destroy']['username'],  
    157                     ownerCertFile=self.cfg['test5Destroy']['ownercertfile'], 
    158                     ownerKeyFile=self.cfg['test5Destroy']['ownerkeyfile'], 
    159                     ownerPassphrase=ownerPassphrase) 
     181            ownerCertFile=xpdVars(self.cfg['test5Destroy']['ownercertfile']), 
     182            ownerKeyFile=xpdVars(self.cfg['test5Destroy']['ownerkeyfile']), 
     183            ownerPassphrase=ownerPassphrase) 
    160184            print "Destroy creds for user %s" % \ 
    161185                                        self.cfg['test5Destroy']['username'] 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/myProxy/myProxyClientTest.cfg

    r3145 r3176  
    88# version 1.0 or later. 
    99[setUp] 
    10 propFilePath: ./myProxyProperties.xml 
     10propFilePath: $NDGSEC_MYPROXY_UNITTEST_DIR/myProxyProperties.xml 
    1111 
    1212# If a pass-phrase entry is commented out it will be prompted for from the 
     
    1414# blank 
    1515[test1Store] 
    16 #username: raphaelTest 
    17 #username: gabriel 
    18 #passphrase: 
    19 #certFile: ./user-cert.pem 
    20 #keyFile: ./user-key.pem 
    21 #ownerCertFile: ./user-cert.pem 
    22 #ownerKeyFile: ./user-key.pem 
    23 #ownerPassphrase: 
    24 username: Junk 
    25 passphrase: Junk 
    26 certFile: ./Junk-cert.pem 
    27 keyFile: ./Junk-key.pem 
    28 ownerCertFile: ./Junk-cert.pem 
    29 ownerKeyFile: ./Junk-key.pem 
    30 ownerPassphrase: JunkJunk 
     16username: testuser 
     17passphrase: testpassword 
     18certFile: $NDGSEC_MYPROXY_UNITTEST_DIR/user.crt 
     19keyFile: $NDGSEC_MYPROXY_UNITTEST_DIR/user.key 
     20ownerCertFile: $NDGSEC_MYPROXY_UNITTEST_DIR/user.crt 
     21ownerKeyFile: $NDGSEC_MYPROXY_UNITTEST_DIR/user.key 
     22ownerPassphrase: testpassword 
    3123 
    3224[test2GetDelegation] 
    33 username: Junk 
    34 #username: raphaelTest 
    35 passphrase: JunkJunk 
     25username: testuser 
     26passphrase: testpassword 
     27# Locations for output proxy cert and key files 
     28proxyCertFileOut: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.crt 
     29proxyKeyFileOut: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.key 
    3630 
    3731[test3Info] 
    38 #username: sstljakTestUser 
    39 ownerCertFile: ./proxy-cert.pem 
    40 ownerKeyFile: ./proxy-key.pem 
    41 ownerPassphrase:  
     32username: testuser 
     33ownerCertFile: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.crt 
     34ownerKeyFile: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.key 
     35ownerPassphrase: testpassword 
    4236 
    4337[test4ChangePassphrase] 
    44 #username: sstljakTestUser 
    45 username: Junk 
    46 ownerCertFile: ./proxy-cert.pem 
    47 ownerKeyFile: ./proxy-key.pem 
    48 passphrase: JunkJunk 
    49 newPassphrase: JunkJunk2 
    50 ownerPassphrase:  
     38username: testuser 
     39ownerCertFile: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.crt 
     40ownerKeyFile: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.key 
     41passphrase: testpassword 
     42newPassphrase: testpassword2 
     43ownerPassphrase: testpassword 
    5144 
    5245[test5Destroy] 
    53 #username: sstljakTestUser 
    54 username: Junk 
    55 ownerCertFile: ./proxy-cert.pem 
    56 ownerKeyFile: ./proxy-key.pem 
    57 ownerPassphrase:  
     46username: testuser 
     47ownerCertFile: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.crt 
     48ownerKeyFile: $NDGSEC_MYPROXY_UNITTEST_DIR/proxy.key 
     49ownerPassphrase: testpassword 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/myProxy/myProxyProperties.xml

    r3024 r3176  
    2020        Set "host/" prefix to host cert CN as is default with globus 
    2121        --> 
    22         <serverCNprefix></serverCNprefix>        
     22        <serverCNprefix>host/</serverCNprefix>   
    2323        <!-- 
    2424        This directory path is used to locate the OpenSSL configuration file 
     
    3030        but the settings can be independent of any Globus installation 
    3131        --> 
    32         <openSSLConfFilePath>$NDGSEC_DIR/conf/openssl.conf</openSSLConfFilePath> 
     32        <openSSLConfFilePath>$NDGSEC_MYPROXY_UNITTEST_DIR/openssl.conf</openSSLConfFilePath> 
    3333        <tmpDir>/tmp</tmpDir> 
    3434        <!--  
     
    4040        --> 
    4141        <!--  
    42                 Life time of a proxy certificate when issued from the Proxy Server with 
    43                 getDelegation() method 
    44                 --> 
     42        Life time of a proxy certificate when issued from the Proxy Server with 
     43        getDelegation() method 
     44        --> 
    4545        <!-- 
    4646        <proxyCertLifetime></proxyCertLifetime> 
    4747        --> 
    48         <caCertFile>$NDGSEC_DIR/conf/certs/cacert.pem</caCertFile> 
     48        <caCertFile>$NDGSEC_MYPROXY_UNITTEST_DIR/ndg-test-ca.crt</caCertFile> 
    4949</myProxyProp> 
Note: See TracChangeset for help on using the changeset viewer.