当前位置: 首页>>代码示例>>Python>>正文


Python SmsTokenClass.check_otp方法代码示例

本文整理汇总了Python中privacyidea.lib.tokens.smstoken.SmsTokenClass.check_otp方法的典型用法代码示例。如果您正苦于以下问题:Python SmsTokenClass.check_otp方法的具体用法?Python SmsTokenClass.check_otp怎么用?Python SmsTokenClass.check_otp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在privacyidea.lib.tokens.smstoken.SmsTokenClass的用法示例。


在下文中一共展示了SmsTokenClass.check_otp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_18_challenge_request

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import check_otp [as 别名]
    def test_18_challenge_request(self):
        responses.add(responses.POST,
                      self.SMSHttpUrl,
                      body=self.success_body)
        transactionid = "123456098712"
        set_privacyidea_config("sms.providerConfig", self.SMSProviderConfig)
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        self.assertTrue(token.check_otp("123456", 1, 10) == -1)
        c = token.create_challenge(transactionid)
        self.assertTrue(c[0], c)
        otp = c[1]
        self.assertTrue(c[3].get("state"), transactionid)

        # check for the challenges response
        r = token.check_challenge_response(passw=otp)
        self.assertTrue(r, r)
开发者ID:Reality9,项目名称:privacyidea,代码行数:19,代码来源:test_lib_tokens_sms.py

示例2: test_19_smstext

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import check_otp [as 别名]
    def test_19_smstext(self):
        # create a SMSTEXT policy:
        p = set_policy(name="smstext",
                       action="{0!s}={1!s}".format(SMSACTION.SMSTEXT, "'Your <otp>'"),
                       scope=SCOPE.AUTH)
        self.assertTrue(p > 0)

        g = FakeFlaskG()
        P = PolicyClass()
        g.audit_object = FakeAudit()
        g.policy_object = P
        options = {"g": g}

        responses.add(responses.POST,
                      self.SMSHttpUrl,
                      body=self.success_body)
        set_privacyidea_config("sms.providerConfig", self.SMSProviderConfig)
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        c = token.create_challenge(options=options)
        self.assertTrue(c[0], c)
        display_message = c[1]
        self.assertEqual(display_message, _("Enter the OTP from the SMS:"))
        self.assertEqual(c[3].get("state"), None)

        # check for the challenges response
        # r = token.check_challenge_response(passw="287922")
        # self.assertTrue(r, r)

        # Test AUTOSMS
        p = set_policy(name="autosms",
                       action=SMSACTION.SMSAUTO,
                       scope=SCOPE.AUTH)
        self.assertTrue(p > 0)

        g = FakeFlaskG()
        P = PolicyClass()
        g.policy_object = P
        g.audit_object = FakeAudit()
        options = {"g": g}

        r = token.check_otp("287922", options=options)
        self.assertTrue(r > 0, r)
开发者ID:salvorapi,项目名称:privacyidea,代码行数:45,代码来源:test_lib_tokens_sms.py

示例3: test_18a_challenge_request_dynamic

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import check_otp [as 别名]
    def test_18a_challenge_request_dynamic(self):
        # Send a challenge request for an SMS token with a dynamic phone number
        responses.add(responses.POST,
                      self.SMSHttpUrl,
                      body=self.success_body)
        transactionid = "123456098712"
        set_privacyidea_config("sms.providerConfig", self.SMSProviderConfig)
        db_token = Token.query.filter_by(serial=self.serial2).first()
        token = SmsTokenClass(db_token)
        self.assertTrue(token.check_otp("123456", 1, 10) == -1)
        c = token.create_challenge(transactionid)
        self.assertTrue(c[0], c)
        otp = c[1]
        self.assertTrue(c[3].get("state"), transactionid)

        # check for the challenges response
        r = token.check_challenge_response(passw=otp,
                                           options={"transaction_id":
                                                        transactionid})
        self.assertTrue(r, r)
开发者ID:hrz-unimr,项目名称:privacyidea,代码行数:22,代码来源:test_lib_tokens_sms.py

示例4: test_04_base_methods

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import check_otp [as 别名]
    def test_04_base_methods(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        self.assertTrue(token.check_otp("123456", 1, 10) == -1)

        # get class info
        cli = token.get_class_info()
        self.assertTrue(cli.get("type") == "sms", cli.get("type"))
        cli = token.get_class_info("type")
        self.assertTrue(cli == "sms", cli)

        # set the description
        token.set_description("something new")
        self.assertTrue(token.token.description == "something new",
                        token.token)

        # set defaults
        token.set_defaults()
        self.assertTrue(token.token.otplen == 6)
        self.assertTrue(token.token.sync_window == 1000)

        token.resync("1234", "3456")

        token.token.count_window = 17
        self.assertTrue(token.get_otp_count_window() == 17)

        token.token.count = 18
        self.assertTrue(token.get_otp_count() == 18)

        token.token.active = False
        self.assertTrue(token.is_active() is False)

        token.token.failcount = 7
        self.assertTrue(token.get_failcount() == 7)
        token.set_failcount(8)
        self.assertTrue(token.token.failcount == 8)

        token.token.maxfail = 12
        self.assertTrue(token.get_max_failcount() == 12)

        self.assertTrue(token.get_user_id() == token.token.user_id)

        self.assertTrue(token.get_serial() == "SE123456", token.token.serial)
        self.assertTrue(token.get_tokentype() == "sms",
                        token.token.tokentype)

        token.set_so_pin("sopin")
        token.set_user_pin("userpin")
        token.set_otpkey(self.otpkey)
        token.set_otplen(8)
        token.set_otp_count(1000)
        self.assertTrue(len(token.token.so_pin) == 32,
                        token.token.so_pin)
        self.assertTrue(len(token.token.user_pin) == 32,
                        token.token.user_pin)
        self.assertTrue(len(token.token.key_enc) == 192,
                        token.token.key_enc)
        self.assertTrue(token.get_otplen() == 8)
        self.assertTrue(token.token.count == 1000,
                        token.token.count)

        token.set_maxfail(1000)
        self.assertTrue(token.token.maxfail == 1000)

        token.set_count_window(52)
        self.assertTrue(token.get_count_window() == 52)

        token.set_sync_window(53)
        self.assertTrue(token.get_sync_window() == 53)
开发者ID:Reality9,项目名称:privacyidea,代码行数:71,代码来源:test_lib_tokens_sms.py


注:本文中的privacyidea.lib.tokens.smstoken.SmsTokenClass.check_otp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。