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)
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)
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/'
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/')
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/')
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/'
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/'
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/')
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/')
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/')
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'] == '/'
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/')
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/')
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'], '/')
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/'
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/'
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/'
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/'