def test_verify_email(self): # If an email is given to the constructor, return a successful result. verifier = MockVerifier('*****@*****.**') result = verifier.verify('asdf', 'http://testserver') ok_(result) eq_(result.audience, 'http://testserver') eq_(result.email, '*****@*****.**')
def test_verify_called_with_extra_kwargs(self): backend = BrowserIDBackend() verifier = MockVerifier('*****@*****.**') verifier.verify = Mock(wraps=verifier.verify) backend.get_verifier = lambda: verifier backend.authenticate(assertion='asdf', audience='http://testserver', foo='bar') verifier.verify.assert_called_with('asdf', 'http://testserver', foo='bar')
def __init__(self, email, **kwargs): """ :param email: Email to return in the verification result. If None, the verification will fail. :param kwargs: Keyword arguments are passed on to :class:`django_browserid.base.MockVerifier`, which updates the verification result with them. """ self.patcher = patch.object(BrowserIDBackend, 'get_verifier') self.return_value = MockVerifier(email, **kwargs)
def __init__(self, email, **kwargs): """ :param email: Email to return in the verification result. If None, the verification will fail. :param kwargs: Keyword arguments are passed on to :class:`django_browserid.base.MockVerifier`, which updates the verification result with them. """ # Need to import these here so that we can import # django_browserid.tests.settings to build the docs. from django_browserid.auth import BrowserIDBackend from django_browserid.base import MockVerifier self.patcher = patch.object(BrowserIDBackend, 'get_verifier') self.return_value = MockVerifier(email, **kwargs)
def test_verify_result_attributes(self): # Extra kwargs to the constructor are added to the result. verifier = MockVerifier('*****@*****.**', foo='bar', baz=5) result = verifier.verify('asdf', 'http://testserver') eq_(result.foo, 'bar') eq_(result.baz, 5)
def test_verify_no_email(self): # If the given email is None, verify should return a failure result. verifier = MockVerifier(None) result = verifier.verify('asdf', 'http://testserver') ok_(not result) eq_(result.reason, 'No email given to MockVerifier.')
def get_verifier(self): return MockVerifier(self.__fake_email)