Testing directory structure
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DESKTOP-DPA61F8\Benedek 2021-04-18 23:06:20 +02:00
parent c8c1b560e8
commit cf46944e50

View File

@ -1,6 +1,7 @@
from authentication import Authetication from authentication import Authetication
import json import json
import logging import logging
import os
test_logger = logging.getLogger('TEST ') test_logger = logging.getLogger('TEST ')
test_logger.root.setLevel(logging.INFO) test_logger.root.setLevel(logging.INFO)
@ -63,6 +64,7 @@ def testUserExists(username: str, password: str):
def productionInit(): def productionInit():
logging.info('INITIATING CONFIG FILE')
auth = Authetication() auth = Authetication()
auth.initConfig() auth.initConfig()
auth.saveUser('alma','alma') auth.saveUser('alma','alma')
@ -72,8 +74,57 @@ def productionInit():
auth.saveUser('dinnye','dinnye') auth.saveUser('dinnye','dinnye')
auth.generatePrivateKeyForUser('dinnye', 'eynnid') 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__': if __name__ == '__main__':
testSaveUser("Diósbejglia", "Diósbejgli") testSaveUser("Diósbejglia", "Diósbejgli")
testAuth("Diósbejglia", "Diósbejgli") testAuth("Diósbejglia", "Diósbejgli")
testUserExists("Diósbejglia", "Diósbejgli") testUserExists("Diósbejglia", "Diósbejgli")
testPersistency()
productionInit() productionInit()