def test_integration_lib(): client = vault_cli.get_client() client.set_secret("a", "b") assert client.get_secret("a") == "b" assert "a" in list(client.delete_all_secrets("")) assert client.list_secrets("") == [] client.set_secret("a", "b") assert client.list_secrets("") == ["a"] client.set_secret("c/d", "e") assert client.get_secret("c/d") == "e" assert client.list_secrets("") == ["a", "c/"] assert client.list_secrets("c") == ["d"] assert client.get_all_secrets("") == {"a": "b", "c": {"d": "e"}} client.delete_secret("a") assert client.list_secrets("") == ["c/"] assert list(client.delete_all_secrets("")) == ["c/d"]
def test_integration_lib(clean_vault): client = vault_cli.get_client() client.set_secret("a", {"value": "b"}) assert client.get_secret("a") == {"value": "b"} assert "a" in list(client.delete_all_secrets("")) assert client.list_secrets("") == [] client.set_secret("a", {"value": "b"}) assert client.list_secrets("") == ["a"] client.set_secret("c/d", {"name": "e"}) assert client.get_secret("c/d") == {"name": "e"} assert client.list_secrets("") == ["a", "c/"] assert client.list_secrets("c") == ["d"] assert client.get_all_secrets("") == { "a": { "value": "b" }, "c": { "d": { "name": "e" } }, } client.delete_secret("a") assert client.list_secrets("") == ["c/"] assert list(client.delete_all_secrets("")) == ["c/d"] assert client.lookup_token()["data"] # Use hvac client directly in order to write values that are not in a "value" attribute client.client.write(client._build_full_path("novalue"), username="******", password="******") assert client.get_secret("novalue") == { "password": "******", "username": "******" }
def test_env_var_config(): # Test env var config os.environ["VAULT_CLI_TOKEN"] = "some-other-token" with pytest.raises(vault_cli.VaultAPIException): vault_cli.get_client().set_secret("a", "b")