예제 #1
0
def app_secured_from_configuration():
    app = Flask(__name__)
    app.config["OPA_SECURED"] = True
    app.config["OPA_URL"] = 'http://localhost:8181/v1/data/examples/allow'
    app.opa = OPA(app, input_function=parse_input)
    init_app(app)
    return app
예제 #2
0
def app():
    """Import the test app"""
    app = Flask(__name__)
    app.config["OPA_SECURED"] = True
    app.config["OPA_URL"] = 'http://localhost:8181/v1/data/examples/allow'
    app.opa = OPA(app, input_function=parse_input).secured()
    init_app(app)
    return app
예제 #3
0
def test_opa_create_with_staticmethod_deny_access():
    app = Flask(__name__)
    opa_url = 'http://localhost:8181/v1/data/dm/allow'
    app.opa = OPA.secure(app, input_function=parse_input, url=opa_url)
    init_app(app)

    responses.add(responses.POST, opa_url, json={'result': False}, status=200)

    response = app.test_client().get('/')

    assert 403 == response.status_code
예제 #4
0
def test_app_without_opa_input_function_raise_value_error(app):
    app = Flask(__name__)
    app.config['OPA_SECURED'] = True
    app.config['OPA_URL'] = 'http://localhost:8181/v1/data/examples/allow'
    app.opa = OPA(app, input_function=None).secured()
예제 #5
0
def app_with_missing_url():
    app = Flask(__name__)
    app.opa = OPA(app, input_function=parse_input)
    init_app(app)
    return app