def test_load_config():
    assert LoadedConfig.kafka.brokers[
        0].port == 27015, "Port failed to be found"
    assert KafkaTopics["originalName"].name == "someTopic"
    assert DependencyEndpoints["app1"]["endpoint1"].port == 8000
    assert DependencyEndpoints["app2"]["endpoint2"].name == "endpoint2"
    assert ObjectBuckets["reqname"].name == "name"
    assert KafkaServers[0] == "broker-host:27015"
    with open(LoadedConfig.rds_ca()) as fp:
        ca_content = fp.read()
        assert ca_content == "ca"
Beispiel #2
0
def test_load_config():
    assert LoadedConfig.kafka.brokers[
        0].port == 27015, "Port failed to be found"
    assert KafkaTopics["originalName"].name == "someTopic"
    assert DependencyEndpoints["app1"]["endpoint1"].port == 8000
    assert DependencyEndpoints["app2"]["endpoint2"].name == "endpoint2"
    assert PrivateDependencyEndpoints["app1"]["endpoint1"].port == 10000
    assert PrivateDependencyEndpoints["app2"]["endpoint2"].name == "endpoint2"
    assert ObjectBuckets["reqname"].name == "name"
    assert KafkaServers[0] == "broker-host:27015"
    with open(LoadedConfig.rds_ca()) as fp:
        ca_content = fp.read()
        assert ca_content == "ca"
    assert isClowderEnabled() == True
    assert LoadedConfig.featureFlags.hostname == "ff-server.server.example.com"
Beispiel #3
0
def config():
    """Database config."""
    if ENVIRONMENT.bool("CLOWDER_ENABLED", default=False):
        db_obj = {
            "ENGINE": "tenant_schemas.postgresql_backend",
            "NAME": LoadedConfig.database.name,
            "USER": LoadedConfig.database.username,
            "PASSWORD": LoadedConfig.database.password,
            "HOST": LoadedConfig.database.hostname,
            "PORT": LoadedConfig.database.port,
        }
        if LoadedConfig.database.rdsCa:
            db_options = {
                "OPTIONS": {
                    "sslmode": ENVIRONMENT.get_value("PGSSLMODE",
                                                     default="prefer"),
                    "sslrootcert": LoadedConfig.rds_ca(),
                }
            }
        else:
            db_options = {}
    else:
        db_obj = {
            "ENGINE": "tenant_schemas.postgresql_backend",
            "NAME": ENVIRONMENT.get_value("DATABASE_NAME", default=None),
            "USER": ENVIRONMENT.get_value("DATABASE_USER", default=None),
            "PASSWORD": ENVIRONMENT.get_value("DATABASE_PASSWORD",
                                              default=None),
            "HOST": ENVIRONMENT.get_value("DATABASE_HOST", default=None),
            "PORT": ENVIRONMENT.get_value("DATABASE_PORT", default=None),
        }
        db_options = {
            "OPTIONS": {
                "sslmode":
                ENVIRONMENT.get_value("PGSSLMODE", default="prefer"),
                "sslrootcert":
                ENVIRONMENT.get_value("PGSSLROOTCERT",
                                      default="/etc/rds-certs/rds-cacert"),
            }
        }

    db_obj.update(db_options)

    return db_obj
Beispiel #4
0
 def get_database_ca_file():
     """Obtain database ca file."""
     if LoadedConfig.database.rdsCa:
         return LoadedConfig.rds_ca()
     return None