本文整理汇总了Python中privacyidea.lib.tokens.daplugtoken.DaplugTokenClass类的典型用法代码示例。如果您正苦于以下问题:Python DaplugTokenClass类的具体用法?Python DaplugTokenClass怎么用?Python DaplugTokenClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DaplugTokenClass类的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(DaplugTokenClass.get_hashlib(hl),
'__call__'),
DaplugTokenClass.get_hashlib(hl))
示例2: test_03_reset_failcounter
def test_03_reset_failcounter(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.token.failcount = 10
token.reset()
self.assertTrue(token.token.failcount == 0,
token.token.failcount)
示例3: test_16_init_detail
def test_16_init_detail(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.add_init_details("otpkey", "11223344556677889900")
detail = token.get_init_detail()
self.assertTrue("otpkey" in detail, detail)
# but the otpkey must not be written to token.token.info (DB)
# As this only writes the OTPkey to the internal init_details dict
self.assertTrue("otpkey" not in token.token.get_info(),
token.token.get_info())
# Now get the Google Authenticator URL, which we only
# get, if a user is specified.
detail = token.get_init_detail(user=User("cornelius",
self.realm1))
self.assertTrue("otpkey" in detail, detail)
otpkey = detail.get("otpkey")
self.assertTrue("img" in otpkey, otpkey)
self.assertTrue("googleurl" in detail, detail)
# some other stuff.
r = token.get_QRimage_data({"googleurl": detail.get("googleurl").get(
"value")})
self.assertEqual(r[0],
'otpauth://daplug/SE123456?secret=CERDGRCVMZ3YRGIA'
'&digits=6&issuer=privacyIDEA')
self.assertRaises(Exception, token.set_init_details, "unvalid value")
token.set_init_details({"detail1": "value1"})
self.assertTrue("detail1" in token.get_init_details(),
token.get_init_details())
示例4: test_07_enable
def test_07_enable(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.enable(False)
self.assertTrue(token.token.active is False)
token.enable()
self.assertTrue(token.token.active)
示例5: test_21_get_class_info
def test_21_get_class_info(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
ti = token.get_class_info()
self.assertTrue(ti.get("type") == "daplug", ti)
ti = token.get_class_info("type")
self.assertTrue(ti == "daplug", ti)
示例6: test_99_delete_token
def test_99_delete_token(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.delete_token()
db_token = Token.query.filter_by(serial=self.serial1).first()
self.assertTrue(db_token is None, db_token)
示例7: 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 = DaplugTokenClass(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)
示例8: test_24_challenges
def test_24_challenges(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.update({"otpkey": self.otpkey, "otplen": 6})
token.set_pin("test")
token.token.count = 0
token.set_sync_window(10)
token.set_count_window(5)
self.assertTrue(token.is_challenge_request("test"))
示例9: test_13_check_otp
def test_13_check_otp(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.update({"otpkey": self.otpkey, "pin": "test", "otplen": 6})
# OTP does not exist
self.assertTrue(token.check_otp_exist(_digi2daplug("222333")) == -1)
# OTP does exist
res = token.check_otp_exist(_digi2daplug("969429"))
self.assertTrue(res == 3, res)
示例10: test_01_create_token
def test_01_create_token(self):
db_token = Token(self.serial1, tokentype="daplug")
db_token.save()
token = DaplugTokenClass(db_token)
self.assertTrue(token.token.serial == self.serial1, token)
self.assertTrue(token.token.tokentype == "daplug", token.token.tokentype)
self.assertTrue(token.type == "daplug", token)
class_prefix = token.get_class_prefix()
self.assertTrue(class_prefix == "DPLG", class_prefix)
self.assertTrue(token.get_class_type() == "daplug", token)
示例11: test_20_check_challenge_response
def test_20_check_challenge_response(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
db_token.set_pin("test")
token = DaplugTokenClass(db_token)
r = token.check_challenge_response(user=None, passw=_digi2daplug("123454"))
# check empty challenges
self.assertTrue(r == -1, r)
# create a challenge and match the transaction_id
c = Challenge(self.serial1, transaction_id="mytransaction", challenge="Blah, what now?")
# save challenge to the database
c.save()
r = token.check_challenge_response(user=None, passw=_digi2daplug("123454"), options={"state": "mytransaction"})
# The challenge matches, but the OTP does not match!
self.assertTrue(r == -1, r)
示例12: test_14_split_pin_pass
def test_14_split_pin_pass(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
token.token.otplen = 6
# postpend pin
set_prepend_pin(False)
_res, pin, value = token.split_pin_pass(_digi2daplug("222333")+"test")
self.assertTrue(pin == "test", pin)
self.assertTrue(value == _digi2daplug("222333"), value)
# prepend pin
set_prepend_pin(True)
_res, pin, value = token.split_pin_pass("test"+_digi2daplug("222333"))
self.assertTrue(pin == "test", pin)
self.assertTrue(value == _digi2daplug("222333"), value)
示例13: test_18_challenges
def test_18_challenges(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(db_token)
resp = token.is_challenge_response(User(login="cornelius", realm=self.realm1), "test" + _digi2daplug("123456"))
self.assertFalse(resp, resp)
resp = token.is_challenge_response(
User(login="cornelius", realm=self.realm1),
"test" + _digi2daplug("123456"),
options={"transaction_id": "123456789"},
)
self.assertTrue(resp, resp)
# test if challenge is valid
C = Challenge("S123455", transaction_id="tid", challenge="Who are you?")
C.save()
示例14: test_15_check_pin
def test_15_check_pin(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(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"))
示例15: test_06_set_pin
def test_06_set_pin(self):
db_token = Token.query.filter_by(serial=self.serial1).first()
token = DaplugTokenClass(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)