예제 #1
0
def test_update_private_key(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    private_key = get_resource_filepath("key/private_key.pem",
                                        as_text=False).read_text()
    config.bot.private_key.content = private_key
    assert config.bot.private_key._content == private_key
    assert config.bot.private_key._path is None
예제 #2
0
def test_datafeed_retry_configuration():
    config_path = get_config_resource_filepath("datafeed_retry_config.yaml")
    config = BdkConfigLoader.load_from_file(config_path)

    assert config.datafeed.retry.max_attempts == 2
    assert config.datafeed.retry.initial_interval.total_seconds() == 1.0
    assert config.datafeed.retry.multiplier == 3
    assert config.datafeed.retry.max_interval.total_seconds() == 2.0
예제 #3
0
def test_load_default_headers_defined_at_child_level_only():
    config = BdkConfigLoader.load_from_file(get_config_resource_filepath("config_headers_child_only.yaml"))

    assert config.default_headers is None
    assert config.pod.default_headers is None
    assert config.key_manager.default_headers is None
    assert config.session_auth.default_headers is None
    assert config.agent.default_headers == {"user-agent": "custom-user-agent", "header-key": "header-value"}
예제 #4
0
def test_load_default_headers_defined_at_global_and_child_level():
    global_headers = {"user-agent": "global-user-agent", "header-key": "global-header-value"}

    config = BdkConfigLoader.load_from_file(get_config_resource_filepath("config_headers_global_child.yaml"))

    assert config.default_headers == global_headers
    assert config.pod.default_headers == global_headers
    assert config.key_manager.default_headers == global_headers
    assert config.session_auth.default_headers == global_headers
    assert config.agent.default_headers == {"user-agent": "agent-user-agent", "header-key": "agent-header-value"}
예제 #5
0
def test_load_proxy_defined_at_global_level():
    config = BdkConfigLoader.load_from_file(get_config_resource_filepath("config_global_proxy.yaml"))

    assert config.proxy.host == "proxy.symphony.com"
    assert config.proxy.port == 1234
    assert config.proxy.username == "proxyuser"
    assert config.proxy.password == "proxypass"

    assert config.agent.proxy == config.proxy
    assert config.pod.proxy == config.proxy
    assert config.key_manager.proxy == config.proxy
    assert config.session_auth.proxy == config.proxy
예제 #6
0
def test_load_proxy_defined_at_child_level_only():
    config = BdkConfigLoader.load_from_file(get_config_resource_filepath("config_proxy_child_only.yaml"))

    assert config.proxy is None
    assert config.pod.proxy is None
    assert config.key_manager.proxy is None
    assert config.session_auth.proxy is None

    assert config.agent.proxy.host == "agent-proxy.symphony.com"
    assert config.agent.proxy.port == 5678
    assert config.agent.proxy.username is None
    assert config.agent.proxy.password is None
예제 #7
0
def test_default_retry_configuration():
    config_path = get_config_resource_filepath("config.yaml")
    config = BdkConfigLoader.load_from_file(config_path)

    assert config.retry.max_attempts == BdkRetryConfig.DEFAULT_MAX_ATTEMPTS
    assert config.retry.initial_interval == timedelta(
        milliseconds=BdkRetryConfig.DEFAULT_INITIAL_INTERVAL)
    assert config.retry.multiplier == BdkRetryConfig.DEFAULT_MULTIPLIER
    assert config.retry.max_interval == timedelta(
        milliseconds=BdkRetryConfig.DEFAULT_MAX_INTERVAL)

    # Datafeed default retry
    assert config.datafeed.retry.max_attempts == sys.maxsize
    assert config.datafeed.retry.initial_interval == timedelta(
        milliseconds=BdkRetryConfig.DEFAULT_INITIAL_INTERVAL)
    assert config.datafeed.retry.multiplier == BdkRetryConfig.DEFAULT_MULTIPLIER
    assert config.datafeed.retry.max_interval == timedelta(
        milliseconds=BdkRetryConfig.DEFAULT_MAX_INTERVAL)
예제 #8
0
def test_load_client_global_config(global_config_path):
    expected_scheme = "https"
    expected_host = "devx1.symphony.com"
    expected_default_headers = {"user-agent": "custom-user-agent", "header-key": "header-value"}

    config = BdkConfigLoader.load_from_file(global_config_path)

    assert config.scheme == expected_scheme
    assert config.host == expected_host
    assert config.port == 8443
    assert config.default_headers == expected_default_headers

    assert config.pod.scheme == expected_scheme
    assert config.pod.host == "diff-pod.symphony.com"
    assert config.pod.port == 8443
    assert config.pod.context == "context"
    assert config.pod.default_headers == expected_default_headers

    assert config.scheme == expected_scheme

    assert config.agent.scheme == expected_scheme
    assert config.agent.host == expected_host
    assert config.agent.port == 443
    assert config.agent.get_formatted_context() == "/context"
    assert config.agent.default_headers == expected_default_headers

    assert config.key_manager.scheme == expected_scheme
    assert config.key_manager.host == expected_host
    assert config.key_manager.port == 8443
    assert config.key_manager.get_formatted_context() == "/diff-context"
    assert config.key_manager.default_headers == expected_default_headers

    assert config.session_auth.scheme == "http"
    assert config.session_auth.host == expected_host
    assert config.session_auth.port == 8443
    assert config.session_auth.context == "context"
    assert config.session_auth.default_headers == expected_default_headers
예제 #9
0
def test_update_certificate(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    certificate_path = get_resource_filepath("cert/certificate.cert",
                                             as_text=True)
    config.bot.certificate.path = certificate_path
    assert config.bot.certificate._path == certificate_path
예제 #10
0
def fixture_config():
    config = BdkConfigLoader.load_from_file(get_config_resource_filepath("config.yaml"))
    return config
def fixture_config():
    config = BdkConfigLoader.load_from_file(get_config_resource_filepath("config.yaml"))
    config.datafeed.retry = minimal_retry_config()
    config.datafeed.version = "v2"
    return config
from symphony.bdk.core.config.loader import BdkConfigLoader

config_1 = BdkConfigLoader.load_from_file("/absolute/path/to/config.yaml")

with open("/absolute/path/to/config.yaml") as config_file:
    config_2 = BdkConfigLoader.load_from_content(config_file.read())

config_3 = BdkConfigLoader.load_from_symphony_dir("config.yaml")
def test_update_private_key(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    private_key = "private_key_path/private_key.pem"
    config.bot.private_key.content = private_key
    assert config.bot.private_key._content == private_key
    assert config.bot.private_key._path is None
예제 #14
0
def test_load_from_file_not_found(wrong_path):
    fail_error_message = f"Config file has not been found at: {Path(wrong_path).absolute()}"
    with pytest.raises(BdkConfigError, match=re.escape(fail_error_message)):
        BdkConfigLoader.load_from_file(wrong_path)
예제 #15
0
def test_load_from_file(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    assert config.bot.username == "youbot"
def fixture_app_cert_config():
    return BdkConfigLoader.load_from_file(get_config_resource_filepath("config_obo_cert.yaml"))
def test_update_certificate(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    certificate_path = "certificate_path/certificate.cert"
    config.bot.certificate.path = certificate_path
    assert config.bot.certificate._path == certificate_path