當前位置: 首頁>>代碼示例>>Python>>正文


Python authentication.Authentication類代碼示例

本文整理匯總了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))
開發者ID:mthornhill,項目名稱:django-tastypie,代碼行數:8,代碼來源:authentication.py

示例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')
開發者ID:mthornhill,項目名稱:django-tastypie,代碼行數:9,代碼來源:authentication.py

示例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))
開發者ID:mattbriancon,項目名稱:django-tastypie,代碼行數:13,代碼來源:authentication.py

示例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))
開發者ID:mthornhill,項目名稱:django-tastypie,代碼行數:6,代碼來源:authentication.py

示例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)
開發者ID:mente,項目名稱:p2psafety,代碼行數:4,代碼來源:authentication.py


注:本文中的tastypie.authentication.Authentication類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。