From cf46944e504dd9137501d9b35f95c60fcdd1b485 Mon Sep 17 00:00:00 2001 From: "DESKTOP-DPA61F8\\Benedek" Date: Sun, 18 Apr 2021 23:06:20 +0200 Subject: [PATCH] Testing directory structure --- server/authentication_test.py | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/server/authentication_test.py b/server/authentication_test.py index cb3033d..7729b1d 100644 --- a/server/authentication_test.py +++ b/server/authentication_test.py @@ -1,6 +1,7 @@ from authentication import Authetication import json import logging +import os test_logger = logging.getLogger('TEST ') test_logger.root.setLevel(logging.INFO) @@ -63,6 +64,7 @@ def testUserExists(username: str, password: str): def productionInit(): + logging.info('INITIATING CONFIG FILE') auth = Authetication() auth.initConfig() auth.saveUser('alma','alma') @@ -72,8 +74,57 @@ def productionInit(): auth.saveUser('dinnye','dinnye') auth.generatePrivateKeyForUser('dinnye', 'eynnid') + +def testPersistency(): + logging.info('PERSISTENCY TEST') + auth = Authetication() + auth.initConfig() + auth.saveUser('alma','alma') + auth.generatePrivateKeyForUser('alma', 'amla') + auth.saveUser('citrom','citrom') + auth.generatePrivateKeyForUser('citrom', 'mortic') + + auth2 = Authetication() + if auth2.checkUserExists('alma'): + logging.info('TEST 1 --> Persictency test :: PASSED') + else: + logging.info('TEST 1 --> Persictency test :: FAILED') + + if auth2.checkUserExists(""): + logging.info('TEST 2 --> Persictency test :: FAILED') + else: + logging.info('TEST 2 --> Persictency test :: PASSED') + + if os.path.isdir(auth.HOME_DIRECTORY_LOCATION): + logging.info('TEST 3 --> Persictency test :: PASSED') + else: + logging.info('TEST 3 --> Persictency test :: FAILED') + + if os.path.isdir(auth.CONFIG_DIRECTORY_LOCATION): + logging.info('TEST 4 --> Persictency test :: PASSED') + else: + logging.info('TEST 4 --> Persictency test :: FAILED') + + if os.path.isfile(auth.CONFIG_FILE_LOCATION): + logging.info('TEST 5 --> Persictency test :: PASSED') + else: + logging.info('TEST 5 --> Persictency test :: FAILED') + + if os.stat(auth.CONFIG_FILE_LOCATION).st_size > 0: + logging.info('TEST 6 --> Persictency test :: PASSED') + else: + logging.info('TEST 6 --> Persictency test :: FAILED') + + if os.path.isdir(auth.PRIVATE_KEY_DIRECTORY_LOCATION): + logging.info('TEST 7 --> Persictency test :: PASSED') + else: + logging.info('TEST 7 --> Persictency test :: FAILED') + + + if __name__ == '__main__': testSaveUser("Diósbejglia", "Diósbejgli") testAuth("Diósbejglia", "Diósbejgli") testUserExists("Diósbejglia", "Diósbejgli") + testPersistency() productionInit()