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


Python HOTP.generate_code_from_time方法代碼示例

本文整理匯總了Python中authenticator.HOTP.generate_code_from_time方法的典型用法代碼示例。如果您正苦於以下問題:Python HOTP.generate_code_from_time方法的具體用法?Python HOTP.generate_code_from_time怎麽用?Python HOTP.generate_code_from_time使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在authenticator.HOTP的用法示例。


在下文中一共展示了HOTP.generate_code_from_time方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_generate_code_from_time_secret_wrong_type

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_secret_wrong_type(self):
        """Test Otp.generate_code_from_time().

        Check for appropriate exception to wrong secret type.

        """
        cut = HOTP()
        with self.assertRaises(TypeError):
            cut.generate_code_from_time(1.234)
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:11,代碼來源:test_hotp.py

示例2: test_generate_code_from_time_period_not_numeric

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_period_not_numeric(self):
        """Test Otp.generate_code_from_time().

        Check for appropriate exception to non-numeric period.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_time(
                self.secret, period="abc")
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:12,代碼來源:test_hotp.py

示例3: test_generate_code_from_time_period_wrong_type

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_period_wrong_type(self):
        """Test Otp.generate_code_from_time().

        Check for appropriate exception to wrong period type.

        """
        cut = HOTP()
        with self.assertRaises(TypeError):
            cut.generate_code_from_time(
                self.secret, period=(6, 3))
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:12,代碼來源:test_hotp.py

示例4: test_generate_code_from_time_secret_wrong_base32_length

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_secret_wrong_base32_length(self):
        """Test Otp.generate_code_from_time().

        Check for appropriate exception to secret string that is invalid
        base32 encoding (too long, bad padding).

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_time(
                "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQAAA")
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:13,代碼來源:test_hotp.py

示例5: test_generate_code_from_time_secret_bad_base32

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_secret_bad_base32(self):
        """Test Otp.generate_code_from_time().

        Check for appropriate exception to secret string that is invalid
        base32 encoding.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_time(
                "GEZDGNBVGY1TQOJQGEZDGNBVGY1TQOJQ")
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:13,代碼來源:test_hotp.py

示例6: test_generate_code_from_time_period_out_of_range

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_period_out_of_range(self):
        """Test Otp.generate_code_from_time().

        Check for appropriate exception to out-of-range period.

        """
        cut = HOTP()
        with self.assertRaises(ValueError):
            cut.generate_code_from_time(
                self.secret, period="0")
        with self.assertRaises(ValueError):
            cut.generate_code_from_time(
                self.secret, period=-1)
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:15,代碼來源:test_hotp.py

示例7: test_generate_code_from_time_b32_secret

# 需要導入模塊: from authenticator import HOTP [as 別名]
# 或者: from authenticator.HOTP import generate_code_from_time [as 別名]
    def test_generate_code_from_time_b32_secret(self):
        """Test Otp.generate_code_from_time().

        Check generate_code_from_time() against a reference implementation
        when passed secret as base32 string.

        """
        cut = HOTP()
        # test with secret as base32 string
        #
        code_string, remaining_seconds = cut.generate_code_from_time(
            self.secret_base32)
        expected_code, expected_seconds = \
            self.reference_generate_code_from_time(self.secret)
        if expected_seconds != remaining_seconds:
            # try again because the clocks were not the same when actual
            # and reference calls were made
            code_string, remaining_seconds = cut.generate_code_from_time(
                self.secret_base32)
            expected_code, expected_seconds = \
                self.reference_generate_code_from_time(self.secret)
        self.assertEqual(expected_seconds, remaining_seconds)
        self.assertEqual(expected_code, code_string)
開發者ID:JeNeSuisPasDave,項目名稱:authenticator,代碼行數:25,代碼來源:test_hotp.py


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