def test_post_anonymous(self, verify_post_mock):
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = False
     Verify.request = request_mock
     Verify.post()
     verify_post_mock.assert_called_with()
Esempio n. 2
0
 def test_post_anonymous(self, verify_post_mock):
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = False
     Verify.request = request_mock
     Verify.post()
     verify_post_mock.assert_called_with()
Esempio n. 3
0
 def test_post_authenticated(self, verify_mock, get_audience_mock):
     user = UserFactory.create()
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = True
     request_mock.user = user
     request_mock.POST = {'assertion': 'assertion'}
     Verify.request = request_mock
     get_audience_mock.return_value = 'audience'
     verify_mock.return_value = Mock(email='*****@*****.**')
     Verify.post()
     verify_mock.assert_called_with('assertion', 'audience')
     get_audience_mock.assert_called_with(request_mock)
     eq_(user.email, '*****@*****.**')
 def test_post_valid_email_exists(self, verify_mock, get_audience_mock,
                                  login_failure_mock):
     UserFactory.create(email='*****@*****.**')
     user = UserFactory.create(email='*****@*****.**')
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = True
     request_mock.user = user
     request_mock.POST = {'assertion': 'assertion'}
     Verify.request = request_mock
     verify_mock.return_value = Mock(email='*****@*****.**')
     get_audience_mock.return_value = 'audience'
     Verify.post()
     verify_mock.assert_called_with('assertion', 'audience')
     get_audience_mock.assert_called_with(request_mock)
     login_failure_mock.assert_called_with()
     ok_(Verify.add_email)
 def test_post_authenticated(self, verify_mock, get_audience_mock):
     user = UserFactory.create()
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = True
     request_mock.user = user
     request_mock.POST = {'assertion': 'assertion'}
     Verify.request = request_mock
     get_audience_mock.return_value = 'audience'
     verify_mock.return_value = Mock(email='*****@*****.**')
     Verify.post()
     verify_mock.assert_called_with('assertion', 'audience')
     get_audience_mock.assert_called_with(request_mock)
     emails = ExternalAccount.objects.filter(type=ExternalAccount.TYPE_EMAIL,
                                             identifier='*****@*****.**',
                                             user=user.userprofile)
     ok_(emails.exists())
Esempio n. 6
0
 def test_post_valid_email_exists(self, verify_mock, get_audience_mock,
                                  login_failure_mock):
     UserFactory.create(email='*****@*****.**')
     user = UserFactory.create(email='*****@*****.**')
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = True
     request_mock.user = user
     request_mock.POST = {'assertion': 'assertion'}
     Verify.request = request_mock
     verify_mock.return_value = Mock(email='*****@*****.**')
     get_audience_mock.return_value = 'audience'
     Verify.post()
     verify_mock.assert_called_with('assertion', 'audience')
     get_audience_mock.assert_called_with(request_mock)
     login_failure_mock.assert_called_with()
     ok_(Verify.change_email)
Esempio n. 7
0
 def test_post_authenticated(self, verify_mock, get_audience_mock):
     user = UserFactory.create()
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = True
     request_mock.user = user
     request_mock.POST = {'assertion': 'assertion'}
     Verify.request = request_mock
     get_audience_mock.return_value = 'audience'
     verify_mock.return_value = Mock(email='*****@*****.**')
     Verify.post()
     verify_mock.assert_called_with('assertion', 'audience')
     get_audience_mock.assert_called_with(request_mock)
     emails = ExternalAccount.objects.filter(
         type=ExternalAccount.TYPE_EMAIL,
         identifier='*****@*****.**',
         user=user.userprofile)
     ok_(emails.exists())