本文整理匯總了Python中tastypie.authentication.Authentication類的典型用法代碼示例。如果您正苦於以下問題:Python Authentication類的具體用法?Python Authentication怎麽用?Python Authentication使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Authentication類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_check_active_false
def test_check_active_false(self):
auth = Authentication(require_active=False)
user = User.objects.get(username='johndoe')
self.assertTrue(auth.check_active(user))
auth = Authentication(require_active=False)
user = User.objects.get(username='bobdoe')
self.assertTrue(auth.check_active(user))
示例2: test_get_identifier
def test_get_identifier(self):
auth = Authentication()
request = HttpRequest()
self.assertEqual(auth.get_identifier(request), 'noaddr_nohost')
request = HttpRequest()
request.META['REMOTE_ADDR'] = '127.0.0.1'
request.META['REMOTE_HOST'] = 'nebula.local'
self.assertEqual(auth.get_identifier(request), '127.0.0.1_nebula.local')
示例3: test_check_active_true
def test_check_active_true(self):
auth = Authentication(require_active=True)
user = User.objects.get(username="johndoe")
self.assertTrue(auth.check_active(user))
auth = Authentication(require_active=True)
user = User.objects.get(username="bobdoe")
self.assertFalse(auth.check_active(user))
# Check the default.
auth = Authentication()
user = User.objects.get(username="bobdoe")
self.assertFalse(auth.check_active(user))
示例4: test_is_authenticated
def test_is_authenticated(self):
auth = Authentication()
request = HttpRequest()
# Doesn't matter. Always true.
self.assertTrue(auth.is_authenticated(None))
self.assertTrue(auth.is_authenticated(request))
示例5: get_identifier
def get_identifier(self, request):
if request.method == 'POST':
return Authentication.get_identifier(self, request)
return super(PostFreeSessionAuthentication, self).get_identifier(request)