def test_authorize_works_explicit_return_url(self): request = self.factory.get('oauth2/oauth2authorize', data={ 'return_url': '/return_endpoint' }) request.session = self.session response = views.oauth2_authorize(request) self.assertTrue(isinstance(response, http.HttpResponseRedirect))
def test_authorize_works_explicit_return_url(self): request = self.factory.get('oauth2/oauth2authorize', data={'return_url': '/return_endpoint'}) request.session = self.session request.user = self.user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)
def test_authorize_works(self): request = self.factory.get('oauth2/oauth2authorize') request.session = self.session request.user = self.user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect) # redirects to Google oauth self.assertIn('accounts.google.com', response.url)
def test_authorize_anonymous_user_redirects_login(self): request = self.factory.get('oauth2/oauth2authorize') request.session = self.session request.user = django_models.AnonymousUser() response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect) # redirects to Django login self.assertIn(django.conf.settings.LOGIN_URL, response.url)
def test_authorized_user_not_logged_in_redirects(self): request = self.factory.get("oauth2/oauth2authorize", data={"return_url": "/return_endpoint"}) request.session = self.session authorized_user = User.objects.create_user(username="******", email="*****@*****.**", password="******") credentials = CredentialsField() CredentialsModel.objects.create(user_id=authorized_user, credentials=credentials) request.user = authorized_user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)
def test_authorized_user_no_credentials_redirects(self): request = self.factory.get('oauth2/oauth2authorize', data={'return_url': '/return_endpoint'}) request.session = self.session authorized_user = django_models.User.objects.create_user( username='******', email='*****@*****.**', password='******') tests_models.CredentialsModel.objects.create(user_id=authorized_user, credentials=None) request.user = authorized_user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)
def test_authorized_user_no_credentials_redirects(self): request = self.factory.get('oauth2/oauth2authorize', data={'return_url': '/return_endpoint'}) request.session = self.session authorized_user = django_models.User.objects.create_user( username='******', email='*****@*****.**', password='******') tests_models.CredentialsModel.objects.create( user_id=authorized_user, credentials=None) request.user = authorized_user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)
def test_authorize_works(self): request = self.factory.get('oauth2/oauth2authorize') request.session = self.session response = views.oauth2_authorize(request) self.assertTrue(isinstance(response, http.HttpResponseRedirect))
def test_authorize_works(self): request = self.factory.get('oauth2/oauth2authorize') request.session = self.session response = views.oauth2_authorize(request) self.assertTrue(isinstance(response, http.HttpResponseRedirect))
def test_authorize_anonymous_user(self): request = self.factory.get('oauth2/oauth2authorize') request.session = self.session request.user = django_models.AnonymousUser() response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)
def test_authorize_works_explicit_return_url(self): request = self.factory.get("oauth2/oauth2authorize", data={"return_url": "/return_endpoint"}) request.session = self.session request.user = self.user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)
def test_authorize_works(self): request = self.factory.get("oauth2/oauth2authorize") request.session = self.session request.user = self.user response = views.oauth2_authorize(request) self.assertIsInstance(response, http.HttpResponseRedirect)