Пример #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)
Пример #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)
Пример #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/'
Пример #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/')
Пример #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/')
Пример #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/'
Пример #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/'
Пример #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/')
Пример #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/')
Пример #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/')
Пример #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'] == '/'
Пример #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/')
Пример #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/')
Пример #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'], '/')
Пример #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/'
Пример #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/'
Пример #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/'
Пример #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/'