88 BasePushNotificationSender ,
99)
1010from a2a .types import (
11+ PushNotificationAuthenticationInfo ,
1112 PushNotificationConfig ,
1213 Task ,
1314 TaskState ,
@@ -29,8 +30,14 @@ def create_sample_push_config(
2930 url : str = 'http://example.com/callback' ,
3031 config_id : str = 'cfg1' ,
3132 token : str | None = None ,
33+ authentication : PushNotificationAuthenticationInfo | None = None ,
3234) -> PushNotificationConfig :
33- return PushNotificationConfig (id = config_id , url = url , token = token )
35+ return PushNotificationConfig (
36+ id = config_id ,
37+ url = url ,
38+ token = token ,
39+ authentication = authentication ,
40+ )
3441
3542
3643class TestBasePushNotificationSender (unittest .IsolatedAsyncioTestCase ):
@@ -92,6 +99,37 @@ async def test_send_notification_with_token_success(self) -> None:
9299 )
93100 mock_response .raise_for_status .assert_called_once ()
94101
102+ async def test_send_notification_with_auth_header (self ) -> None :
103+ task_id = 'task_send_auth'
104+ task_data = create_sample_task (task_id = task_id )
105+ auth = PushNotificationAuthenticationInfo (
106+ schemes = ['Basic' , 'Bearer' ], credentials = 'token_or_jwt'
107+ )
108+ config = create_sample_push_config (
109+ url = 'http://notify.me/here' ,
110+ token = 'unique_token' ,
111+ authentication = auth ,
112+ )
113+ self .mock_config_store .get_info .return_value = [config ]
114+
115+ mock_response = AsyncMock (spec = httpx .Response )
116+ mock_response .status_code = 200
117+ self .mock_httpx_client .post .return_value = mock_response
118+
119+ await self .sender .send_notification (task_data )
120+
121+ self .mock_config_store .get_info .assert_awaited_once_with
122+
123+ self .mock_httpx_client .post .assert_awaited_once_with (
124+ config .url ,
125+ json = task_data .model_dump (mode = 'json' , exclude_none = True ),
126+ headers = {
127+ 'X-A2A-Notification-Token' : 'unique_token' ,
128+ 'Authorization' : 'Bearer token_or_jwt' ,
129+ },
130+ )
131+ mock_response .raise_for_status .assert_called_once ()
132+
95133 async def test_send_notification_no_config (self ) -> None :
96134 task_id = 'task_send_no_config'
97135 task_data = create_sample_task (task_id = task_id )
0 commit comments