本文整理汇总了Python中privacyidea.lib.tokens.daplugtoken.DaplugTokenClass.set_init_details方法的典型用法代码示例。如果您正苦于以下问题:Python DaplugTokenClass.set_init_details方法的具体用法?Python DaplugTokenClass.set_init_details怎么用?Python DaplugTokenClass.set_init_details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类privacyidea.lib.tokens.daplugtoken.DaplugTokenClass
的用法示例。
在下文中一共展示了DaplugTokenClass.set_init_details方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_16_init_detail
# 需要导入模块: from privacyidea.lib.tokens.daplugtoken import DaplugTokenClass [as 别名]
# 或者: from privacyidea.lib.tokens.daplugtoken.DaplugTokenClass import set_init_details [as 别名]
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())