Ejemplo n.º 1
0
def app_register_blueprints(app):
    # TODO: (jsm) deprecate the index endpoints on the root path,
    # these are currently duplicated under /index (the ultimate
    # path) for migration

    app.url_map.strict_slashes = False

    if "DICTIONARY_URL" in app.config:
        url = app.config["DICTIONARY_URL"]
        datadictionary = DataDictionary(url=url)
    elif "PATH_TO_SCHEMA_DIR" in app.config:
        datadictionary = DataDictionary(
            root_dir=app.config["PATH_TO_SCHEMA_DIR"])
    else:
        import gdcdictionary

        datadictionary = gdcdictionary.gdcdictionary

    dictionary.init(datadictionary)
    from gdcdatamodel import models as md
    from gdcdatamodel import validators as vd

    models.init(md)
    validators.init(vd)
    sheepdog_blueprint = sheepdog.create_blueprint("submission")

    v0 = "/v0"
    app.register_blueprint(sheepdog_blueprint, url_prefix=v0 + "/submission")
    app.register_blueprint(sheepdog_blueprint, url_prefix="/submission")
    app.register_blueprint(oauth2_blueprint.blueprint,
                           url_prefix=v0 + "/oauth2")
    app.register_blueprint(oauth2_blueprint.blueprint, url_prefix="/oauth2")
Ejemplo n.º 2
0
def dictionary_setup(_app):
    url = 's3://testurl'
    session = requests.Session()
    adapter = requests_mock.Adapter()
    session.mount('s3', adapter)
    json_dict = json.load(open(PATH_TO_SCHEMA_DIR + '/dictionary.json'))
    adapter.register_uri('GET', url, json=json_dict, status_code=200)
    resp = session.get(url)

    with patch('requests.get') as get_mocked:
        get_mocked.return_value = resp
        datadictionary = DataDictionary(url=url)
        dictionary.init(datadictionary)
        from gdcdatamodel import models as md
        from gdcdatamodel import validators as vd
        models.init(md)
        validators.init(vd)
        sheepdog_blueprint = sheepdog.create_blueprint(
            'submission'
        )

        try:
            _app.register_blueprint(sheepdog_blueprint, url_prefix='/v0/submission')
        except AssertionError:
            _app.logger.info('Blueprint is already registered!!!')
Ejemplo n.º 3
0
def app_init(app):
    # Register duplicates only at runtime
    app.logger.info("Initializing app")

    app.config["REQUIRE_FILE_INDEX_EXISTS"] = (
        # If True, enforce indexd record exists before file node registration
        app.config.get("REQUIRE_FILE_INDEX_EXISTS", False))

    app_register_blueprints(app)
    db_init(app)
    # exclude es init as it's not used yet
    # es_init(app)
    try:
        app.secret_key = app.config["FLASK_SECRET_KEY"]
    except KeyError:
        app.logger.error(
            "Secret key not set in config! Authentication will not work")
    sheepdog_blueprint = sheepdog.create_blueprint("submission")

    try:
        app.register_blueprint(sheepdog_blueprint, url_prefix="/v0/submission")
    except AssertionError:
        app.logger.info("Blueprint is already registered!!!")

    app.node_authz_entity_name = os.environ.get("AUTHZ_ENTITY_NAME", None)
    app.node_authz_entity = None
    app.subject_entity = None
    if app.node_authz_entity_name:
        full_module_name = "datamodelutils.models"
        mymodule = importlib.import_module(full_module_name)
        for i in dir(mymodule):
            app.logger.warn(i)
            if i.lower() == "person":
                attribute = getattr(mymodule, i)
                app.subject_entity = attribute
            if i.lower() == app.node_authz_entity_name.lower():
                attribute = getattr(mymodule, i)
                app.node_authz_entity = attribute
Ejemplo n.º 4
0
def app_init(app):
    # Register duplicates only at runtime
    app.logger.info("Initializing app")

    app.config["REQUIRE_FILE_INDEX_EXISTS"] = (
        # If True, enforce indexd record exists before file node registration
        app.config.get("REQUIRE_FILE_INDEX_EXISTS", False))

    app_register_blueprints(app)
    db_init(app)
    # exclude es init as it's not used yet
    # es_init(app)
    try:
        app.secret_key = app.config["FLASK_SECRET_KEY"]
    except KeyError:
        app.logger.error(
            "Secret key not set in config! Authentication will not work")
    sheepdog_blueprint = sheepdog.create_blueprint("submission")

    try:
        app.register_blueprint(sheepdog_blueprint, url_prefix="/v0/submission")
    except AssertionError:
        app.logger.info("Blueprint is already registered!!!")