Ignore:
Timestamp:
24/02/10 16:01:49 (10 years ago)
Author:
pjkersha
Message:

Merging in changes from 6557

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/branches/ndg-security-1.5.x/ndg_security_test/ndg/security/test/unit/credentialwallet/test_credentialwallet.py

    r6069 r6633  
    248248         
    249249    def setUp(self): 
    250         self.assertion =self._createAssertion() 
     250        self.assertion = self._createAssertion() 
    251251         
    252252    def _createAssertion(self, timeNow=None, validityDuration=60*60*8, 
     
    322322        self.assert_(len(wallet.credentials) == 0) 
    323323 
    324     def test04ReplaceCredential(self): 
     324    def test04ClockSkewTolerance(self): 
     325        # Add a short lived credential but with the wallet set to allow for 
     326        # a clock skew of  
     327        shortExpiryAssertion = self._createAssertion(validityDuration=1) 
     328        wallet = SAMLCredentialWallet() 
     329         
     330        # Set a tolerance of five seconds 
     331        wallet.clockSkewTolerance = 5.*60*60 
     332        wallet.addCredential(shortExpiryAssertion) 
     333         
     334        self.assert_(len(wallet.credentials) == 1) 
     335        sleep(2) 
     336        wallet.audit() 
     337        self.assert_(len(wallet.credentials) == 1) 
     338         
     339    def test05ReplaceCredential(self): 
    325340        # Replace an existing credential from a given institution with a more 
    326341        # up to date one 
     
    332347        wallet.addCredential(newAssertion) 
    333348        self.assert_(len(wallet.credentials) == 1) 
    334         self.assert_(newAssertion.conditions.notOnOrAfter==\ 
     349        self.assert_(newAssertion.conditions.notOnOrAfter == \ 
    335350                     wallet.credentials[ 
    336351                        SAMLCredentialWalletTestCase.SITEA_SAML_ISSUER_NAME 
    337352                    ].credential.conditions.notOnOrAfter) 
    338353         
    339     def test05CredentialsFromSeparateSites(self): 
     354    def test06CredentialsFromSeparateSites(self): 
    340355        wallet = self._addCredential() 
    341356        wallet.addCredential(self._createAssertion(issuerName="MySite")) 
    342357        self.assert_(len(wallet.credentials) == 2) 
    343358 
    344     def test06Pickle(self): 
     359    def test07Pickle(self): 
    345360        wallet = self._addCredential() 
    346361        outFile = open(SAMLCredentialWalletTestCase.PICKLE_FILEPATH, 'w') 
     
    353368            SAMLCredentialWalletTestCase.SITEA_ATTRIBUTEAUTHORITY_SAML_URI)) 
    354369         
     370        self.assert_(unpickledWallet.credentials.items()[0][1].issuerName == \ 
     371                     BaseTestCase.SITEA_SAML_ISSUER_NAME) 
     372 
     373    def test08CreateFromConfig(self): 
     374        wallet = SAMLCredentialWallet.fromConfig( 
     375                                SAMLCredentialWalletTestCase.CONFIG_FILEPATH) 
     376        self.assert_(wallet.clockSkewTolerance == timedelta(seconds=0.01)) 
     377        self.assert_(wallet.userId == 'https://openid.localhost/philip.kershaw') 
    355378         
    356379if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.