def setUp(self): self.app = app.test_client() init_db() self.files = os.path.join(d, 'files') self.canaries_dir = app.config.get('CANARIES_DIR') self.fp = '2fa69032cba961ff8387ef06d2969d08c2dfb998' f = open(os.path.join(self.files, 'valid.sig')) self.valid_msg = f.read() f.close()
def setUp(self): init_db() self.user = User('C2DFB998', '2fa69032cba961ff8387ef06d2969d08c2dfb998', 'Foo Bar <*****@*****.**>') self.sekrit = os.urandom(16).encode('hex') self.chal = Challenge(sha256(self.sekrit).hexdigest()) db_session.add(self.user) db_session.add(self.chal) db_session.commit()
from flask.ext.mail import Mail import canary.config app = Flask(__name__) app.config.from_object('canary.config') if os.environ.get('CANARY_ENV') == 'test': app.config.from_object('canary.config.Testing') app.secret_key = app.config.get('SECRET_KEY') from canary.db import db_session, init_db import canary.views init_db() mail = Mail(app) if not app.debug or app.testing: import logging from logging import Formatter from logging.handlers import SysLogHandler loghandler = SysLogHandler() loghandler.setLevel(logging.INFO) loghandler.setFormatter(Formatter( '%(asctime)s %(levelname)s: %(message)s' '[in %(pathname)s:%(lineno)d]')) app.logger.addHandler(loghandler)