コード例 #1
0
def test_setup():
    with pytest.raises(IOError):
        os.environ["CTF_CONFIG"] = "tests/configs/nx.json"
        create_app()

    with pytest.raises(ValueError):
        os.environ["CTF_CONFIG"] = "tests/configs/teapot.json"
        create_app()
コード例 #2
0
def app():
    os.environ["CTF_CONFIG"] = "tests/configs/good.json"
    app = create_app()
    app.redis = fakeredis.FakeRedis()
    app.secret_key = 'my secret key'
    app.debug = True
    return app
コード例 #3
0
def app():
    os.environ["CTF_CONFIG"] = "tests/configs/good.json"
    app = create_app()
    app.redis = fakeredis.FakeRedis()
    app.secret_key = 'my secret key'
    app.debug = True
    return app
コード例 #4
0
def app(monkeypatch):
    os.environ["CTF_CONFIG"] = "tests/configs/good.json"
    app = create_app()
    app.redis = fakeredis.FakeRedis()
    app.secret_key = 'my secret key'
    app.debug = True
    # We aren't trying to test CSRF here
    app.config['WTF_CSRF_CHECK_DEFAULT'] = False
    app.config['WTF_CSRF_ENABLED'] = False
    ext.csrf.exempt(frontend.bp)
    monkeypatch.setattr(frontend, 'validate_csrf', lambda d: d == 'token')
    return app
コード例 #5
0
def app(monkeypatch):
    os.environ["CTF_CONFIG"] = "tests/configs/good.json"
    app = create_app()
    app.redis = fakeredis.FakeRedis()
    app.secret_key = 'my secret key'
    app.debug = True

    # In-memory database only
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'

    # We aren't trying to test CSRF here
    app.config['WTF_CSRF_CHECK_DEFAULT'] = False
    app.config['WTF_CSRF_ENABLED'] = False
    ext.csrf.exempt(frontend.bp)
    # This will let us still test flask_wtf.csrf.validate_csrf from /logout/
    monkeypatch.setattr(frontend, 'validate_csrf', lambda d: d == 'token')

    with app.app_context():
        ext.db.create_all()
        setup.build_challenges()

    return app
コード例 #6
0
from ctf import create_app
import os
app = create_app()
app.run(debug=True, port=int(os.environ.get('PORT', '5000')))
コード例 #7
0
from ctf import db, create_app

db.create_all(app=create_app())