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


Python SmsTokenClass.create_challenge方法代码示例

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


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

示例1: test_21_failed_loading

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import create_challenge [as 别名]
    def test_21_failed_loading(self):
        transactionid = "123456098712"
        set_privacyidea_config("sms.providerConfig", "noJSON")
        set_privacyidea_config("sms.provider",
                               "privacyidea.lib.smsprovider."
                               "HttpSMSProvider.HttpSMSProviderWRONG")
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)

        c = token.create_challenge(transactionid)
        self.assertFalse(c[0], c)
        self.assertTrue("The PIN was correct, but" in c[1], c[1])

        set_privacyidea_config("sms.provider",
                               "privacyidea.lib.smsprovider."
                               "HttpSMSProvider.HttpSMSProvider")
        c = token.create_challenge(transactionid)
        self.assertFalse(c[0], c)
        self.assertTrue("Failed to load sms.providerConfig" in c[1], c[1])
开发者ID:Reality9,项目名称:privacyidea,代码行数:21,代码来源:test_lib_tokens_sms.py

示例2: test_18_challenge_request

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import create_challenge [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

示例3: test_18b_challenge_request_dynamic_multivalue

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import create_challenge [as 别名]
 def test_18b_challenge_request_dynamic_multivalue(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.serial2).first()
     token = SmsTokenClass(db_token)
     # if the email is a multi-value attribute, the first address should be chosen
     new_user_info = token.user.info.copy()
     new_user_info['mobile'] = ['1234', '5678']
     with mock.patch('privacyidea.lib.resolvers.PasswdIdResolver.IdResolver.getUserInfo') as mock_user_info:
         mock_user_info.return_value = new_user_info
         c = token.create_challenge(transactionid)
         self.assertTrue(c[0], c)
         self.assertIn('destination=1234', responses.calls[0].request.body)
         self.assertNotIn('destination=5678', responses.calls[0].request.body)
开发者ID:hrz-unimr,项目名称:privacyidea,代码行数:19,代码来源:test_lib_tokens_sms.py

示例4: test_19_smstext

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import create_challenge [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

示例5: test_18a_challenge_request_dynamic

# 需要导入模块: from privacyidea.lib.tokens.smstoken import SmsTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.smstoken.SmsTokenClass import create_challenge [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


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