All checks were successful
continuous-integration/drone/push Build is passing
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
from authentication import Authetication
|
|
import json
|
|
import logging
|
|
|
|
|
|
test_logger = logging.getLogger('TEST ')
|
|
test_logger.root.setLevel(logging.INFO)
|
|
|
|
def testSaveUser(username, password):
|
|
logging.info('STARTING SAVE USER TEST')
|
|
auth = Authetication()
|
|
auth.initConfig()
|
|
result = auth.saveUser(username, password)
|
|
check = False
|
|
|
|
with open(auth.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file:
|
|
data = json.load(json_file)
|
|
|
|
for user in data['user']:
|
|
if username == user['username']:
|
|
check = True
|
|
|
|
if result and check:
|
|
test_logger.info('TEST 1 ---> Save VALID user :: PASSED')
|
|
else:
|
|
test_logger.info('TEST 1 ---> Save VALID user :: FAILED')
|
|
|
|
|
|
def testAuth(username, password):
|
|
logging.info('STARTING AUTHENTICATION TEST')
|
|
auth = Authetication()
|
|
auth.initConfig()
|
|
auth.saveUser(username, password)
|
|
homeDir = auth.login(username, password)
|
|
|
|
if homeDir == 1:
|
|
test_logger.info('TEST 1 --> Authentication test with VALID :: PASSED')
|
|
else:
|
|
test_logger.info('TEST 1 --> Authentication test with VALID :: FAILED')
|
|
|
|
homeDir = auth.login(username, "")
|
|
if homeDir == "":
|
|
test_logger.info('TEST 2 --> Authentication test with INVALID :: PASSED')
|
|
else:
|
|
test_logger.info('TEST 2 --> Authentication test with INVALID ::FAILED')
|
|
|
|
|
|
def testUserExists(username, password):
|
|
logging.info('STARTING USER EXISTS TEST')
|
|
auth = Authetication()
|
|
auth.initConfig()
|
|
auth.saveUser(username, password)
|
|
|
|
if auth.checkUserExists(username):
|
|
logging.info('TEST 1 --> User exists with VALID user :: PASSED')
|
|
else:
|
|
logging.info('TEST 1 --> User exists with VALID user :: FAILED')
|
|
|
|
if auth.checkUserExists(""):
|
|
logging.info('TEST 2 --> User exists with INVALID user :: FAILED')
|
|
else:
|
|
logging.info('TEST 2 --> User exists with INVALID user :: PASSED')
|
|
|
|
if __name__ == '__main__':
|
|
testSaveUser("Diósbejglia","Diósbejgli")
|
|
testAuth("Diósbejglia","Diósbejgli")
|
|
testUserExists("Diósbejglia","Diósbejgli") |