Esempio n. 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()
Esempio n. 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
Esempio n. 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
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
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
Esempio n. 6
0
from ctf import create_app
import os
app = create_app()
app.run(debug=True, port=int(os.environ.get('PORT', '5000')))
Esempio n. 7
0
from ctf import db, create_app

db.create_all(app=create_app())