Ignore:
Timestamp:
27/11/09 15:52:29 (10 years ago)
Author:
pjkersha
Message:

Working authz lite integration tests with integrated SAML Attribute Authority interface to authz middleware: the old NDG Attribute Authority SOAP/WSDL interface is completely removed as a dependency.

  • major fixes to ndg.security.common.credentialwallet NDGCredentialWallet and SAMLCredentialWallet for slots and pickling capability needed for beaker.session. NDGCredentialWallet is kept for the moment for backwards compatibility.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg_security_test/ndg/security/test/unit/credentialwallet/test_credentialwallet.py

    r6062 r6063  
    1717from string import Template 
    1818from cStringIO import StringIO 
     19import cPickle as pickle 
     20 
    1921from elementtree import ElementTree 
    2022 
     
    4648    ndg.security.common.credentialwallet.NDGCredentialWallet class. 
    4749    """ 
     50    THIS_DIR = os.path.dirname(__file__) 
     51    PICKLE_FILENAME = 'NDGCredentialWalletPickle.dat' 
     52    PICKLE_FILEPATH = os.path.join(THIS_DIR, PICKLE_FILENAME) 
     53 
    4854    def __init__(self, *arg, **kw): 
    4955        super(NDGCredentialWalletTestCase, self).__init__(*arg, **kw) 
     
    108114             
    109115        credWallet.attributeAuthority = None 
    110         credWallet.credentialRepository = None 
     116        credWallet._credentialRepository = None 
    111117        credWallet.mapFromTrustedHosts = False 
    112118        credWallet.rtnExtAttCertList = True 
     
    159165            attCert = credWallet.getAttCert() 
    160166        except CredentialWalletAttributeRequestDenied, e: 
    161             print("SUCCESS - obtained expected result: %s" % e) 
     167            print("ok - obtained expected result: %s" % e) 
    162168            return 
    163169         
     
    196202        print("Attribute Certificate:\n%s" % attCert)   
    197203 
     204    def test08Pickle(self): 
     205        credWallet = NDGCredentialWallet(cfg=self.cfg.get('setUp',  
     206                                                          'cfgFilePath')) 
     207 
     208        outFile = open(NDGCredentialWalletTestCase.PICKLE_FILEPATH, 'w') 
     209        pickle.dump(credWallet, outFile) 
     210        outFile.close() 
     211         
     212        inFile = open(NDGCredentialWalletTestCase.PICKLE_FILEPATH) 
     213        unpickledCredWallet = pickle.load(inFile) 
     214        self.assert_(unpickledCredWallet.userId == credWallet.userId) 
     215         
    198216 
    199217class SAMLCredentialWalletTestCase(BaseTestCase): 
     
    201219    CONFIG_FILENAME = 'test_samlcredentialwallet.cfg' 
    202220    CONFIG_FILEPATH = os.path.join(THIS_DIR, CONFIG_FILENAME) 
     221    PICKLE_FILENAME = 'SAMLCredentialWalletPickle.dat' 
     222    PICKLE_FILEPATH = os.path.join(THIS_DIR, PICKLE_FILENAME) 
    203223     
    204224    ASSERTION_STR = ( 
     
    321341        wallet.addCredential(self._createAssertion(issuerName="MySite")) 
    322342        self.assert_(len(wallet.credentials) == 2) 
     343 
     344    def test06Pickle(self): 
     345        wallet = self._addCredential() 
     346        outFile = open(SAMLCredentialWalletTestCase.PICKLE_FILEPATH, 'w') 
     347        pickle.dump(wallet, outFile) 
     348        outFile.close() 
     349         
     350        inFile = open(SAMLCredentialWalletTestCase.PICKLE_FILEPATH) 
     351        unpickledWallet = pickle.load(inFile) 
     352        self.assert_(unpickledWallet.credentialsKeyedByURI.get( 
     353            SAMLCredentialWalletTestCase.SITEA_ATTRIBUTEAUTHORITY_SAML_URI)) 
    323354         
    324355         
Note: See TracChangeset for help on using the changeset viewer.