Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Remove warning about possible changes to assertion format.
Browse files Browse the repository at this point in the history
Since the project was shut down, the format is pretty obviously
not going to change, so the warning is just noise.
  • Loading branch information
rfk committed Jan 11, 2018
1 parent 33cb61e commit ff63a4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
27 changes: 12 additions & 15 deletions browserid/tests/test_verifiers.py
Expand Up @@ -123,8 +123,8 @@ def setUp(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
self.verifier = LocalVerifier(["*"])
# There should be a warning about using this verifier.
self.assertEquals(w[0].category, FutureWarning)
# There should be no warning about using this verifier.
self.assertEquals(len(w), 0)

@callwith(patched_supportdoc_fetching())
def test_error_handling_in_verify_certificate_chain(self):
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_extraction_of_extra_claims_from_principal(self):

@callwith(patched_supportdoc_fetching())
def test_email_validation(self):
verifier = LocalVerifier(warning=False, audiences="http://persona.org")
verifier = LocalVerifier(audiences="http://persona.org")

# Null bytes in the email hostname.
assertion = make_assertion("test@users.example\x00.com",
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_audience_verification(self):
assertion = make_assertion("alexis@mozilla.com", "http://persona.org")

# we don't set any audience explicitely here
verifier = LocalVerifier(warning=False)
verifier = LocalVerifier()

# specifying the audience on verifier.verify uses it.
self.assertRaises(AudienceMismatchError, verifier.verify, assertion,
Expand All @@ -228,7 +228,7 @@ def test_audience_verification(self):

# specifying the audience when creating the verifier AND when calling
# verifier.verify.
verifier = LocalVerifier(["*.example.com"], warning=False)
verifier = LocalVerifier(["*.example.com"])
self.assertRaises(AudienceMismatchError, verifier.verify, assertion,
audience="*.example.com")

Expand All @@ -245,7 +245,7 @@ def test_audience_verification(self):

# the assertion is valid for http://persona.org; the verifier is
# configured to accept this audience so it should validate
verifier = LocalVerifier(["persona.org"], warning=False)
verifier = LocalVerifier(["persona.org"])
self.assertTrue(verifier.verify(assertion))

# but if we ask explicitely for a different audience (the assertion is
Expand Down Expand Up @@ -313,7 +313,7 @@ class TestDummyVerifier(unittest.TestCase, VerifierTestCases):
def setUp(self):
self.patched = patched_supportdoc_fetching()
self.patched.__enter__()
self.verifier = LocalVerifier(["*"], warning=False)
self.verifier = LocalVerifier(["*"])

def tearDown(self):
self.patched.__exit__(None, None, None)
Expand Down Expand Up @@ -371,8 +371,7 @@ def test_verification_of_dummy_assertion_with_bad_certificate_sig(self):

def test_cache_eviction_based_on_time(self):
supportdocs = SupportDocumentManager(FIFOCache(cache_timeout=0.1))
verifier = LocalVerifier(["*"], supportdocs=supportdocs,
warning=False)
verifier = LocalVerifier(["*"], supportdocs=supportdocs)
# Prime the cache by verifying an assertion.
assertion = make_assertion("test@example.com", "")
self.assertTrue(verifier.verify(assertion))
Expand All @@ -388,8 +387,7 @@ def test_cache_eviction_based_on_time(self):

def test_cache_eviction_based_on_size(self):
supportdocs = SupportDocumentManager(max_size=2)
verifier = LocalVerifier(["*"], supportdocs=supportdocs,
warning=False)
verifier = LocalVerifier(["*"], supportdocs=supportdocs)
# Prime the cache by verifying some assertions.
assertion1 = make_assertion("test@1.com", "", "1.com")
self.assertTrue(verifier.verify(assertion1))
Expand All @@ -410,8 +408,7 @@ def test_cache_eviction_based_on_size(self):

def test_cache_eviction_during_write(self):
supportdocs = SupportDocumentManager(cache_timeout=0.1)
verifier = LocalVerifier(["*"], supportdocs=supportdocs,
warning=False)
verifier = LocalVerifier(["*"], supportdocs=supportdocs)
# Prime the cache by verifying an assertion.
assertion1 = make_assertion("test@1.com", "", "1.com")
self.assertTrue(verifier.verify(assertion1))
Expand All @@ -430,7 +427,7 @@ def test_cache_eviction_during_write(self):
self.assertRaises(RuntimeError, verifier.verify, assertion1)

def test_audience_pattern_checking(self):
verifier = LocalVerifier(["*.moz.com", "www.test.com"], warning=False)
verifier = LocalVerifier(["*.moz.com", "www.test.com"])
# Domains like *.moz.com should be valid audiences.
# They will work with both the implicit patterns and explicit audience.
assertion = make_assertion("test@example.com", "www.moz.com")
Expand Down Expand Up @@ -459,7 +456,7 @@ class TestWorkerPoolVerifier(TestDummyVerifier):
def setUp(self):
super(TestWorkerPoolVerifier, self).setUp()
self.verifier = WorkerPoolVerifier(
verifier=LocalVerifier(["*"], warning=False)
verifier=LocalVerifier(["*"])
)

def tearDown(self):
Expand Down
17 changes: 5 additions & 12 deletions browserid/verifiers/local.py
Expand Up @@ -5,7 +5,6 @@
import re
import sys
import time
import warnings

from browserid import jwt
from browserid.verifiers import Verifier
Expand Down Expand Up @@ -45,13 +44,16 @@ class LocalVerifier(Verifier):
"""

def __init__(self, audiences=None, trusted_secondaries=None,
supportdocs=None, warning=True):
supportdocs=None, warning=False):
super(LocalVerifier, self).__init__(audiences)
self.trusted_secondaries = trusted_secondaries
self.supportdocs = supportdocs or SupportDocumentManager()

if warning:
_emit_warning()
# We used to emit a warning about the assertion format
# being subject to change. That's no longer true, but
# we still accept the `warning` arg for compatibility.
pass

def parse_jwt(self, data):
return jwt.parse(data)
Expand Down Expand Up @@ -167,15 +169,6 @@ def verify_certificate_chain(self, certificates, now=None):
return cert


def _emit_warning():
"""Emit a scary warning so users will know this isn't final yet."""
msg = "The BrowserID certificate format has not been finalized and may "\
"change in backwards-incompatible ways. If you find that "\
"the latest version of this module cannot verify a valid "\
"BrowserID assertion, please contact the author."
warnings.warn(msg, FutureWarning, stacklevel=3)


def extract_extra_claims(jwt):
"""Return a dict of any non-standard claims in the given JWT."""
claims = {}
Expand Down

0 comments on commit ff63a4b

Please sign in to comment.