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 # This is complicated enough to have its unit test (in test_testing.py) paths = [key for key in self.db if key.startswith(path)] result = [] for element in paths: element = element[len(path) + 1 if path else 0:].split("/", 1) if len(element) == 1: result.append(element[0]) else: result.append(f"{element[0]}/") return sorted(set(result) - {""})
def handle_errors(): try: yield except json.decoder.JSONDecodeError as exc: raise exceptions.VaultNonJsonResponse(errors=[str(exc)]) except hvac.exceptions.InvalidRequest as exc: raise exceptions.VaultInvalidRequest(errors=exc.errors) from exc except hvac.exceptions.Unauthorized as exc: raise exceptions.VaultUnauthorized(errors=exc.errors) from exc except hvac.exceptions.Forbidden as exc: raise exceptions.VaultForbidden(errors=exc.errors) from exc except hvac.exceptions.InternalServerError as exc: raise exceptions.VaultInternalServerError(errors=exc.errors) from exc except hvac.exceptions.VaultDown as exc: raise exceptions.VaultSealed(errors=exc.errors) from exc except hvac.exceptions.UnexpectedError as exc: raise exceptions.VaultAPIException(errors=exc.errors) from exc