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))
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
    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)
Example #7
0
    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))
Example #9
0
 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))
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 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)