-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathtest_application_integration_toolset.py
More file actions
738 lines (661 loc) · 23 KB
/
test_application_integration_toolset.py
File metadata and controls
738 lines (661 loc) · 23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from unittest import mock
from fastapi.openapi.models import Operation
from google.adk.agents.readonly_context import ReadonlyContext
from google.adk.auth.auth_credential import AuthCredential
from google.adk.auth.auth_credential import AuthCredentialTypes
from google.adk.auth.auth_credential import OAuth2Auth
from google.adk.tools.application_integration_tool.application_integration_toolset import ApplicationIntegrationToolset
from google.adk.tools.application_integration_tool.integration_connector_tool import IntegrationConnectorTool
from google.adk.tools.openapi_tool.auth.auth_helpers import dict_to_auth_scheme
from google.adk.tools.openapi_tool.openapi_spec_parser import rest_api_tool
from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_spec_parser import OperationEndpoint
from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_spec_parser import ParsedOperation
import pytest
@pytest.fixture
def mock_integration_client():
with mock.patch(
"google.adk.tools.application_integration_tool.application_integration_toolset.IntegrationClient"
) as mock_client:
yield mock_client
@pytest.fixture
def mock_connections_client():
with mock.patch(
"google.adk.tools.application_integration_tool.application_integration_toolset.ConnectionsClient"
) as mock_client:
yield mock_client
@pytest.fixture
def mock_openapi_toolset():
with mock.patch(
"google.adk.tools.application_integration_tool.application_integration_toolset.OpenAPIToolset"
) as mock_toolset:
mock_toolset_instance = mock.MagicMock()
mock_rest_api_tool = mock.MagicMock(spec=rest_api_tool.RestApiTool)
mock_rest_api_tool.name = "Test Tool"
# Create an async mock for the get_tools method
async def mock_get_tools(context: ReadonlyContext = None):
return [mock_rest_api_tool]
# Assign the async mock function to get_tools
mock_toolset_instance.get_tools = mock_get_tools
mock_toolset.return_value = mock_toolset_instance
yield mock_toolset
@pytest.fixture
def mock_openapi_toolset_with_multiple_tools_and_no_tools():
with mock.patch(
"google.adk.tools.application_integration_tool.application_integration_toolset.OpenAPIToolset"
) as mock_toolset:
mock_toolset_instance = mock.MagicMock()
mock_rest_api_tool = mock.MagicMock(spec=rest_api_tool.RestApiTool)
mock_rest_api_tool.name = "Test Tool"
mock_rest_api_tool_2 = mock.MagicMock(spec=rest_api_tool.RestApiTool)
mock_rest_api_tool_2.name = "Test Tool 2"
# Create an async mock for the get_tools method
async def mock_get_tools(context: ReadonlyContext = None):
return [mock_rest_api_tool, mock_rest_api_tool_2]
mock_toolset_instance.get_tools = mock_get_tools
mock_toolset.return_value = mock_toolset_instance
yield mock_toolset
def get_mocked_parsed_operation(operation_id, attributes):
mock_openapi_spec_parser_instance = mock.MagicMock()
mock_parsed_operation = mock.MagicMock(spec=ParsedOperation)
mock_parsed_operation.name = "list_issues"
mock_parsed_operation.description = "list_issues_description"
mock_parsed_operation.endpoint = OperationEndpoint(
base_url="http://localhost:8080",
path="/v1/issues",
method="GET",
)
mock_parsed_operation.auth_scheme = None
mock_parsed_operation.auth_credential = None
mock_parsed_operation.additional_context = {}
mock_parsed_operation.parameters = []
mock_operation = mock.MagicMock(spec=Operation)
mock_operation.operationId = operation_id
mock_operation.description = "list_issues_description"
mock_operation.parameters = []
mock_operation.requestBody = None
mock_operation.responses = {}
mock_operation.callbacks = {}
for key, value in attributes.items():
setattr(mock_operation, key, value)
mock_parsed_operation.operation = mock_operation
mock_openapi_spec_parser_instance.parse.return_value = [mock_parsed_operation]
return mock_openapi_spec_parser_instance
@pytest.fixture
def mock_openapi_entity_spec_parser():
with mock.patch(
"google.adk.tools.application_integration_tool.application_integration_toolset.OpenApiSpecParser"
) as mock_spec_parser:
mock_openapi_spec_parser_instance = get_mocked_parsed_operation(
"list_issues", {"x-entity": "Issues", "x-operation": "LIST_ENTITIES"}
)
mock_spec_parser.return_value = mock_openapi_spec_parser_instance
yield mock_spec_parser
@pytest.fixture
def mock_openapi_action_spec_parser():
with mock.patch(
"google.adk.tools.application_integration_tool.application_integration_toolset.OpenApiSpecParser"
) as mock_spec_parser:
mock_openapi_action_spec_parser_instance = get_mocked_parsed_operation(
"list_issues_operation",
{"x-action": "CustomAction", "x-operation": "EXECUTE_ACTION"},
)
mock_spec_parser.return_value = mock_openapi_action_spec_parser_instance
yield mock_spec_parser
@pytest.fixture
def project():
return "test-project"
@pytest.fixture
def location():
return "us-central1"
@pytest.fixture
def integration_spec():
return {"openapi": "3.0.0", "info": {"title": "Integration API"}}
@pytest.fixture
def connection_spec():
return {"openapi": "3.0.0", "info": {"title": "Connection API"}}
@pytest.fixture
def connection_details():
return {
"serviceName": "test-service",
"host": "test.host",
"name": "test-connection",
}
@pytest.fixture
def connection_details_auth_override_enabled():
return {
"serviceName": "test-service",
"host": "test.host",
"name": "test-connection",
"authOverrideEnabled": True,
}
@pytest.mark.asyncio
async def test_initialization_with_integration_and_trigger(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_toolset,
):
integration_name = "test-integration"
triggers = ["test-trigger"]
toolset = ApplicationIntegrationToolset(
project, location, integration=integration_name, triggers=triggers
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
integration_name,
triggers,
None,
None,
None,
None,
)
mock_integration_client.return_value.get_openapi_spec_for_integration.assert_called_once()
mock_connections_client.assert_not_called()
mock_openapi_toolset.assert_called_once()
tools = await toolset.get_tools()
assert len(tools) == 1
assert tools[0].name == "Test Tool"
@pytest.mark.asyncio
async def test_initialization_with_integration_and_list_of_triggers(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_toolset_with_multiple_tools_and_no_tools,
):
integration_name = "test-integration"
triggers = ["test-trigger1", "test-trigger2"]
toolset = ApplicationIntegrationToolset(
project, location, integration=integration_name, triggers=triggers
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
integration_name,
triggers,
None,
None,
None,
None,
)
mock_integration_client.return_value.get_openapi_spec_for_integration.assert_called_once()
mock_connections_client.assert_not_called()
mock_openapi_toolset_with_multiple_tools_and_no_tools.assert_called_once()
tools = await toolset.get_tools()
assert len(tools) == 2
assert tools[0].name == "Test Tool"
assert tools[1].name == "Test Tool 2"
@pytest.mark.asyncio
async def test_initialization_with_integration_and_empty_trigger_list(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_toolset_with_multiple_tools_and_no_tools,
):
integration_name = "test-integration"
toolset = ApplicationIntegrationToolset(
project, location, integration=integration_name
)
mock_integration_client.assert_called_once_with(
project, location, None, integration_name, None, None, None, None, None
)
mock_integration_client.return_value.get_openapi_spec_for_integration.assert_called_once()
mock_connections_client.assert_not_called()
mock_openapi_toolset_with_multiple_tools_and_no_tools.assert_called_once()
tools = await toolset.get_tools()
assert len(tools) == 2
assert tools[0].name == "Test Tool"
assert tools[1].name == "Test Tool 2"
@pytest.mark.asyncio
async def test_initialization_with_connection_and_entity_operations(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_entity_spec_parser,
connection_details,
):
connection_name = "test-connection"
entity_operations_list = ["list", "get"]
tool_name = "My Connection Tool"
tool_instructions = "Use this tool to manage entities."
mock_connections_client.return_value.get_connection_details.return_value = (
connection_details
)
toolset = ApplicationIntegrationToolset(
project,
location,
connection=connection_name,
entity_operations=entity_operations_list,
tool_name_prefix=tool_name,
tool_instructions=tool_instructions,
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
None,
None,
connection_name,
entity_operations_list,
None,
None,
)
mock_connections_client.assert_called_once_with(
project, location, connection_name, None
)
mock_openapi_entity_spec_parser.return_value.parse.assert_called_once()
mock_connections_client.return_value.get_connection_details.assert_called_once()
mock_integration_client.return_value.get_openapi_spec_for_connection.assert_called_once_with(
tool_name,
tool_instructions,
)
tools = await toolset.get_tools()
assert len(tools) == 1
assert tools[0].name == "list_issues"
assert isinstance(tools[0], IntegrationConnectorTool)
assert tools[0]._entity == "Issues"
assert tools[0]._operation == "LIST_ENTITIES"
@pytest.mark.asyncio
async def test_initialization_with_connection_and_actions(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_action_spec_parser,
connection_details,
):
connection_name = "test-connection"
actions_list = ["create", "delete"]
tool_name = "My Actions Tool"
tool_instructions = "Perform actions using this tool."
mock_connections_client.return_value.get_connection_details.return_value = (
connection_details
)
toolset = ApplicationIntegrationToolset(
project,
location,
connection=connection_name,
actions=actions_list,
tool_name_prefix=tool_name,
tool_instructions=tool_instructions,
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
None,
None,
connection_name,
None,
actions_list,
None,
)
mock_connections_client.assert_called_once_with(
project, location, connection_name, None
)
mock_connections_client.return_value.get_connection_details.assert_called_once()
mock_integration_client.return_value.get_openapi_spec_for_connection.assert_called_once_with(
tool_name, tool_instructions
)
mock_openapi_action_spec_parser.return_value.parse.assert_called_once()
tools = await toolset.get_tools()
assert len(tools) == 1
assert tools[0].name == "list_issues_operation"
assert isinstance(tools[0], IntegrationConnectorTool)
assert tools[0]._action == "CustomAction"
assert tools[0]._operation == "EXECUTE_ACTION"
def test_initialization_without_required_params(project, location):
with pytest.raises(
ValueError,
match=(
"Invalid request, Either integration or \\(connection and"
" \\(entity_operations or actions\\)\\) should be provided."
),
):
ApplicationIntegrationToolset(project, location)
with pytest.raises(
ValueError,
match=(
"Invalid request, Either integration or \\(connection and"
" \\(entity_operations or actions\\)\\) should be provided."
),
):
ApplicationIntegrationToolset(project, location, triggers=["test"])
with pytest.raises(
ValueError,
match=(
"Invalid request, Either integration or \\(connection and"
" \\(entity_operations or actions\\)\\) should be provided."
),
):
ApplicationIntegrationToolset(project, location, connection="test")
def test_initialization_with_service_account_credentials(
project, location, mock_integration_client, mock_openapi_toolset
):
service_account_json = json.dumps({
"type": "service_account",
"project_id": "dummy",
"private_key_id": "dummy",
"private_key": "dummy",
"client_email": "test@example.com",
"client_id": "131331543646416",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": (
"https://www.googleapis.com/oauth2/v1/certs"
),
"client_x509_cert_url": (
"http://www.googleapis.com/robot/v1/metadata/x509/dummy%40dummy.com"
),
"universe_domain": "googleapis.com",
})
integration_name = "test-integration"
triggers = ["test-trigger"]
toolset = ApplicationIntegrationToolset(
project,
location,
integration=integration_name,
triggers=triggers,
service_account_json=service_account_json,
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
integration_name,
triggers,
None,
None,
None,
service_account_json,
)
mock_openapi_toolset.assert_called_once()
_, kwargs = mock_openapi_toolset.call_args
assert isinstance(kwargs["auth_credential"], AuthCredential)
assert (
kwargs[
"auth_credential"
].service_account.service_account_credential.client_email
== "test@example.com"
)
def test_initialization_without_explicit_service_account_credentials(
project, location, mock_integration_client, mock_openapi_toolset
):
integration_name = "test-integration"
triggers = "test-trigger"
toolset = ApplicationIntegrationToolset(
project, location, integration=integration_name, triggers=triggers
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
integration_name,
triggers,
None,
None,
None,
None,
)
mock_openapi_toolset.assert_called_once()
_, kwargs = mock_openapi_toolset.call_args
assert isinstance(kwargs["auth_credential"], AuthCredential)
assert kwargs["auth_credential"].service_account.use_default_credential
@pytest.mark.asyncio
async def test_get_tools(
project, location, mock_integration_client, mock_openapi_toolset
):
integration_name = "test-integration"
triggers = ["test-trigger"]
toolset = ApplicationIntegrationToolset(
project, location, integration=integration_name, triggers=triggers
)
tools = await toolset.get_tools()
assert len(tools) == 1
assert isinstance(tools[0], rest_api_tool.RestApiTool)
assert tools[0].name == "Test Tool"
def test_initialization_with_connection_details(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_toolset,
):
connection_name = "test-connection"
entity_operations_list = ["list"]
tool_name = "My Connection Tool"
tool_instructions = "Use this tool."
mock_connections_client.return_value.get_connection_details.return_value = {
"serviceName": "custom-service",
"host": "custom.host",
}
toolset = ApplicationIntegrationToolset(
project,
location,
connection=connection_name,
entity_operations=entity_operations_list,
tool_name_prefix=tool_name,
tool_instructions=tool_instructions,
)
mock_integration_client.return_value.get_openapi_spec_for_connection.assert_called_once_with(
tool_name, tool_instructions
)
@pytest.mark.asyncio
async def test_init_with_connection_and_custom_auth(
mock_integration_client,
mock_connections_client,
mock_openapi_action_spec_parser,
connection_details_auth_override_enabled,
):
connection_name = "test-connection"
actions_list = ["create", "delete"]
tool_name = "My Actions Tool"
tool_instructions = "Perform actions using this tool."
mock_connections_client.return_value.get_connection_details.return_value = (
connection_details_auth_override_enabled
)
oauth2_data_google_cloud = {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://test-url/o/oauth2/auth",
"tokenUrl": "https://test-url/token",
"scopes": {
"https://test-url/auth/test-scope": "test scope",
"https://www.test-url.com/auth/test-scope2": "test scope 2",
},
}
},
}
oauth2_scheme = dict_to_auth_scheme(oauth2_data_google_cloud)
auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
client_id="test-client-id",
client_secret="test-client-secret",
),
)
toolset = ApplicationIntegrationToolset(
project,
location,
connection=connection_name,
actions=actions_list,
tool_name_prefix=tool_name,
tool_instructions=tool_instructions,
auth_scheme=oauth2_scheme,
auth_credential=auth_credential,
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
None,
None,
connection_name,
None,
actions_list,
None,
)
mock_connections_client.assert_called_once_with(
project, location, connection_name, None
)
mock_connections_client.return_value.get_connection_details.assert_called_once()
mock_integration_client.return_value.get_openapi_spec_for_connection.assert_called_once_with(
tool_name, tool_instructions
)
mock_openapi_action_spec_parser.return_value.parse.assert_called_once()
assert len(await toolset.get_tools()) == 1
assert (await toolset.get_tools())[0].name == "list_issues_operation"
assert isinstance((await toolset.get_tools())[0], IntegrationConnectorTool)
assert (await toolset.get_tools())[0]._action == "CustomAction"
assert (await toolset.get_tools())[0]._operation == "EXECUTE_ACTION"
assert (await toolset.get_tools())[0]._auth_scheme == oauth2_scheme
assert (await toolset.get_tools())[0]._auth_credential == auth_credential
@pytest.mark.asyncio
async def test_init_with_connection_with_auth_override_disabled_and_custom_auth(
mock_integration_client,
mock_connections_client,
mock_openapi_action_spec_parser,
connection_details,
):
connection_name = "test-connection"
actions_list = ["create", "delete"]
tool_name = "My Actions Tool"
tool_instructions = "Perform actions using this tool."
mock_connections_client.return_value.get_connection_details.return_value = (
connection_details
)
oauth2_data_google_cloud = {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://test-url/o/oauth2/auth",
"tokenUrl": "https://test-url/token",
"scopes": {
"https://test-url/auth/test-scope": "test scope",
"https://www.test-url.com/auth/test-scope2": "test scope 2",
},
}
},
}
oauth2_scheme = dict_to_auth_scheme(oauth2_data_google_cloud)
auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
client_id="test-client-id",
client_secret="test-client-secret",
),
)
toolset = ApplicationIntegrationToolset(
project,
location,
connection=connection_name,
actions=actions_list,
tool_name_prefix=tool_name,
tool_instructions=tool_instructions,
auth_scheme=oauth2_scheme,
auth_credential=auth_credential,
)
mock_integration_client.assert_called_once_with(
project,
location,
None,
None,
None,
connection_name,
None,
actions_list,
None,
)
mock_connections_client.assert_called_once_with(
project, location, connection_name, None
)
mock_connections_client.return_value.get_connection_details.assert_called_once()
mock_integration_client.return_value.get_openapi_spec_for_connection.assert_called_once_with(
tool_name, tool_instructions
)
mock_openapi_action_spec_parser.return_value.parse.assert_called_once()
assert len(await toolset.get_tools()) == 1
assert (await toolset.get_tools())[0].name == "list_issues_operation"
assert isinstance((await toolset.get_tools())[0], IntegrationConnectorTool)
assert (await toolset.get_tools())[0]._action == "CustomAction"
assert (await toolset.get_tools())[0]._operation == "EXECUTE_ACTION"
assert not (await toolset.get_tools())[0]._auth_scheme
assert not (await toolset.get_tools())[0]._auth_credential
@pytest.mark.asyncio
async def test_get_tools_uses_exchanged_auth_credential_when_available(
project,
location,
mock_integration_client,
mock_connections_client,
mock_openapi_action_spec_parser,
connection_details_auth_override_enabled,
):
connection_name = "test-connection"
actions_list = ["create"]
mock_connections_client.return_value.get_connection_details.return_value = (
connection_details_auth_override_enabled
)
oauth2_data_google_cloud = {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://test-url/o/oauth2/auth",
"tokenUrl": "https://test-url/token",
"scopes": {
"https://test-url/auth/test-scope": "test scope",
},
}
},
}
oauth2_scheme = dict_to_auth_scheme(oauth2_data_google_cloud)
raw_auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
client_id="test-client-id",
client_secret="test-client-secret",
),
)
toolset = ApplicationIntegrationToolset(
project,
location,
connection=connection_name,
actions=actions_list,
auth_scheme=oauth2_scheme,
auth_credential=raw_auth_credential,
)
exchanged_auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
client_id="test-client-id",
client_secret="test-client-secret",
access_token="exchanged-access-token",
),
)
toolset._auth_config.exchanged_auth_credential = exchanged_auth_credential
original_tool = toolset._tools[0]
tools = await toolset.get_tools()
assert len(tools) == 1
assert tools[0] is not original_tool
assert tools[0]._auth_credential == exchanged_auth_credential
assert original_tool._auth_credential == raw_auth_credential