def test_get_all_logging(self): UsersLogic.register(RegisteredUser("user1user1", "13245678")) UsersLogic.register(RegisteredUser("user2user2", "13245678")) LoggerLogic.add_login_log("user1user1") LoggerLogic.add_login_log("user2user2") logs = Logger.get_all_login_logs() self.assertTrue(len(logs) == 2) login_log = logs[1] self.assertEqual(login_log.username, "user1user1") login_log = logs[0] self.assertEqual(login_log.username, "user2user2")
def login(user): if SystemManagers.login(user.username, hashlib.sha256( user.password.encode()).hexdigest()): LoggerLogic.add_login_log(user.username) return "SUCCESS" if user.username is not None and user.password is not None: if RegisteredUsers.is_user_exists(user.username): user.password = hashlib.sha256(user.password.encode()).hexdigest() if RegisteredUsers.login(user): LoggerLogic.add_login_log(user.username) return "SUCCESS" return "FAILED:Password in incorrect" return "FAILED: Username is incorrect" return "FAILED: Missing Parameters"