def test_change_length(self): s = PasswordSetting("unit.test") s.set_full_template("1;xxxaxxxxxxx") self.assertEqual(11, s.get_length()) s.set_length(16) self.assertEqual(16, s.get_length()) self.assertEqual(16, len(s.get_template()))
def test_to_json(self): s = PasswordSetting("unit.test") s.set_modification_date("2005-01-01T01:14:12") s.set_creation_date("2001-01-01T02:14:12") s.set_salt("something".encode('utf-8')) s.set_iterations(213) s.set_length(14) s.set_custom_character_set("XVLCWKHGFQUIAEOSNRTDYÜÖÄPZBMJ") s.set_notes("Some note.") self.assertIn("domain", s.to_dict()) self.assertEqual("unit.test", s.to_dict()["domain"]) self.assertIn("cDate", s.to_dict()) self.assertEqual("2001-01-01T02:14:12", s.to_dict()["cDate"]) self.assertIn("mDate", s.to_dict()) self.assertEqual("2005-01-01T01:14:12", s.to_dict()["mDate"]) self.assertIn("salt", s.to_dict()) self.assertEqual(str(b64encode("something".encode('utf-8')), encoding='utf-8'), s.to_dict()["salt"]) self.assertIn("iterations", s.to_dict()) self.assertEqual(213, s.to_dict()["iterations"]) self.assertIn("length", s.to_dict()) self.assertEqual(14, s.to_dict()["length"]) self.assertIn("usedCharacters", s.to_dict()) self.assertEqual("XVLCWKHGFQUIAEOSNRTDYÜÖÄPZBMJ", s.to_dict()["usedCharacters"]) self.assertIn("notes", s.to_dict()) self.assertEqual("Some note.", s.to_dict()["notes"])
def test_long(self): setting = PasswordSetting('some.domain') setting.set_salt('pepper'.encode('utf-8')) setting.set_length(32) manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk='foo'.encode('utf-8')) self.assertEqual("]#]Y6Q-+)TCus§&8[kEw5O.pJsTjOC#}", manager.generate(setting))