def setUp(self): pref.setConfigFile("tests/res/sshConfig.yaml") #values for mock object self.computer = computerTable.Computer(None, None, "name", "nickName", "desc", self.username, self.ip, datetime.datetime.now(), datetime.datetime.now(), False) self.user = None self.script = ScriptTable.Script(0, "script", self.filename, 0, "desc", datetime.datetime.now(), datetime.datetime.now(), 0.0, False)
def test_setConfigFileComplex(self): err = pref.setConfigFile("tests/res/test2Conf.yaml") self.assertEqual(err.code, pref.Success.code) self.assertEqual("null", pref.getError(pref.ERROR_UNKNOWN)) self.assertEqual("/test", pref.getNoCheck(pref.CONFIG_LOGIN_ENDPOINT))
def test_setConfigFileInvalidFile(self): err = pref.setConfigFile("tests/res/badConf.yaml") self.assertEqual(err.code, pref.getNoCheck(pref.ERROR_ATTRIBUTE_NOT_FOUND).code)
def test_setConfigFileDNE(self): err = pref.setConfigFile("tests/res/DOESNOTEXIST") self.assertEqual(err.code, pref.getNoCheck(pref.ERROR_FILE_NOT_FOUND).code)
def test_setConfigFile(self): err = pref.setConfigFile("tests/res/test1Conf.yaml") self.assertEqual(err, pref.Success)
from flask import Flask, redirect, request, jsonify, session import logging import libpurpl3.preferences as pref import libpurpl3.login as login import libpurpl3.operations as op import libpurpl3.sshServer as sshServer #Load preferences #TODO change to command line arg pref.setConfigFile("config.yaml") #Creates application app = Flask(__name__) app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 app.secret_key = pref.getNoCheck(pref.CONFIG_SESSION_KEY) #TODO get better key larry #sets loggers level logging.basicConfig( level=pref.getNoCheck(pref.CONFIG_LOG_LEVEL), format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger = logging.getLogger() logger.setLevel(pref.getNoCheck(pref.CONFIG_LOG_LEVEL)) #Functions for login and operations LOGIN_OPS = { pref.getNoCheck(pref.LOGIN_LOGIN): login.login, pref.getNoCheck(pref.LOGIN_CHANGE_PASSWORD): login.changePassword, pref.getNoCheck(pref.LOGIN_RESET_PASSWORD): login.resetPassword, pref.getNoCheck(pref.LOGIN_LOGOUT): login.logout, }