chore: Add X-Goog-API-Client header to GDA API requests

PiperOrigin-RevId: 869372484
This commit is contained in:
Google Team Member
2026-02-12 13:58:05 -08:00
committed by Copybara-Service
parent c6b1c74321
commit d85932faa3
4 changed files with 26 additions and 2 deletions
@@ -89,6 +89,12 @@ def test_ask_data_insights_success(mock_get_stream):
assert result["response"] == "Final formatted string from stream"
mock_get_stream.assert_called_once()
# Verify that the correct headers and client ID were passed to _get_stream
args, _ = mock_get_stream.call_args
headers = args[2]
assert headers["X-Goog-API-Client"] == "GOOGLE_ADK"
assert headers["Authorization"] == "Bearer fake-token"
@mock.patch.object(data_insights_tool, "_get_stream")
def test_ask_data_insights_handles_exception(mock_get_stream):
@@ -196,3 +196,16 @@ def test_get_stream_from_file(mock_post, case_file_path):
# 6. Assert that the final list of dicts matches the expected output
assert result == expected_final_list
def test_get_http_headers_includes_client_id():
"""Tests _get_http_headers includes the correct GDA client ID."""
mock_creds = mock.Mock()
mock_creds.token = "fake-token"
# pylint: disable=protected-access
headers = data_agent_tool._get_http_headers(mock_creds)
assert headers["X-Goog-API-Client"] == "GOOGLE_ADK"
assert headers["Content-Type"] == "application/json"
assert headers["Authorization"] == "Bearer fake-token"