Exemplo n.º 1
0
def test_with_missing_secret_key_in_vault(broker):
    broker.setup({
        "data": {},
        'status_code': 200,
    })
    with pytest.raises(SecretNotFoundError):
        envyconfig.load('fixtures/missing_key_vault.yaml')
Exemplo n.º 2
0
def test_with_supplied_format_parameters():
    formats = {
        'interpolated': 'some_stuff',
    }
    config = envyconfig.load('fixtures/basic_format.yaml', override=formats)
    assert config['foo'] == 'This string will be some_stuff.'
    assert config['bar']['baz1'] == 'This string will also be some_stuff.'
Exemplo n.º 3
0
def test_with_older_version_in_vault(broker):
    expected = '1235\n'
    broker.setup({
        "data": {
            "foo_secret": expected
        },
        'version': 1,
        'status_code': 200,
    })
    config = envyconfig.load('fixtures/basic_vault.yaml')
    assert config['older_foo'] == expected
Exemplo n.º 4
0
def test_that_we_duck_type_basic_defaults() -> None:
    config = envyconfig.load('fixtures/basic_env.yaml')
    typed = config['bar']
    assert type(typed['baz1']) is bool
    assert not typed['baz1']
    assert type(typed['baz2']) is bool
    assert typed['baz2']
    assert type(typed['baz3']) is int
    assert typed['baz3'] == 1232
    assert type(typed['baz4']) is float
    assert typed['baz4'] == 1232.2
    assert type(typed['baz5']) is str
    assert typed['baz5'] == 'abcd'
Exemplo n.º 5
0
def test_that_we_handle_missing_address_in_config(environment):
    environment.setenv("VAULT_ADDR", '')
    with pytest.raises(ConfigurationError):
        envyconfig.load('fixtures/basic_vault.yaml')
Exemplo n.º 6
0
def test_multiple_colons():
    config = envyconfig.load('fixtures/complex.yaml')
    assert config['foo'] is None
Exemplo n.º 7
0
def test_nested():
    config = envyconfig.load('fixtures/basic_nested.yaml')
    assert config['foo']['bar'] == 'baz'
Exemplo n.º 8
0
def test_that_we_allow_missing_defaults() -> None:
    config = envyconfig.load('fixtures/basic_env.yaml')
    typed = config['bar']
    assert typed['baz6'] is None
Exemplo n.º 9
0
def test_empty_value():
    config = envyconfig.load('fixtures/basic.yaml')
    assert config['baz'] == ''
Exemplo n.º 10
0
def test_basic():
    config = envyconfig.load('fixtures/basic.yaml')
    assert config['foo'] == 'bar'
Exemplo n.º 11
0
def test_flattened():
    config = envyconfig.load('fixtures/basic_nested.yaml', flatten=True)
    assert config['bar'] == 'baz'
Exemplo n.º 12
0
def test_that_we_can_specify_a_secret_version():
    config = envyconfig.load('fixtures/basic_gs.yaml')
    assert config['foo'] == 'projects/my-project/secrets/my-secret/versions/2'
Exemplo n.º 13
0
def test_nested_gs():
    config = envyconfig.load('fixtures/nested_gs.yaml')
    assert config['foo']['bar'] == 'projects/my-project/secrets/my-secret/versions/1'
Exemplo n.º 14
0
def test_with_env_var(monkeypatch):
    expected = 'some string'
    monkeypatch.setenv("TESTENVVAR", expected)
    config = envyconfig.load('fixtures/basic_env.yaml')
    assert config['foo'] == expected
Exemplo n.º 15
0
def test_use_default_when_env_var_is_not_defined():
    config = envyconfig.load('fixtures/basic_env.yaml')
    assert config['foo'] == 'bar'