codecov[bot]: # [Codecov](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=h1) Report
> Merging [#140](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=desc) into [master](https://codecov.io/gh/peopledoc/vault-cli/commit/35c185d17c1ca70339900f7236746d000273e783?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/peopledoc/vault-cli/pull/140/graphs/tree.svg?width=650&token=fjUxXKxpOh&height=150&src=pr)](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=tree)

```diff
@@          Coverage Diff          @@
##           master   #140   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     12           
  Lines         800    804    +4     
  Branches      103    103           
=====================================
+ Hits          800    804    +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #integration | `67.41% <50%> (-0.09%)` | :arrow_down: |
| #unit | `100% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [vault\_cli/client.py](https://codecov.io/gh/peopledoc/vault-cli/pull/140/diff?src=pr&el=tree#diff-dmF1bHRfY2xpL2NsaWVudC5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [vault\_cli/testing.py](https://codecov.io/gh/peopledoc/vault-cli/pull/140/diff?src=pr&el=tree#diff-dmF1bHRfY2xpL3Rlc3RpbmcucHk=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=footer). Last update [35c185d...2f3e47a](https://codecov.io/gh/peopledoc/vault-cli/pull/140?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

SdgJlbl: Problem also impacts the library, so fixing in `client.py` seems more relevant.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4080144..d4604f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ CHANGELOG
 - Omit secrets in `vault env` when path contains forbidden chars (#138)
 - `vault env` fails properly when program name is not supplied
 - `vault env` now supports `-` and ` ` (spaces) in variable names, changing them into `_`
+- Fix trailing slash in path issue in `get-all` and `delete-all` (#135)
 
 1.1.0 (2020-02-28)
 -------------------
diff --git a/vault_cli/client.py b/vault_cli/client.py
index d849d72..a5fc3d5 100644
--- a/vault_cli/client.py
+++ b/vault_cli/client.py
@@ -265,6 +265,7 @@ class VaultClientBase:
         types.JSONDict
             {"folder/subfolder": {"secret_key": "secret_value"}}
         """
+        path = path.rstrip("/")
         try:
             secrets_paths = list(
                 self._browse_recursive_secrets(path=path, render=render)
@@ -400,6 +401,7 @@ class VaultClientBase:
 
     def delete_all_secrets_iter(self, *paths: str) -> Iterable[str]:
         for path in paths:
+            path = path.rstrip("/")
             secrets_paths = self._browse_recursive_secrets(path=path, render=False)
             for secret_path in secrets_paths:
                 yield secret_path

vault get-all is all funky when path ends with /
diff --git a/tests/unit/test_client_base.py b/tests/unit/test_client_base.py
index 7e963db..93b8176 100644
--- a/tests/unit/test_client_base.py
+++ b/tests/unit/test_client_base.py
@@ -137,6 +137,10 @@ def test_vault_client_base_get_all_secrets(vault):
 
     assert result == {"a": {"c": {"value": "secret-ac"}}}
 
+    result = vault.get_all_secrets("a/")
+
+    assert result == {"a": {"c": {"value": "secret-ac"}}}
+
 
 def test_vault_client_base_get_all_secrets_flat(vault):
     vault.db = {"a/c": {"value": "secret-ac"}, "b": {"value": "secret-b"}}
@@ -152,13 +156,16 @@ def test_vault_client_base_get_all_secrets_flat(vault):
 
 @pytest.mark.parametrize(
     "input, expected",
-    [("a", {"a/c": {"value": "secret-ac"}}), ("b", {"b": {"value": "secret-b"}})],
+    [
+        ("a", {"a/c": {"value": "secret-ac"}}),
+        ("b", {"b": {"value": "secret-b"}}),
+        ("a/", {"a/c": {"value": "secret-ac"}}),
+    ],
 )
 def test_vault_client_base_get_secrets(vault, input, expected):
     vault.db = {"a/c": {"value": "secret-ac"}, "b": {"value": "secret-b"}}
 
     result = vault.get_secrets(input)
-
     assert result == expected
 
 
@@ -203,6 +210,14 @@ def test_vault_client_base_delete_all_secrets_no_generator(vault):
     assert vault.db == {}
 
 
+def test_vault_client_base_delete_all_secrets_trailing_slash(vault):
+    vault.db = {"a/c": {"value": "secret-ac"}}
+
+    assert vault.delete_all_secrets("a/") == ["a/c"]
+
+    assert vault.db == {}
+
+
 def test_vault_client_base_context_manager(vault):
 
     with vault as c:
diff --git a/vault_cli/testing.py b/vault_cli/testing.py
index 396feae..2d6c758 100644
--- a/vault_cli/testing.py
+++ b/vault_cli/testing.py
@@ -23,6 +23,7 @@ class TestVaultClient(client.VaultClientBase):
         pass
 
     def _get_secret(self, path):
+        path = path.rstrip("/")
         if path in self.forbidden_get_paths:
             raise exceptions.VaultForbidden()
         try:
@@ -31,6 +32,7 @@ class TestVaultClient(client.VaultClientBase):
             raise exceptions.VaultSecretNotFound()
 
     def _list_secrets(self, path):
+        path = path.rstrip("/")
         if path in self.forbidden_list_paths:
             raise exceptions.VaultForbidden()
         # Just reproducing in memory the behaviour of the real list_secrets

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
backports.tarfile==1.2.0
black==25.1.0
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.8.0
cryptography==44.0.2
distlib==0.3.9
docutils==0.21.2
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.18.0
hvac==2.3.0
id==1.5.0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
isort==6.0.1
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
Jinja2==3.1.6
keyring==25.6.0
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
more-itertools==10.6.0
mypy-extensions==1.0.0
nh3==0.2.21
packaging==24.2
pathspec==0.12.1
platformdirs==4.3.7
pluggy==1.5.0
pycparser==2.22
Pygments==2.19.1
pyproject-api==1.9.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
PyYAML==6.0.2
readme_renderer==44.0
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==14.0.0
SecretStorage==3.3.3
tomli==2.2.1
tox==4.25.0
twine==6.1.0
typing_extensions==4.13.0
urllib3==2.3.0
-e git+https://github.com/peopledoc/vault-cli.git@90d6c41b56225dfff106fb92026e82ec241ed313#egg=vault_cli
virtualenv==20.29.3
zipp==3.21.0

name: vault-cli
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - backports-tarfile==1.2.0
      - black==25.1.0
      - cachetools==5.5.2
      - certifi==2025.1.31
      - cffi==1.17.1
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - click==8.1.8
      - colorama==0.4.6
      - coverage==7.8.0
      - cryptography==44.0.2
      - distlib==0.3.9
      - docutils==0.21.2
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - filelock==3.18.0
      - hvac==2.3.0
      - id==1.5.0
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - isort==6.0.1
      - jaraco-classes==3.4.0
      - jaraco-context==6.0.1
      - jaraco-functools==4.1.0
      - jeepney==0.9.0
      - jinja2==3.1.6
      - keyring==25.6.0
      - markdown-it-py==3.0.0
      - markupsafe==3.0.2
      - mdurl==0.1.2
      - more-itertools==10.6.0
      - mypy-extensions==1.0.0
      - nh3==0.2.21
      - packaging==24.2
      - pathspec==0.12.1
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pycparser==2.22
      - pygments==2.19.1
      - pyproject-api==1.9.0
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-xdist==3.6.1
      - pyyaml==6.0.2
      - readme-renderer==44.0
      - requests==2.32.3
      - requests-toolbelt==1.0.0
      - rfc3986==2.0.0
      - rich==14.0.0
      - secretstorage==3.3.3
      - tomli==2.2.1
      - tox==4.25.0
      - twine==6.1.0
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - virtualenv==20.29.3
      - zipp==3.21.0
prefix: /opt/conda/envs/vault-cli

tests/unit/test_client_base.py::test_vault_client_base_get_all_secrets tests/unit/test_client_base.py::test_vault_client_base_get_secrets[a/-expected2] tests/unit/test_client_base.py::test_vault_client_base_delete_all_secrets_trailing_slash
tests/unit/test_client_base.py::test_get_client tests/unit/test_client_base.py::test_get_client_class tests/unit/test_client_base.py::test_vault_client_base_call_init_client tests/unit/test_client_base.py::test_vault_client_base_authenticate[test_kwargs0-expected0] tests/unit/test_client_base.py::test_vault_client_base_authenticate[test_kwargs1-expected1] tests/unit/test_client_base.py::test_vault_client_base_authenticate[test_kwargs2-expected2] tests/unit/test_client_base.py::test_vault_client_base_username_without_password tests/unit/test_client_base.py::test_vault_client_base_login_cert_without_key tests/unit/test_client_base.py::test_vault_client_base_no_auth tests/unit/test_client_base.py::test_vault_client_ca_bundle_verify[True-yay-yay] tests/unit/test_client_base.py::test_vault_client_ca_bundle_verify[True-None-True] tests/unit/test_client_base.py::test_vault_client_ca_bundle_verify[False-yay-False] tests/unit/test_client_base.py::test_vault_client_base_browse_recursive_secrets tests/unit/test_client_base.py::test_vault_client_base_browse_recursive_secrets_single_secret tests/unit/test_client_base.py::test_vault_client_base_get_all_secrets_flat tests/unit/test_client_base.py::test_vault_client_base_get_secrets[a-expected0] tests/unit/test_client_base.py::test_vault_client_base_get_secrets[b-expected1] tests/unit/test_client_base.py::test_vault_client_base_get_secrets_relative[a-expected0] tests/unit/test_client_base.py::test_vault_client_base_get_secrets_relative[b-expected1] tests/unit/test_client_base.py::test_vault_client_base_delete_all_secrets_generator tests/unit/test_client_base.py::test_vault_client_base_delete_all_secrets_no_generator tests/unit/test_client_base.py::test_vault_client_base_context_manager tests/unit/test_client_base.py::test_vault_client_set_secret tests/unit/test_client_base.py::test_vault_client_set_secret_overwrite_invalid[True-False] tests/unit/test_client_base.py::test_vault_client_set_secret_overwrite_invalid[True-None] tests/unit/test_client_base.py::test_vault_client_set_secret_overwrite_invalid[False-False] tests/unit/test_client_base.py::test_vault_client_set_secret_with_update tests/unit/test_client_base.py::test_vault_client_set_secret_with_update_overwrite_invalid tests/unit/test_client_base.py::test_vault_client_set_secret_overwrite_valid[True-True-c] tests/unit/test_client_base.py::test_vault_client_set_secret_overwrite_valid[False-None-c] tests/unit/test_client_base.py::test_vault_client_set_secret_overwrite_valid[True-None-d] tests/unit/test_client_base.py::test_vault_client_set_secret_when_there_are_existing_secrets_beneath_path tests/unit/test_client_base.py::test_vault_client_set_secret_when_a_parent_is_an_existing_secret tests/unit/test_client_base.py::test_vault_client_set_secret_read_not_allowed tests/unit/test_client_base.py::test_vault_client_set_secret_list_not_allowed tests/unit/test_client_base.py::test_vault_client_set_secret_read_parent_not_allowed tests/unit/test_client_base.py::test_vault_client_move_secrets tests/unit/test_client_base.py::test_vault_client_move_secrets_generator tests/unit/test_client_base.py::test_vault_client_move_secrets_overwrite_safe tests/unit/test_client_base.py::test_vault_client_move_secrets_overwrite_force tests/unit/test_client_base.py::test_vault_client_base_render_template tests/unit/test_client_base.py::test_vault_client_base_render_template_path_not_found tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents0-expected0] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents1-expected1] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents2-expected2] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents3-expected3] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents4-expected4] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents5-expected5] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents6-expected6] tests/unit/test_client_base.py::test_vault_client_base_get_secret[vault_contents7-expected7] tests/unit/test_client_base.py::test_vault_client_base_get_secret_template_root tests/unit/test_client_base.py::test_vault_client_base_get_secret_multiple_keys tests/unit/test_client_base.py::test_vault_client_base_get_secret_with_dict tests/unit/test_client_base.py::test_vault_client_base_get_secret_not_found tests/unit/test_client_base.py::test_vault_client_base_get_secret_missing_key tests/unit/test_client_base.py::test_vault_client_base_lookup_token tests/unit/test_client_base.py::test_vault_client_base_get_secrets_error tests/unit/test_client_base.py::test_vault_client_base_get_secrets_list_forbidden tests/unit/test_client_base.py::test_vault_client_base_absolute_path[get_secret-params0-expected0] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[get_secret-params1-expected1] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[delete_secret-params2-expected2] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[delete_secret-params3-expected3] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[list_secrets-params4-expected4] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[list_secrets-params5-expected5] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[set_secret-params6-expected6] tests/unit/test_client_base.py::test_vault_client_base_absolute_path[set_secret-params7-expected7] tests/unit/test_client_base.py::test_vault_client_base_build_full_path[foo-/base/foo] tests/unit/test_client_base.py::test_vault_client_base_build_full_path[/foo-/foo] tests/unit/test_client_base.py::test_vault_client_base_base_path[foo-/foo/] tests/unit/test_client_base.py::test_vault_client_base_base_path[foo/-/foo/] tests/unit/test_client_base.py::test_vault_client_base_base_path[foo//-/foo/] tests/unit/test_client_base.py::test_vault_client_base_base_path[/foo-/foo/] tests/unit/test_client_base.py::test_vault_client_base_base_path[/foo/-/foo/] tests/unit/test_client_base.py::test_vault_client_base_base_path[/foo//-/foo/] tests/unit/test_client_base.py::test_vault_client_base_get_secret_implicit_cache_ends tests/unit/test_client_base.py::test_vault_client_base_get_secret_implicit_cache_no_race_condition tests/unit/test_client_base.py::test_vault_client_base_get_secrets_implicit_cache_no_race_condition tests/unit/test_client_base.py::test_vault_client_base_get_secret_explicit_cache
vault_cli/client.py CHANGELOG.md
vault_cli/client.py CHANGELOG.md