Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion obstore/python/obstore/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def from_url( # noqa: C901
**kwargs,
)
if scheme == "http":
if config or kwargs:
if config or kwargs or credential_provider:
msg = "HTTPStore does not accept any configuration"
raise BaseError(msg)

Expand All @@ -813,6 +813,9 @@ def from_url( # noqa: C901
automatic_cleanup = kwargs.pop("automatic_cleanup")
if "mkdir" in kwargs:
mkdir = kwargs.pop("mkdir")
if credential_provider:
msg = "LocalStore does not accept a credential provider"
raise BaseError(msg)

return LocalStore.from_url(
url,
Expand Down
14 changes: 14 additions & 0 deletions tests/store/test_from_url.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

import pytest

from obstore.exceptions import BaseError, UnknownConfigurationKeyError
from obstore.store import from_url

if TYPE_CHECKING:
from obstore.store import S3Credential


def test_local():
cwd = Path().absolute()
Expand Down Expand Up @@ -55,3 +61,11 @@ def test_http():

with pytest.raises(BaseError):
from_url(url, bucket="test")


def test_credential_provider_to_http_store_raises():
def s3_credential_provider() -> S3Credential:
return {"access_key_id": "", "secret_access_key": "", "expires_at": None}

with pytest.raises(BaseError):
from_url("http://mydomain/path", credential_provider=s3_credential_provider)