Ejemplo n.º 1
0
 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))
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 6
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)
Ejemplo n.º 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)
Ejemplo n.º 8
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))
Ejemplo n.º 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))
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)