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


Python smstoken.SmsTokenClass类代码示例

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


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

示例1: test_10_get_hashlib

 def test_10_get_hashlib(self):
     # check if functions are returned
     for hl in ["sha1", "md5", "sha256", "sha512",
                "sha224", "sha384", "", None]:
         self.assertTrue(hasattr(SmsTokenClass.get_hashlib(hl),
                                 '__call__'),
                         SmsTokenClass.get_hashlib(hl))
开发者ID:Reality9,项目名称:privacyidea,代码行数:7,代码来源:test_lib_tokens_sms.py

示例2: test_03_reset_failcounter

 def test_03_reset_failcounter(self):
     db_token = Token.query.filter_by(serial=self.serial1).first()
     token = SmsTokenClass(db_token)
     token.token.failcount = 10
     token.reset()
     self.assertTrue(token.token.failcount == 0,
                     token.token.failcount)
开发者ID:Reality9,项目名称:privacyidea,代码行数:7,代码来源:test_lib_tokens_sms.py

示例3: test_99_delete_token

    def test_99_delete_token(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        token.delete_token()

        db_token = Token.query.filter_by(serial=self.serial1).first()
        self.assertTrue(db_token is None, db_token)
开发者ID:Reality9,项目名称:privacyidea,代码行数:7,代码来源:test_lib_tokens_sms.py

示例4: test_07_enable

 def test_07_enable(self):
     db_token = Token.query.filter_by(serial=self.serial1).first()
     token = SmsTokenClass(db_token)
     token.enable(False)
     self.assertTrue(token.token.active is False)
     token.enable()
     self.assertTrue(token.token.active)
开发者ID:Reality9,项目名称:privacyidea,代码行数:7,代码来源:test_lib_tokens_sms.py

示例5: test_17_challenge_token

    def test_17_challenge_token(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        token.set_pin(self.otppin)

        r = token.is_challenge_request(self.otppin)
        self.assertTrue(r)
开发者ID:Reality9,项目名称:privacyidea,代码行数:7,代码来源:test_lib_tokens_sms.py

示例6: test_05_get_set_realms

 def test_05_get_set_realms(self):
     set_realm(self.realm2)
     db_token = Token.query.filter_by(serial=self.serial1).first()
     token = SmsTokenClass(db_token)
     realms = token.get_realms()
     self.assertTrue(len(realms) == 1, realms)
     token.set_realms([self.realm1, self.realm2])
     realms = token.get_realms()
     self.assertTrue(len(realms) == 2, realms)
开发者ID:Reality9,项目名称:privacyidea,代码行数:9,代码来源:test_lib_tokens_sms.py

示例7: test_13_check_otp

 def test_13_check_otp(self):
     db_token = Token.query.filter_by(serial=self.serial1).first()
     token = SmsTokenClass(db_token)
     token.update({"otpkey": self.otpkey,
                   "pin": "test",
                   "otplen": 6,
                   "phone": self.phone1})
     # OTP does not exist
     self.assertTrue(token.check_otp_exist("222333") == -1)
     # OTP does exist
     res = token.check_otp_exist("969429")
     self.assertTrue(res == 3, res)
开发者ID:Reality9,项目名称:privacyidea,代码行数:12,代码来源:test_lib_tokens_sms.py

示例8: test_14_split_pin_pass

    def test_14_split_pin_pass(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)

        token.token.otplen = 6
        # postpend pin
        set_prepend_pin(False)
        _res, pin, value = token.split_pin_pass("222333test")
        self.assertTrue(pin == "test", pin)
        self.assertTrue(value == "222333", value)
        # prepend pin
        set_prepend_pin(True)
        _res, pin, value = token.split_pin_pass("test222333")
        self.assertTrue(pin == "test", pin)
        self.assertTrue(value == "222333", value)
开发者ID:Reality9,项目名称:privacyidea,代码行数:15,代码来源:test_lib_tokens_sms.py

示例9: test_15_check_pin

    def test_15_check_pin(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        # test the encrypted pin
        token.set_pin("encrypted", encrypt=True)
        self.assertTrue(token.check_pin("encrypted"))
        self.assertFalse(token.check_pin("wrong pin"))

        # test the hashed pin
        token.set_pin("test")
        self.assertTrue(token.check_pin("test"))
        self.assertFalse(token.check_pin("wrong pin"))
开发者ID:Reality9,项目名称:privacyidea,代码行数:12,代码来源:test_lib_tokens_sms.py

示例10: test_18_challenge_request

    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,代码行数:17,代码来源:test_lib_tokens_sms.py

示例11: test_18b_challenge_request_dynamic_multivalue

 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,代码行数:17,代码来源:test_lib_tokens_sms.py

示例12: test_02_set_user

    def test_02_set_user(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = SmsTokenClass(db_token)
        self.assertTrue(token.token.tokentype == "sms",
                        token.token.tokentype)
        self.assertTrue(token.type == "sms", token.type)

        token.add_user(User(login="cornelius",
                            realm=self.realm1))
        self.assertEqual(token.token.owners.first().resolver, self.resolvername1)
        self.assertEqual(token.token.owners.first().user_id, "1000")

        user_object = token.user
        self.assertTrue(user_object.login == "cornelius",
                        user_object)
        self.assertTrue(user_object.resolver == self.resolvername1,
                        user_object)
开发者ID:privacyidea,项目名称:privacyidea,代码行数:17,代码来源:test_lib_tokens_sms.py

示例13: test_06_set_pin

 def test_06_set_pin(self):
     db_token = Token.query.filter_by(serial=self.serial1).first()
     token = SmsTokenClass(db_token)
     token.set_pin("hallo")
     (ph1, pseed) = token.get_pin_hash_seed()
     # check the database
     token.set_pin("blubber")
     ph2 = token.token.pin_hash
     self.assertTrue(ph1 != ph2)
     token.set_pin_hash_seed(ph1, pseed)
开发者ID:Reality9,项目名称:privacyidea,代码行数:10,代码来源:test_lib_tokens_sms.py

示例14: test_19_smstext

    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,代码行数:43,代码来源:test_lib_tokens_sms.py

示例15: test_21_failed_loading

    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,代码行数:19,代码来源:test_lib_tokens_sms.py


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