def test_no_code_provided(self): response = self.client.get(self.url) assert response.status_code == 302 # Messages seem to appear in the context for some reason. assert 'could not be parsed' in response.context['title'] assert_url_equal(response['location'], self.login_url()) assert not self.login_user.called assert not self.register_user.called
def test_wrong_state(self): response = self.client.get( self.url, {'code': 'foo', 'state': '9f865be0'}) assert response.status_code == 302 assert 'could not be logged in' in response.context['title'] assert_url_equal(response['location'], self.login_url()) assert not self.login_user.called assert not self.register_user.called
def test_error_no_profile_with_no_path(self): request = self.make_request() assert len(get_messages(request)) == 0 response = self.render_error(request, views.ERROR_NO_PROFILE) assert response.status_code == 302 messages = get_messages(request) assert len(messages) == 1 assert ('Firefox Account could not be found' in next(iter(messages)).message) assert_url_equal(response['location'], self.login_url())
def test_error_no_code_with_safe_path(self): request = self.make_request() assert len(get_messages(request)) == 0 response = self.render_error( request, views.ERROR_NO_CODE, next_path='/over/here') assert response.status_code == 302 messages = get_messages(request) assert len(messages) == 1 assert 'could not be parsed' in next(iter(messages)).message assert_url_equal(response['location'], self.login_url(to='/over/here'))
def test_error_state_mismatch_with_unsafe_path(self): request = self.make_request() assert len(get_messages(request)) == 0 response = self.render_error(request, views.ERROR_STATE_MISMATCH, next_path='https://www.google.com/') assert response.status_code == 302 messages = get_messages(request) assert len(messages) == 1 assert 'could not be logged in' in next(iter(messages)).message assert_url_equal(response['location'], self.login_url())
def test_no_fxa_profile(self): self.fxa_identify.side_effect = verify.IdentificationError response = self.client.get( self.url, {'code': 'codes!!', 'state': self.fxa_state}) assert response.status_code == 302 assert ('Your Firefox Account could not be found' in response.context['title']) assert_url_equal(response['location'], self.login_url()) self.fxa_identify.assert_called_with('codes!!', config=FXA_CONFIG) assert not self.login_user.called assert not self.register_user.called
def test_error_state_mismatch_with_unsafe_path(self): request = self.make_request() assert len(get_messages(request)) == 0 response = self.render_error( request, views.ERROR_STATE_MISMATCH, next_path='https://www.google.com/') assert response.status_code == 302 messages = get_messages(request) assert len(messages) == 1 assert 'could not be logged in' in next(iter(messages)).message assert_url_equal(response['location'], self.login_url())