mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(bitbucket): use the configured base_url
BitBucketClient read config.get("", ...) instead of config.get("base_url", ...), so a custom BitBucket API base URL was ignored and every request went to api.bitbucket.org. Read the documented key and cover it with a request-URL test.
Closes #50158
This commit is contained in:
parent
dddbaa803d
commit
6aab6451c4
2 changed files with 23 additions and 1 deletions
|
|
@ -80,7 +80,7 @@ class BitBucketClient:
|
|||
self.repository = config.get("repository")
|
||||
self.access_token = config.get("access_token")
|
||||
self.branch = config.get("branch", "main")
|
||||
self.base_url = config.get("", "https://api.bitbucket.org/2.0")
|
||||
self.base_url = config.get("base_url", "https://api.bitbucket.org/2.0")
|
||||
self.auth_method = config.get("auth_method", "token")
|
||||
self.username = config.get("username")
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,28 @@ def test_bitbucket_client_initialization():
|
|||
assert client_basic.username == "test-user"
|
||||
|
||||
|
||||
def test_bitbucket_client_uses_configured_base_url():
|
||||
config = {
|
||||
"workspace": "test-workspace",
|
||||
"repository": "test-repo",
|
||||
"access_token": "test-token",
|
||||
"base_url": "https://bitbucket.example.com/2.0",
|
||||
}
|
||||
|
||||
with patch("litellm.integrations.bitbucket.bitbucket_client.HTTPHandler") as handler_cls:
|
||||
client = BitBucketClient(config)
|
||||
handler_cls.return_value.get.return_value = MagicMock(
|
||||
headers={"content-type": "text/plain"}, text="prompt"
|
||||
)
|
||||
|
||||
client.get_file_content("prompts/test.prompt")
|
||||
|
||||
assert (
|
||||
handler_cls.return_value.get.call_args.args[0]
|
||||
== "https://bitbucket.example.com/2.0/repositories/test-workspace/test-repo/src/main/prompts/test.prompt"
|
||||
)
|
||||
|
||||
|
||||
def test_bitbucket_client_missing_required_fields():
|
||||
"""Test BitBucketClient initialization with missing required fields."""
|
||||
with pytest.raises(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue