From 1cf787a577604173ca4d48bdbfd34193cd028c7a Mon Sep 17 00:00:00 2001 From: Franccesco Orozco Date: Thu, 23 Jul 2026 19:54:39 -0600 Subject: [PATCH] dream: use httpx data= for Token form encoding Dream dream-2026-07-23.1 finding 005. --- src/bloomy/configuration.py | 14 +++++--------- tests/test_configuration.py | 9 ++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/bloomy/configuration.py b/src/bloomy/configuration.py index 6312210..609a278 100644 --- a/src/bloomy/configuration.py +++ b/src/bloomy/configuration.py @@ -5,7 +5,6 @@ import os from pathlib import Path from typing import TYPE_CHECKING -from urllib.parse import urlencode import httpx import yaml @@ -81,14 +80,11 @@ def _fetch_api_key(self, username: str, password: str) -> str: with httpx.Client() as client: response = client.post( "https://app.bloomgrowth.com/Token", - headers={"Content-Type": "application/x-www-form-urlencoded"}, - content=urlencode( - { - "grant_type": "password", - "userName": username, - "password": password, - } - ), + data={ + "grant_type": "password", + "userName": username, + "password": password, + }, ) if not response.is_success: diff --git a/tests/test_configuration.py b/tests/test_configuration.py index b0bfdf6..899e695 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -69,7 +69,14 @@ def test_configure_api_key_success(self): config.configure_api_key("user", "pass") assert config.api_key == "new-api-key" - mock_client.post.assert_called_once() + mock_client.post.assert_called_once_with( + "https://app.bloomgrowth.com/Token", + data={ + "grant_type": "password", + "userName": "user", + "password": "pass", + }, + ) def test_configure_api_key_failure(self): """Test API key configuration with authentication failure."""