Ejemplo n.º 1
0
def test_parse_sources_finds_multiple_paths():
    sources = "foo/bar/:key,foo2/bar/:key2,target:/foo3/bar/:key3"
    result = vault.parse_sources(sources, config)
    assert result[1]["path"] == "foo2/bar/"
    assert result[1]["key"] == "key2"
    assert result[2]["path"] == "/foo3/bar/"
    assert result[2]["key"] == "key3"
Ejemplo n.º 2
0
def main():
    try:
        config = get_config()
    except IndexError as e:
        logger.exception(e)
        sys.exit(1)

    try:
        vault_token = vault.get_token()
    except Exception as e:
        logger.exception("Could not read vault token: %s", e)
        sys.exit(1)

    sources = vault.parse_sources(config["SECRET_SOURCES"], config)
    logger.info("Secret source mappings: %s", sources)

    secrets = vault.get_secrets(config, sources, vault_token)
    k8s.create_or_update_secret(config["SECRET_TARGET"], config["NAMESPACE"],
                                secrets)
Ejemplo n.º 3
0
def test_parse_sources_finds_single_path():
    sources = "target:foo/bar/:key"
    result = vault.parse_sources(sources, config)
    assert result[0]["path"] == "foo/bar/"
    assert result[0]["key"] == "key"
    assert result[0]["target"] == "target"
Ejemplo n.º 4
0
def test_parse_sources_strips_leading_secret():
    result = vault.parse_sources("/secret/foo:key", config)
    assert result[0]["path"] == "/foo"
    result = vault.parse_sources("secret/foo:key", config)
    assert result[0]["path"] == "/foo"
Ejemplo n.º 5
0
def test_parse_sources_finds_prefixs():
    sources = "foo/bar/:key,foo2/bar/:key2"
    result = vault.parse_sources(sources, config)
    assert result[1]["path"] == "foo2/bar/"
    assert result[1]["key"] == "key2"
Ejemplo n.º 6
0
def test_parse_sources_finds_default_key():
    sources = "target:foo/bar/"
    result = vault.parse_sources(sources, config)
    assert result[0]["target"] == "target"
    assert result[0]["key"] == "value"
    assert result[0]["path"] == "foo/bar/"