本文整理汇总了Python中oauth2client.contrib.django_util.views.oauth2_authorize方法的典型用法代码示例。如果您正苦于以下问题:Python views.oauth2_authorize方法的具体用法?Python views.oauth2_authorize怎么用?Python views.oauth2_authorize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauth2client.contrib.django_util.views
的用法示例。
在下文中一共展示了views.oauth2_authorize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_already_authorized
# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_already_authorized(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='bill2', email='[email protected]', password='hunter2')
credentials = _Credentials()
tests_models.CredentialsModel.objects.create(
user_id=authorized_user,
credentials=credentials)
request.user = authorized_user
response = views.oauth2_authorize(request)
self.assertIsInstance(response, http.HttpResponseRedirect)
self.assertEqual(response.url, '/return_endpoint')
示例2: test_authorize_works
# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
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)
示例3: test_authorize_anonymous_user
# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
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)
示例4: test_authorize_works_explicit_return_url
# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
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)
示例5: test_authorize_anonymous_user_redirects_login
# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
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)
示例6: test_authorized_user_no_credentials_redirects
# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
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='bill2', email='[email protected]', password='hunter2')
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)