def test_06_export_pskc(self):
     # create three tokens
     t1 = init_token({"serial": "t1", "type": "hotp", "otpkey": "123456",
                      "description": u"söme ünicøde"})
     t2 = init_token({"serial": "t2", "type": "totp", "otpkey": "123456",
                      "description": "something <with> xml!"})
     t3 = init_token({"serial": "t3", "type": "spass", "otpkey": "123456"})
     t4 = init_token({"serial": "t4", "type": "pw", "otpkey": "lässig",
                      "description": "password token"})
     tlist = [t1, t2, t3, t4]
     # export the tokens
     psk, token_num, soup = export_pskc(tlist)
     # Only 3 tokens exported, the spass token does not get exported!
     self.assertEqual(token_num, 3)
     self.assertEqual(len(psk), 32)
     export = "{0!s}".format(soup)
     # remote the tokens
     remove_token("t1")
     remove_token("t2")
     remove_token("t3")
     remove_token("t4")
     # import the tokens again
     tokens, _ = parsePSKCdata(export, preshared_key_hex=psk)
     self.assertEqual(len(tokens), 3)
     self.assertEqual(tokens.get("t1").get("type"), "hotp")
     self.assertEqual(tokens.get("t1").get("otpkey"), "123456")
     # unicode gets replaced
     self.assertEqual(tokens.get("t1").get("description"), "s?me ?nic?de")
     self.assertEqual(tokens.get("t2").get("type"), "totp")
     self.assertEqual(tokens.get("t2").get("timeStep"), "30")
     self.assertEqual(tokens.get("t2").get("description"), "something <with> xml!")
     # password token
     self.assertEqual(tokens.get("t4").get("otpkey"), u"lässig")
Пример #2
0
 def test_06_export_pskc(self):
     # create three tokens
     t1 = init_token({"serial": "t1", "type": "hotp", "otpkey": "123456",
                      "description": u"söme ünicøde"})
     t2 = init_token({"serial": "t2", "type": "totp", "otpkey": "123456",
                      "description": "something <with> xml!"})
     t3 = init_token({"serial": "t3", "type": "spass", "otpkey": "123456"})
     tlist = [t1, t2, t3]
     # export the tokens
     psk, token_num, soup = export_pskc(tlist)
     # Only 2 tokens exported, the spass token does not get exported!
     self.assertEqual(token_num, 2)
     self.assertEqual(len(psk), 32)
     export = "{0!s}".format(soup)
     # remote the tokens
     remove_token("t1")
     remove_token("t2")
     remove_token("t3")
     # import the tokens again
     tokens = parsePSKCdata(export, preshared_key_hex=psk)
     self.assertEqual(len(tokens), 2)
     self.assertEqual(tokens.get("t1").get("type"), "hotp")
     self.assertEqual(tokens.get("t1").get("otpkey"), "123456")
     # unicode does not get exported
     self.assertEqual(tokens.get("t1").get("description"), "deleted during export")
     self.assertEqual(tokens.get("t2").get("type"), "totp")
     self.assertEqual(tokens.get("t2").get("timeStep"), "30")
     self.assertEqual(tokens.get("t2").get("description"), "something <with> xml!")
Пример #3
0
 def test_06_export_pskc(self):
     # create three tokens
     t1 = init_token({"serial": "t1", "type": "hotp", "otpkey": "123456"})
     t2 = init_token({"serial": "t2", "type": "totp", "otpkey": "123456"})
     t3 = init_token({"serial": "t3", "type": "spass", "otpkey": "123456"})
     tlist = [t1, t2, t3]
     # export the tokens
     psk, soup = export_pskc(tlist)
     self.assertEqual(len(psk), 32)
     export = "{0!s}".format(soup)
     # remote the tokens
     remove_token("t1")
     remove_token("t2")
     remove_token("t3")
     # import the tokens again
     tokens = parsePSKCdata(export, preshared_key_hex=psk)
     self.assertEqual(len(tokens), 2)
     self.assertEqual(tokens.get("t1").get("type"), "hotp")
     self.assertEqual(tokens.get("t1").get("otpkey"), "123456")
     self.assertEqual(tokens.get("t2").get("type"), "totp")
     self.assertEqual(tokens.get("t2").get("timeStep"), "30")