Skip to content

Commit 1e995a3

Browse files
authored
Merge pull request #25 from franccesco/dream/2026-07-23.1/finding-005
dream: use httpx data= for Token form encoding
2 parents 16ef48a + 1cf787a commit 1e995a3

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/bloomy/configuration.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
from pathlib import Path
77
from typing import TYPE_CHECKING
8-
from urllib.parse import urlencode
98

109
import httpx
1110
import yaml
@@ -81,14 +80,11 @@ def _fetch_api_key(self, username: str, password: str) -> str:
8180
with httpx.Client() as client:
8281
response = client.post(
8382
"https://app.bloomgrowth.com/Token",
84-
headers={"Content-Type": "application/x-www-form-urlencoded"},
85-
content=urlencode(
86-
{
87-
"grant_type": "password",
88-
"userName": username,
89-
"password": password,
90-
}
91-
),
83+
data={
84+
"grant_type": "password",
85+
"userName": username,
86+
"password": password,
87+
},
9288
)
9389

9490
if not response.is_success:

tests/test_configuration.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ def test_configure_api_key_success(self):
6969
config.configure_api_key("user", "pass")
7070

7171
assert config.api_key == "new-api-key"
72-
mock_client.post.assert_called_once()
72+
mock_client.post.assert_called_once_with(
73+
"https://app.bloomgrowth.com/Token",
74+
data={
75+
"grant_type": "password",
76+
"userName": "user",
77+
"password": "pass",
78+
},
79+
)
7380

7481
def test_configure_api_key_failure(self):
7582
"""Test API key configuration with authentication failure."""

0 commit comments

Comments
 (0)