Esempio n. 1
0
 def test_rsvp_not_firefox(self, rsvp_mock, gfpe_mock, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides', HTTP_USER_AGENT='Safari')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = 'atoken'
     gfpe_mock.return_value = '*****@*****.**'
     views.oauth_fxa(req)
     rsvp_mock.assert_called_with('*****@*****.**', False)
Esempio n. 2
0
 def test_rsvp_not_firefox(self, rsvp_mock, gfpe_mock, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides', HTTP_USER_AGENT='Safari')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = 'atoken'
     gfpe_mock.return_value = '*****@*****.**'
     views.oauth_fxa(req)
     rsvp_mock.assert_called_with('*****@*****.**', False)
Esempio n. 3
0
 def test_token_failure(self, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = None
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/oauth/fxa/error/'
Esempio n. 4
0
 def test_token_failure(self, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = None
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/oauth/fxa/error/')
Esempio n. 5
0
 def test_email_failure(self, gfpe_mock, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = 'atoken'
     gfpe_mock.return_value = None
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/oauth/fxa/error/')
Esempio n. 6
0
 def test_email_failure(self, gfpe_mock, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = 'atoken'
     gfpe_mock.return_value = None
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/oauth/fxa/error/'
Esempio n. 7
0
 def test_success(self, rsvp_mock, gfpe_mock, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = 'atoken'
     gfpe_mock.return_value = '*****@*****.**'
     response = views.oauth_fxa(req)
     assert response.cookies['fxaOauthVerified'].value == 'True'
     assert response.status_code == 302
     assert response['Location'] == '/firefox/concerts/'
Esempio n. 8
0
 def test_success(self, rsvp_mock, gfpe_mock, gfot_mock):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     gfot_mock.return_value = 'atoken'
     gfpe_mock.return_value = '*****@*****.**'
     response = views.oauth_fxa(req)
     assert response.cookies['fxaOauthVerified'].value == 'True'
     eq_(response.status_code, 302)
     eq_(response['Location'], '/firefox/concerts/')
Esempio n. 9
0
 def test_missing_provided_state(self):
     req = self.rf.get('/mozorg/oauth/fxa?code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/oauth/fxa/error/')
Esempio n. 10
0
 def test_missing_code(self):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude')
     req.COOKIES['fxaOauthState'] = 'thedude'
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/oauth/fxa/error/')
Esempio n. 11
0
 def test_switch_off(self):
     """Should redirect to the home page if the whole system is turned off"""
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/'
Esempio n. 12
0
 def test_missing_expected_state(self):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/oauth/fxa/error/')
Esempio n. 13
0
 def test_state_mismatch(self):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'walter'
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/oauth/fxa/error/')
Esempio n. 14
0
 def test_switch_off(self):
     """Should redirect to the home page if the whole system is turned off"""
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     response = views.oauth_fxa(req)
     eq_(response.status_code, 302)
     eq_(response['Location'], '/')
Esempio n. 15
0
 def test_missing_expected_state(self):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/oauth/fxa/error/'
Esempio n. 16
0
 def test_missing_provided_state(self):
     req = self.rf.get('/mozorg/oauth/fxa?code=abides')
     req.COOKIES['fxaOauthState'] = 'thedude'
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/oauth/fxa/error/'
Esempio n. 17
0
 def test_state_mismatch(self):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude&code=abides')
     req.COOKIES['fxaOauthState'] = 'walter'
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/oauth/fxa/error/'
Esempio n. 18
0
 def test_missing_code(self):
     req = self.rf.get('/mozorg/oauth/fxa?state=thedude')
     req.COOKIES['fxaOauthState'] = 'thedude'
     response = views.oauth_fxa(req)
     assert response.status_code == 302
     assert response['Location'] == '/oauth/fxa/error/'