Ejemplo n.º 1
0
def _generate_deploy_params(runlevel):
    if runlevel == RunLevel.development_instance():
        supplemental_config = _generate_development_params()
    elif runlevel == RunLevel.production_instance():
        supplemental_config = _generate_production_params()
    else:
        raise Exception("Unsupported runlevel: " + str(runlevel))
    return supplemental_config
Ejemplo n.º 2
0
def test_production_config():
    run_level = RunLevel.production_instance()
    project_env = ProjectEnv.knoweng_instance()
    config = nest_config.generate_config(project_env, run_level)
    app = create_app(config, project_env, run_level)
    if app is None:
        assert False, "create_app returned None"

    assert app.config['ENV'] == 'prod'
    assert app.config['DEBUG'] is False
    assert app.config['DEBUG_TB_ENABLED'] is False
    return
Ejemplo n.º 3
0
def test_deploy_instances():
    development_env = RunLevel.development_instance()
    production_env = RunLevel.production_instance()

    development_rt = RunLevel(development_env.get_runlevel_name())
    production_rt = RunLevel(production_env.get_runlevel_name())

    assert development_env == development_rt
    assert development_env == development_env
    assert not development_env == production_env
    assert production_env == production_rt

    s = (str(development_env))
    print(s)
    assert s.endswith('development')

    assert development_env == RunLevel('development')
    return
Ejemplo n.º 4
0
def build_authenticator(flask_app, project_env, runlevel):
    users_sqla_maker = core_db.get_nest_users_sqla_maker()
    db_engine = nest_db.get_global_sqlalchemy_engine()
    md = nest_db.get_global_sqlalchemy_metadata()
    users_client = users_sqla_maker.get_db_client(db_engine, md)

    #the authenticator will interact with the local db as the master system_user
    auth_user = core_db.get_system_user()
    users_client.set_requesting_user(auth_user)

    #knoweng uses hubzero to look up user accounts in production
    #all other situations will use user accounts stored in the local db
    use_hubzero = (ProjectEnv.knoweng_instance() == project_env
                   and RunLevel.production_instance() == runlevel)

    if use_hubzero:
        print('registering Hubzero authenticator')
        from nest_py.knoweng.flask.accounts.knoweng_authentication import HubzeroAuthenticationStrategy
        authenticator = HubzeroAuthenticationStrategy(flask_app, users_client)
    else:
        from nest_py.core.flask.accounts.authentication import NativeAuthenticationStrategy

        authenticator = NativeAuthenticationStrategy(flask_app, users_client)
    return authenticator