Permalink
Browse files

Change "supportdoc_manager" attribute to just "supportdocs".

  • Loading branch information...
1 parent f39fd7f commit 330074939c1db97bef5ecd67115cfb884b8bf75c @rfk rfk committed Jul 16, 2012
Showing with 14 additions and 16 deletions.
  1. +10 −10 browserid/tests/test_verifiers.py
  2. +4 −6 browserid/verifiers/local.py
@@ -301,8 +301,8 @@ def test_verification_of_dummy_assertion_with_bad_certificate_sig(self):
assertion)
def test_cache_eviction_based_on_time(self):
- supportdoc_mgr = SupportDocumentManager(FIFOCache(cache_timeout=0.1))
- verifier = LocalVerifier(["*"], supportdoc_manager=supportdoc_mgr,
+ supportdocs = SupportDocumentManager(FIFOCache(cache_timeout=0.1))
+ verifier = LocalVerifier(["*"], supportdocs=supportdocs,
warning=False)
# Prime the cache by verifying an assertion.
assertion = make_assertion("test@example.com", "")
@@ -318,19 +318,19 @@ def test_cache_eviction_based_on_time(self):
self.assertRaises(RuntimeError, verifier.verify, assertion)
def test_cache_eviction_based_on_size(self):
- supportdoc_mgr = SupportDocumentManager(max_size=2)
- verifier = LocalVerifier(["*"], supportdoc_manager=supportdoc_mgr,
+ supportdocs = SupportDocumentManager(max_size=2)
+ verifier = LocalVerifier(["*"], supportdocs=supportdocs,
warning=False)
# Prime the cache by verifying some assertions.
assertion1 = make_assertion("test@1.com", "", "1.com")
self.assertTrue(verifier.verify(assertion1))
assertion2 = make_assertion("test@2.com", "", "2.com")
self.assertTrue(verifier.verify(assertion2))
- self.assertEquals(len(supportdoc_mgr.cache), 2)
+ self.assertEquals(len(supportdocs.cache), 2)
# Hitting a third host should evict the first public key.
assertion3 = make_assertion("test@3.com", "", "3.com")
self.assertTrue(verifier.verify(assertion3))
- self.assertEquals(len(supportdoc_mgr.cache), 2)
+ self.assertEquals(len(supportdocs.cache), 2)
# Make it error out if re-fetching any keys
exc = RuntimeError("key fetch disabled")
@@ -340,19 +340,19 @@ def test_cache_eviction_based_on_size(self):
self.assertRaises(RuntimeError, verifier.verify, assertion1)
def test_cache_eviction_during_write(self):
- supportdoc_mgr = SupportDocumentManager(cache_timeout=0.1)
- verifier = LocalVerifier(["*"], supportdoc_manager=supportdoc_mgr,
+ supportdocs = SupportDocumentManager(cache_timeout=0.1)
+ verifier = LocalVerifier(["*"], supportdocs=supportdocs,
warning=False)
# Prime the cache by verifying an assertion.
assertion1 = make_assertion("test@1.com", "", "1.com")
self.assertTrue(verifier.verify(assertion1))
- self.assertEquals(len(supportdoc_mgr.cache), 1)
+ self.assertEquals(len(supportdocs.cache), 1)
# Let that cached key expire
time.sleep(0.1)
# Now grab a different key; caching it should purge the expired key.
assertion2 = make_assertion("test@2.com", "", "2.com")
self.assertTrue(verifier.verify(assertion2))
- self.assertEquals(len(supportdoc_mgr.cache), 1)
+ self.assertEquals(len(supportdocs.cache), 1)
# Check that only the second entry is in cache.
exc = RuntimeError("key fetch disabled")
@@ -23,12 +23,10 @@ class LocalVerifier(Verifier):
"""
def __init__(self, audiences=None, trusted_secondaries=None,
- supportdoc_manager=None, warning=True):
+ supportdocs=None, warning=True):
super(LocalVerifier, self).__init__(audiences)
self.trusted_secondaries = trusted_secondaries
- if supportdoc_manager is None:
- supportdoc_manager = SupportDocumentManager()
- self.supportdoc_manager = supportdoc_manager
+ self.supportdocs = supportdocs or SupportDocumentManager()
if warning:
_emit_warning()
@@ -80,7 +78,7 @@ def verify(self, assertion, audience=None, now=None):
email = certificates[-1].payload["principal"]["email"]
root_issuer = certificates[0].payload["iss"]
provider = email.split('@')[-1]
- if not self.supportdoc_manager.is_trusted_issuer(provider,
+ if not self.supportdocs.is_trusted_issuer(provider,
root_issuer, self.trusted_secondaries):
msg = "untrusted root issuer: %s" % (root_issuer,)
raise InvalidSignatureError(msg)
@@ -119,7 +117,7 @@ def verify_certificate_chain(self, certificates, now=None):
if now is None:
now = int(time.time() * 1000)
root_issuer = certificates[0].payload["iss"]
- root_key = self.supportdoc_manager.get_key(root_issuer)
+ root_key = self.supportdocs.get_key(root_issuer)
current_key = root_key
for cert in certificates:
if cert.payload["exp"] < now:

0 comments on commit 3300749

Please sign in to comment.