Exemplo n.º 1
0
 def test_show_all_users(self):
     signed_user_controller = SignedUserController()
     signed_user_controller.add_guest("0.0.0.1")
     signed_user_controller.add_guest("0.0.0.3")
     signed_user_controller.add_guest("0.0.0.3")
     d1 = datetime.datetime(2020, 4, 23)
     signed_user_controller.add_signed_user("name_u1", "1234", "ro", d1,
                                            "0.0.0.5")
     l1, l2 = signed_user_controller.show_all_users()
     self.assertEqual(3, l1.__len__() + l2.__len__())
Exemplo n.º 2
0
 def test_edit_personal_name(self):
     signed_user_controller = SignedUserController()
     d1 = datetime.datetime(2020, 4, 23)
     signed_user_controller.add_signed_user("name_u1", "1234", "ro", d1,
                                            "0.0.0.5")
     self.assertTrue(
         signed_user_controller.edit_personal_name("name_u1", "moshe"))
     self.assertNotEqual("ro",
                         signed_user_controller.get_user("name_u1").name)
     self.assertEqual("moshe",
                      signed_user_controller.get_user("name_u1").name)
     self.assertFalse(
         signed_user_controller.edit_personal_name("name21", "moshe"))
Exemplo n.º 3
0
 def test_delete_signed_user(self):
     signed_user_controller = SignedUserController()
     d1 = datetime.datetime(2020, 4, 23)
     d2 = datetime.datetime(1998, 4, 23)
     signed_user_controller.add_signed_user("name_u1", "1234", "ro", d1,
                                            "0.0.0.5")
     signed_user_controller.add_signed_user("name_u2", "1234", "ro", d2,
                                            "0.0.0.6")
     signed_user_controller.delete_signed_user("name_u1")
     signed_user_controller.delete_signed_user("name_u12")
     self.assertEqual(1,
                      signed_user_controller.get_signed_users().__len__())
     self.assertIsNone(
         signed_user_controller.get_signed_users().get("name_u1"))
Exemplo n.º 4
0
 def test_add_signed_user(self):
     signed_user_controller = SignedUserController()
     signed_user_controller.add_guest("0.0.0.1")
     signed_user_controller.add_guest("0.0.0.1")
     d1 = datetime.datetime(2020, 4, 23)
     d2 = datetime.datetime(1998, 4, 23)
     signed_user_controller.add_signed_user("name_u1", "1234", "ro", d1,
                                            "0.0.0.5")
     signed_user_controller.add_signed_user("name_u2", "1234", "ro", d2,
                                            "0.0.0.6")
     self.assertIsNotNone(
         signed_user_controller.get_signed_users().get("name_u1").user_id)
     self.assertEqual(3, (signed_user_controller.get_guests().__len__()) +
                      (signed_user_controller.get_signed_users().__len__()))
Exemplo n.º 5
0
 def test_edit_personal_birth_date(self):
     signed_user_controller = SignedUserController()
     d1 = datetime.datetime(2020, 4, 23)
     d2 = datetime.datetime(1998, 4, 23)
     signed_user_controller.add_signed_user("name_u1", "1234", "ro", d1,
                                            "0.0.0.5")
     self.assertTrue(
         signed_user_controller.edit_personal_birth_date("name_u1", d2))
     self.assertNotEqual(
         d1,
         signed_user_controller.get_user("name_u1").birth_date)
     self.assertEqual(d2,
                      signed_user_controller.get_user("name_u1").birth_date)
     self.assertFalse(
         signed_user_controller.edit_personal_birth_date("name21", d1))
Exemplo n.º 6
0
 def test_edit_personal_password(self):
     signed_user_controller = SignedUserController()
     d1 = datetime.datetime(2020, 4, 23)
     old_password = "******"
     new_password = "******"
     signed_user_controller.add_signed_user("name_u1", old_password, "ro",
                                            d1, "0.0.0.5")
     self.assertTrue(
         signed_user_controller.edit_personal_password(
             "name_u1", old_password, new_password))
     self.assertNotEqual(
         str(hashlib.sha256(old_password.encode()).hexdigest()),
         signed_user_controller.get_user("name_u1").password)
     self.assertEqual(
         str(hashlib.sha256(new_password.encode()).hexdigest()),
         signed_user_controller.get_user("name_u1").password)
     self.assertFalse(
         signed_user_controller.edit_personal_password(
             "name1", new_password, old_password))