def test_character_set(self):
     s = PasswordSetting("unit.test")
     self.assertFalse(s.use_custom_character_set())
     self.assertEqual("abcdefghijklmnopqrstuvwxyz" +
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                      "0123456789" +
                      "#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_custom_character_set("&=Oo0wWsS$#uUvVzZ")
     self.assertTrue(s.use_custom_character_set())
     self.assertEqual("&=Oo0wWsS$#uUvVzZ", s.get_character_set())
     s.set_custom_character_set(
         "abcdefghijklmnopqrstuvwxyz" +
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
         "0123456789" +
         "#!\"§$%&/()[]{}=-_+*<>;:.")
     self.assertFalse(s.use_custom_character_set())
     self.assertEqual("abcdefghijklmnopqrstuvwxyz" +
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                      "0123456789" +
                      "#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_use_letters(False)
     self.assertEqual("0123456789#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_use_letters(True)
     s.set_use_digits(False)
     s.set_use_extra(False)
     self.assertEqual("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", s.get_character_set())
 def test_get_character_set(self):
     s = PasswordSetting("unit.test")
     self.assertEqual("c", s.get_character_set()[2])
     s.set_custom_character_set("axFLp0")
     self.assertEqual(6, len(s.get_character_set()))
     self.assertEqual("F", s.get_character_set()[2])
     self.assertEqual("0", s.get_character_set()[5])
 def test_get_character_set(self):
     s = PasswordSetting("unit.test")
     self.assertEqual("c", s.get_character_set()[12])
     s.set_extra_character_set("axFLp0")
     s.set_template("xox")
     self.assertEqual(6, len(s.get_character_set()))
     self.assertEqual("F", s.get_character_set()[2])
     self.assertEqual("0", s.get_character_set()[5])
 def test_set_use_upper_case(self):
     s = PasswordSetting("unit.test")
     s.set_custom_character_set("Eab2c3")
     s.set_use_upper_case(False)
     self.assertEqual("abc23", s.get_character_set())
     s.set_custom_character_set("Eab2c3")
     s.set_use_upper_case(True)
     self.assertEqual("abcABCDEFGHIJKLMNOPQRSTUVWXYZ23", s.get_character_set())
 def test_set_use_extra(self):
     s = PasswordSetting("unit.test")
     s.set_custom_character_set("Eab;^2c3")
     s.set_use_extra(False)
     self.assertEqual("abcE23", s.get_character_set())
     s.set_custom_character_set("Eab;^2c3")
     s.set_use_extra(True)
     self.assertEqual("abcE23#!\"§$%&/()[]{}=-_+*<>;:.^", s.get_character_set())
 def test_set_use_lower_case(self):
     s = PasswordSetting("unit.test")
     s.set_custom_character_set("Eabc2")
     s.set_use_lower_case(False)
     self.assertEqual("E2", s.get_character_set())
     s.set_custom_character_set("Eabc2")
     s.set_use_lower_case(True)
     self.assertEqual("abcdefghijklmnopqrstuvwxyzE2", s.get_character_set())
 def test_set_use_digits(self):
     s = PasswordSetting("unit.test")
     s.set_custom_character_set("abE;c2")
     s.set_use_digits(False)
     self.assertEqual("abcE;", s.get_character_set())
     s.set_custom_character_set("aL;^bc2")
     s.set_use_digits(True)
     self.assertEqual("abcL0123456789;^", s.get_character_set())
 def test_get_character_set(self):
     s = PasswordSetting("unit.test")
     self.assertEqual("c", s.get_character_set()[12])
     s.set_extra_character_set("axFLp0")
     s.set_template("xox")
     self.assertEqual(6, len(s.get_character_set()))
     self.assertEqual("F", s.get_character_set()[2])
     self.assertEqual("0", s.get_character_set()[5])
 def test_load_from_json(self):
     json_str = "{\"domain\": \"unit.test\", \"username\": \"testilinius\", " +\
                "\"notes\": \"interesting note\", \"legacyPassword\": \"rtSr?bS,mi\", " +\
                "\"usedCharacters\": \"AEIOUaeiou\", \"iterations\": 5341, " +\
                "\"length\": 16, \"salt\": \"ZmFzY2luYXRpbmc=\", " +\
                "\"cDate\": \"2001-01-01T02:14:12\", \"mDate\": \"2005-01-01T01:14:12\"}"
     s = PasswordSetting(json.loads(json_str)["domain"])
     s.load_from_dict(json.loads(json_str))
     self.assertEquals("unit.test", s.get_domain())
     self.assertEquals("testilinius", s.get_username())
     self.assertEquals("interesting note", s.get_notes())
     self.assertEquals("rtSr?bS,mi", s.get_legacy_password())
     self.assertFalse(s.use_lower_case())
     self.assertFalse(s.use_upper_case())
     self.assertFalse(s.use_digits())
     self.assertFalse(s.use_extra())
     self.assertTrue(s.use_custom_character_set())
     self.assertEquals("AEIOUaeiou", s.get_character_set())
     self.assertEquals(5341, s.get_iterations())
     self.assertEquals(16, s.get_length())
     expected_salt = "fascinating".encode('utf-8')
     self.assertEqual(len(expected_salt), len(s.get_salt()))
     for i in range(len(expected_salt)):
         self.assertEqual(expected_salt[i], s.get_salt()[i])
     self.assertEquals("2001-01-01T02:14:12", s.get_creation_date())
     self.assertEquals("2005-01-01T01:14:12", s.get_modification_date())
 def test_character_set(self):
     s = PasswordSetting("unit.test")
     self.assertEqual("0123456789" +
                      "abcdefghijklmnopqrstuvwxyz" +
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                      "#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_extra_character_set("&=Oo0wWsS$#uUvVzZ")
     s.set_template("oxxxxxxxxx")
     self.assertEqual("&=Oo0wWsS$#uUvVzZ", s.get_character_set())
     s.set_extra_character_set(
         "abcdefghijklmnopqrstuvwxyz" +
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
         "0123456789" +
         "#!\"§$%&/()[]{}=-_+*<>;:.")
     self.assertEqual("abcdefghijklmnopqrstuvwxyz" +
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                      "0123456789" +
                      "#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_template("noxxxxxxxx")
     s.set_extra_character_set("#!\"§$%&/()[]{}=-_+*<>;:.")
     self.assertEqual("0123456789#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_template("xaxxxAxxx")
     self.assertEqual("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", s.get_character_set())
 def test_character_set(self):
     s = PasswordSetting("unit.test")
     self.assertEqual("0123456789" +
                      "abcdefghijklmnopqrstuvwxyz" +
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                      "#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_extra_character_set("&=Oo0wWsS$#uUvVzZ")
     s.set_template("oxxxxxxxxx")
     self.assertEqual("&=Oo0wWsS$#uUvVzZ", s.get_character_set())
     s.set_extra_character_set(
         "abcdefghijklmnopqrstuvwxyz" +
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
         "0123456789" +
         "#!\"§$%&/()[]{}=-_+*<>;:.")
     self.assertEqual("abcdefghijklmnopqrstuvwxyz" +
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                      "0123456789" +
                      "#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_template("noxxxxxxxx")
     s.set_extra_character_set("#!\"§$%&/()[]{}=-_+*<>;:.")
     self.assertEqual("0123456789#!\"§$%&/()[]{}=-_+*<>;:.", s.get_character_set())
     s.set_template("xaxxxAxxx")
     self.assertEqual("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", s.get_character_set())
 def test_load_from_json(self):
     json_str = "{\"domain\": \"unit.test\", \"username\": \"testilinius\", " +\
                "\"notes\": \"interesting note\", \"legacyPassword\": \"rtSr?bS,mi\", " +\
                "\"extras\": \"AEIOUaeiou\", \"iterations\": 5341, " +\
                "\"passwordTemplate\": \"7;xxxxoxxxxxxxxxxx\", \"salt\": \"ZmFzY2luYXRpbmc=\", " +\
                "\"cDate\": \"2001-01-01T02:14:12.000\", \"mDate\": \"2005-01-01T01:14:12.000\"}"
     s = PasswordSetting(json.loads(json_str)["domain"])
     s.load_from_dict(json.loads(json_str))
     self.assertEqual("unit.test", s.get_domain())
     self.assertEqual("testilinius", s.get_username())
     self.assertEqual("interesting note", s.get_notes())
     self.assertEqual("rtSr?bS,mi", s.get_legacy_password())
     self.assertEqual("AEIOUaeiou", s.get_character_set())
     self.assertEqual(5341, s.get_iterations())
     self.assertEqual("xxxxoxxxxxxxxxxx", s.get_template())
     expected_salt = "fascinating".encode('utf-8')
     self.assertEqual(len(expected_salt), len(s.get_salt()))
     for i in range(len(expected_salt)):
         self.assertEqual(expected_salt[i], s.get_salt()[i])
     self.assertEqual("2001-01-01T02:14:12.000", s.get_creation_date())
     self.assertEqual("2005-01-01T01:14:12.000", s.get_modification_date())