Ignore:
Timestamp:
28/11/08 12:22:42 (12 years ago)
Author:
pjkersha
Message:

Added local Session Manager call test to combined services unit tests.

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

Legend:

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

    r4406 r4513  
    151151        # Read user Certificate into a string ready for passing via WS 
    152152        try: 
    153             userCertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
    154             userCertTxt = open(userCertFilePath, 'r').read() 
     153            userX509CertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
     154            userX509CertTxt = open(userX509CertFilePath, 'r').read() 
    155155         
    156156        except TypeError: 
    157157            # No issuing cert set 
    158             userCertTxt = None 
     158            userX509CertTxt = None 
    159159                 
    160160        except IOError, ioErr: 
     
    163163 
    164164        # Make attribute certificate request 
    165         attCert = self.siteAClnt.getAttCert(userCert=userCertTxt) 
     165        attCert = self.siteAClnt.getAttCert(userX509Cert=userX509CertTxt) 
    166166         
    167167        print "Attribute Certificate: \n\n:" + str(attCert) 
     
    179179        # Read user Certificate into a string ready for passing via WS 
    180180        try: 
    181             userCertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
    182             userCertTxt = open(userCertFilePath, 'r').read() 
     181            userX509CertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
     182            userX509CertTxt = open(userX509CertFilePath, 'r').read() 
    183183         
    184184        except TypeError: 
    185185            # No issuing cert set 
    186             userCertTxt = None 
     186            userX509CertTxt = None 
    187187                 
    188188        except IOError, ioErr: 
     
    193193        userId = _cfg['userId'] 
    194194        attCert = self.siteAClnt.getAttCert(userId=userId, 
    195                                             userCert=userCertTxt) 
     195                                            userX509Cert=userX509CertTxt) 
    196196         
    197197        print "Attribute Certificate: \n\n:" + str(attCert) 
     
    208208        # Read user Certificate into a string ready for passing via WS 
    209209        try: 
    210             userCertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
    211             userCertTxt = open(userCertFilePath, 'r').read() 
     210            userX509CertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
     211            userX509CertTxt = open(userX509CertFilePath, 'r').read() 
    212212         
    213213        except TypeError: 
    214214            # No issuing cert set 
    215             userCertTxt = None 
     215            userX509CertTxt = None 
    216216                 
    217217        except IOError, ioErr: 
     
    233233     
    234234        # Make attribute certificate request 
    235         attCert = siteBClnt.getAttCert(userCert=userCertTxt, 
     235        attCert = siteBClnt.getAttCert(userX509Cert=userX509CertTxt, 
    236236                                       userAttCert=userAttCert) 
    237237        print "Attribute Certificate: \n\n:" + str(attCert) 
     
    248248        # Read user Certificate into a string ready for passing via WS 
    249249        try: 
    250             userCertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
    251             userCertTxt = open(userCertFilePath, 'r').read() 
     250            userX509CertFilePath = xpdVars(_cfg.get('issuingClntCertFilePath')) 
     251            userX509CertTxt = open(userX509CertFilePath, 'r').read() 
    252252         
    253253        except TypeError: 
    254254            # No issuing cert set 
    255             userCertTxt = None 
     255            userX509CertTxt = None 
    256256                 
    257257        except IOError, ioErr: 
     
    277277            # Make attribute certificate request 
    278278            try: 
    279                 attCert = siteBClnt.getAttCert(userCert=userCertTxt, 
     279                attCert = siteBClnt.getAttCert(userX509Cert=userX509CertTxt, 
    280280                                               userAttCert=userAttCert) 
    281281            except Exception, e: 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/authnservice/test_authnservice.py

    r4404 r4513  
    6262        log.info("Finished loading all required data") 
    6363 
    64     def writeProxyFile(cls, proxyCert, proxyPriKey, userCert, filePath=None): 
     64    def writeProxyFile(cls, proxyCert, proxyPriKey, userX509Cert, filePath=None): 
    6565        log.info("TestAuthNService writeProxyFile() called") 
    6666 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/serverapp.py

    r4501 r4513  
    1414__revision__ = "$Id$" 
    1515import os 
     16from authkit.permissions import UserIn 
     17from authkit.authorize import authorize 
     18 
    1619from ndg.security.server.wsgi.utils.sessionmanagerclient import \ 
    1720    WSGISessionManagerClient 
     
    3942    def test_connect(self, environ, start_response): 
    4043         
    41         client = WSGISessionManagerClient(environ=environ) 
    42         res = client.connect("testuser", passphrase="testpassword") 
    4344        start_response('200 OK', [('Content-type', 'text/plain')]) 
    4445        return "test_connect succeeded" 
     46 
     47    def test_getAttributeCertificate(self, environ, start_response): 
     48        client = WSGISessionManagerClient(environ=environ) 
     49        attCert = client.getAttCert() 
     50        start_response('200 OK', [('Content-type', 'text/xml')]) 
     51        return attCert 
     52 
     53def valid(environ, username, password): 
     54    """validation function""" 
     55    try: 
     56        client = WSGISessionManagerClient(environ=environ) 
     57        res = client.connect(username, passphrase=password) 
     58    except Exception, e: 
     59        return False 
     60    else: 
     61        return True 
    4562         
    4663def app_factory(global_config, **local_conf): 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/services.ini

    r4501 r4513  
    152152# Chain of SOAP Middleware filters 
    153153[pipeline:main] 
    154 pipeline = wsseSignatureVerificationFilter AttributeAuthorityFilter SessionManagerFilter wsseSignatureFilter mainApp 
     154pipeline = wsseSignatureVerificationFilter AttributeAuthorityFilter SessionManagerFilter wsseSignatureFilter httpBasicAuthFilter mainApp 
    155155 
    156156 
     
    194194writeResponse = True 
    195195 
     196[filter:httpBasicAuthFilter] 
     197paste.filter_app_factory = authkit.authenticate:middleware 
     198setup_method=basic 
     199basic_realm=Test Realm 
     200basic_authenticate_function=ndg.security.test.combinedservices.serverapp:valid 
     201 
    196202 
    197203[WS-Security] 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/sessionmanager/usercertauthn.py

    r4464 r4513  
    2121from ndg.security.common.myproxy import MyProxyClient 
    2222 
    23 class UserCertAuthN(AbstractAuthNService): 
     23class UserX509CertAuthN(AbstractAuthNService): 
    2424    '''Test Authentication interface to the Session Manager  
    2525    returning a certificate and private key 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/test_combinedservices.cfg

    r4479 r4513  
    3636aaURI = http://localhost:8000/AttributeAuthority 
    3737 
     38[test09WSGILocalInstanceConnect] 
     39url = http://localhost:8000/test_connect 
     40username = testuser 
     41passphrase = testpassword 
     42 
    3843[wsse] 
    3944# WS-Security settings for unit test AA clients 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/combinedservices/test_combinedservices.py

    r4480 r4513  
    2121import getpass 
    2222import re 
     23import base64 
     24import urllib2 
    2325 
    2426from os.path import expandvars as xpdVars 
    2527from os.path import join as jnPath 
    26 mkPath = lambda file: jnPath(os.environ['NDGSEC_COMBINED_SRVS_UNITTEST_DIR'], file) 
     28mkPath = lambda file: jnPath(os.environ['NDGSEC_COMBINED_SRVS_UNITTEST_DIR'],  
     29                             file) 
    2730 
    2831from ndg.security.common.sessionmanager import SessionManagerClient, \ 
     
    6164        return signingCertChain 
    6265 
    63  
    64          
     66    def _httpBasicAuthReq(self, url, username, password): 
     67        """Utility for making a client request to the WSGI test application 
     68        using HTTP Basic Authentication""" 
     69        req = urllib2.Request(url) 
     70        base64String = base64.encodestring('%s:%s' % (username, password))[:-1] 
     71        authHeader =  "Basic %s" % base64String 
     72        req.add_header("Authorization", authHeader) 
     73        handle = urllib2.urlopen(req) 
     74             
     75        return handle.read() 
     76         
     77 
    6578    def setUp(self): 
    6679 
     
    247260         
    248261        # Request an attribute certificate from an Attribute Authority  
    249         # using the userCert returned from connect() 
     262        # using the userX509Cert returned from connect() 
    250263         
    251264        aaURI = self.cfg['test07GetAttCertWithUserX509Cert']['aaURI'] 
     
    266279        print "Attribute Certificate:\n%s" % attCert  
    267280 
    268              
     281 
     282    def test09WSGILocalInstanceConnect(self): 
     283        """test09WSGILocalInstanceConnect: test a WSGI app calling a Session 
     284        Manager WSGI local instance""" 
     285         
     286        # Make a client connection to the WSGI app - authenticate with WSGI 
     287        # basic auth 
     288        thisSection = 'test09WSGILocalInstanceConnect' 
     289        url = self.cfg[thisSection]['url'] 
     290        username = self.cfg[thisSection]['username'] 
     291        password = self.cfg[thisSection]['passphrase'] 
     292        print("WSGI app connecting to local Session Manager instance: %s" % 
     293              self._httpBasicAuthReq(url, username, password)) 
     294         
     295         
    269296class CombinedServicesTestSuite(unittest.TestSuite): 
    270297     
     
    279306                    "test06GetAttCertWithSessID", 
    280307                    "test07GetAttCertWithUserX509Cert", 
     308                    "test08GetAttCertFromLocalAttributeAuthority", 
     309                    "test09WSGILocalInstanceConnect", 
    281310                  )) 
    282311        unittest.TestSuite.__init__(self, map) 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/credentialwallet/test_credentialwallet.py

    r4447 r4513  
    9191-----END CERTIFICATE----- 
    9292''' 
    93         print("userCert=%s" % credWallet.userX509Cert) 
     93        print("userX509Cert=%s" % credWallet.userX509Cert) 
    9494        credWallet.userId = 'ndg-user' 
    9595        print("userId=%s" % credWallet.userId) 
     
    183183 
    184184 
    185     def test05GetAttCertRefusedWithUserCert(self): 
     185    def test05GetAttCertRefusedWithUserX509Cert(self): 
    186186         
    187187        # Keyword mapFromTrustedHosts overrides any setting in the config file 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanager/sessionMgrTest.cfg

    r4447 r4513  
    2222propFilePath = $NDGSEC_SM_UNITTEST_DIR/sessionMgr.cfg 
    2323 
    24 [test01Connect2AuthNServiceWithNoUserCertReturned] 
     24[test01Connect2AuthNServiceWithNoUserX509CertReturned] 
    2525# Alter username according to the MyProxy credentials you wish to test.  If 
    2626# passphrase is commented out you will be prompted for it on the command line. 
     
    2929passphrase = testpassword 
    3030 
    31 [test02Connect2AuthNServiceReturningAUserCert] 
     31[test02Connect2AuthNServiceReturningAUserX509Cert] 
    3232outputCredsFilePath = user.creds 
    3333 
     
    5151extACFilePath = $NDGSEC_SM_UNITTEST_DIR/ac-out.xml 
    5252 
    53 [test11GetAttCertWithUserCert] 
     53[test11GetAttCertWithUserX509Cert] 
    5454aaURI = http://localhost:5000/AttributeAuthority 
    5555 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanager/test_sessionmanager.py

    r4447 r4513  
    8787        print("Finished setting up connection") 
    8888 
    89     def _connect2UserCertAuthNService(self): 
     89    def _connect2UserX509CertAuthNService(self): 
    9090        '''Same as _connect but Session Manager is using an Authentication  
    9191        Service that returns PKI credentials i.e. like MyProxy''' 
     
    103103        self.sm['authNService'] = { 
    104104            'moduleFilePath': os.environ['NDGSEC_SM_UNITTEST_DIR'], 
    105             'moduleName': 'usercertauthn', 
    106             'className': 'UserCertAuthN', 
     105            'moduleName': 'userx509certauthn', 
     106            'className': 'UserX509CertAuthN', 
    107107            'userX509CertFilePath': userX509CertFilePath, 
    108108            'userPriKeyFilePath': userPriKeyFilePath 
     
    131131        print("Finished setting up connection") 
    132132    
    133     def test01Connect2AuthNServiceWithNoUserCertReturned(self): 
    134          
    135         thisSection = 'test01Connect2AuthNServiceWithNoUserCertReturned' 
     133    def test01Connect2AuthNServiceWithNoUserX509CertReturned(self): 
     134         
     135        thisSection = 'test01Connect2AuthNServiceWithNoUserX509CertReturned' 
    136136        username = self.cfg.get(thisSection, 'username') 
    137137        if SessionManagerTestCase.passphrase is None and \ 
     
    154154        print("User '%s' connected to Session Manager:\n%s"%(username, sessID))      
    155155                                   
    156     def test02Connect2AuthNServiceReturningAUserCert(self): 
    157          
    158         section = 'test02Connect2AuthNServiceReturningAUserCert' 
     156    def test02Connect2AuthNServiceReturningAUserX509Cert(self): 
     157         
     158        section = 'test02Connect2AuthNServiceReturningAUserX509Cert' 
    159159         
    160160        # Change to alternative authentication service 
     
    166166        self.sm['authNService'] = { 
    167167            'moduleFilePath': os.environ['NDGSEC_SM_UNITTEST_DIR'], 
    168             'moduleName': 'usercertauthn', 
    169             'className': 'UserCertAuthN', 
     168            'moduleName': 'userX509certauthn', 
     169            'className': 'UserX509CertAuthN', 
    170170            'userX509CertFilePath': userX509CertFilePath, 
    171171            'userPriKeyFilePath': userPriKeyFilePath 
     
    211211        self.sm['authNService'] = { 
    212212            'moduleFilePath': os.environ['NDGSEC_SM_UNITTEST_DIR'], 
    213             'moduleName': 'usercertauthn', 
    214             'className': 'UserCertAuthN', 
     213            'moduleName': 'userX509certauthn', 
     214            'className': 'UserX509CertAuthN', 
    215215            'userX509CertFilePath': userX509CertFilePath, 
    216216            'userPriKeyFilePath': userPriKeyFilePath 
     
    255255             
    256256 
    257     def test06DisconnectWithUserCert(self): 
    258         """test5DisconnectWithUserCert: Disconnect based on a user X.509 
     257    def test06DisconnectWithUserX509Cert(self): 
     258        """test5DisconnectWithUserX509Cert: Disconnect based on a user X.509 
    259259        cert. credential from an earlier call to connect  
    260260        """ 
    261261         
    262         self._connect2UserCertAuthNService() 
     262        self._connect2UserX509CertAuthNService() 
    263263         
    264264        # User cert DN determines ID of session to delete 
     
    347347 
    348348 
    349     def test11GetAttCertWithUserCert(self): 
    350         """test11GetAttCertWithUserCert: make an attribute request using 
     349    def test11GetAttCertWithUserX509Cert(self): 
     350        """test11GetAttCertWithUserX509Cert: make an attribute request using 
    351351        a user cert as authentication credential""" 
    352         self._connect2UserCertAuthNService() 
     352        self._connect2UserX509CertAuthNService() 
    353353 
    354354        # Request an attribute certificate from an Attribute Authority  
    355355        # using the userX509Cert returned from connect() 
    356356         
    357         aaURI = self.cfg.get('test11GetAttCertWithUserCert', 'aaURI') 
     357        aaURI = self.cfg.get('test11GetAttCertWithUserX509Cert', 'aaURI') 
    358358        attCert, errMsg, extAttCertList = self.sm.getAttCert( 
    359359                                     userX509Cert=self.userX509Cert,  
     
    392392        smTestCaseMap = map(SessionManagerTestCase, 
    393393                          ( 
    394                             "test01Connect2AuthNServiceWithNoUserCertReturned", 
    395                             "test02Connect2AuthNServiceReturningAUserCert", 
     394                            "test01Connect2AuthNServiceWithNoUserX509CertReturned", 
     395                            "test02Connect2AuthNServiceReturningAUserX509Cert", 
    396396                            "test03GetSessionStatus", 
    397397                            "test04ConnectNoCreateServerSess", 
    398398                            "test05DisconnectWithSessID", 
    399                             "test06DisconnectWithUserCert", 
     399                            "test06DisconnectWithUserX509Cert", 
    400400                            "test07GetAttCertWithSessID", 
    401401                            "test08GetAttCertRefusedWithSessID", 
    402402                            "test09GetMappedAttCertWithSessID", 
    403403                            "test10GetAttCertWithExtAttCertListWithSessID", 
    404                             "test11GetAttCertWithUserCert", 
     404                            "test11GetAttCertWithUserX509Cert", 
    405405                            "test12GetAttCertFromLocalAAInstance", 
    406406                          )) 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanager/usercertauthn.py

    r4404 r4513  
    2121from ndg.security.common.myproxy import MyProxyClient 
    2222 
    23 class UserCertAuthN(AbstractAuthNService): 
     23class UserX509CertAuthN(AbstractAuthNService): 
    2424    '''Test Authentication interface to the Session Manager  
    2525    returning a certificate and private key 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanagerclient/test_sessionmanagerclient.py

    r4437 r4513  
    303303         
    304304        # Request an attribute certificate from an Attribute Authority  
    305         # using the userCert returned from connect() 
     305        # using the userX509Cert returned from connect() 
    306306         
    307307        aaURI = self.cfg['test10GetAttCertWithUserX509Cert']['aaURI'] 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanagerclient/usercertauthn.py

    r4406 r4513  
    2121from ndg.security.common.myproxy import MyProxyClient 
    2222 
    23 class UserCertAuthN(AbstractAuthNService): 
     23class UserX509CertAuthN(AbstractAuthNService): 
    2424    '''Test Authentication interface to the Session Manager  
    2525    returning a certificate and private key 
Note: See TracChangeset for help on using the changeset viewer.