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
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
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
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()
def app_with_missing_url(): app = Flask(__name__) app.opa = OPA(app, input_function=parse_input) init_app(app) return app