def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        command = input("Logged>>")

        if command == 'info':
            print("You are: " + logged_user.get_username())
            print("Your id is: " + str(logged_user.get_id()))
            print("Your balance is:" + str(logged_user.get_balance()) + '$')

        elif command == 'changepass':
            new_pass = getpass("Enter your new password: "******"info - for showing account info")
            print("changepass - for changing passowrd")
            print("deposit <amount> - for depositing money")
            print("withdraw <amount> - for withdrawing money")
Ejemplo n.º 2
0
    def test_change_password(self):
        new_password = "******"
        SQLManager.change_pass(new_password, self.logged_user)

        with self.subTest('The password was changed in the database!'):
            password_hash = '9cd9fd430e4be00593e1b2c1824977f1eaee841593a8f44e70bb9261cda5e90d'

            SQLManager.cursor.execute('SELECT Count(*)  FROM clients WHERE username = (%s) AND'
                                      ' password = (%s)', ('Tester', password_hash))

            self.assertEqual(SQLManager.cursor.fetchone()[0], 1)

        with self.subTest('The user can login with the new password!'):
            logged_user_new_password = SQLManager.login('Tester', new_password)
            self.assertEqual(logged_user_new_password.get_username(), 'Tester')
Ejemplo n.º 3
0
class SqlManagerTests(unittest.TestCase):
    def setUp(self):
        self.manager = SQLManager()
        self.manager.register('Tester', '123')

    def tearDown(self):
        self.manager.cursor.execute('DROP TABLE clients')

    @classmethod
    def tearDownClass(cls):
        os.remove("bank.db")

    def test_register(self):
        self.manager.register('Dinko', '123123')

        self.manager.cursor.execute(
            """SELECT Count(*)
                                      FROM clients
                                      WHERE username = (?)
                                      AND password = (?)""",
            ('Dinko', '123123'))
        users_count = self.manager.cursor.fetchone()

        self.assertEqual(users_count[0], 1)

    def test_login(self):
        logged_user = self.manager.login('Tester', '123')
        self.assertEqual(logged_user.get_username(), 'Tester')

    def test_login_wrong_password(self):
        logged_user = self.manager.login('Tester', '123567')
        self.assertFalse(logged_user)

    def test_change_message(self):
        logged_user = self.manager.login('Tester', '123')
        new_message = "podaivinototam"
        self.manager.change_message(new_message, logged_user)
        self.assertEqual(logged_user.get_message(), new_message)

    def test_change_password(self):
        logged_user = self.manager.login('Tester', '123')
        new_password = "******"
        self.manager.change_pass(new_password, logged_user)

        logged_user_new_password = self.manager.login('Tester', new_password)
        self.assertEqual(logged_user_new_password.get_username(), 'Tester')
Ejemplo n.º 4
0
 def test_change_password_raises_exception_on_invalid_new_password(self):
     with self.assertRaises(InvalidPassword):
         SQLManager.change_pass('123', self.logged_user)