1111from uipath_langchain .chat .bedrock import (
1212 AwsBedrockCompletionsPassthroughClient ,
1313 UiPathChatBedrock ,
14+ UiPathChatBedrockConverse ,
1415)
1516
1617
1718class TestGetClientSkipsImds :
18- def test_client_creation_does_not_trigger_credential_resolution (self , caplog ):
19+ def _assert_no_credential_resolution (self , caplog , client ):
20+ assert caplog .records
21+ credential_log_records = [
22+ r for r in caplog .records if r .name .startswith ("botocore.credentials" )
23+ ]
24+ assert not credential_log_records , (
25+ f"Unexpected credential resolution: { [r .getMessage () for r in credential_log_records ]} "
26+ )
27+ assert client ._request_signer ._signature_version == botocore .UNSIGNED
28+
29+ def test_get_client_does_not_trigger_credential_resolution (self , caplog ):
1930 passthrough = AwsBedrockCompletionsPassthroughClient (
2031 model = "anthropic.claude-haiku-4-5-20251001" ,
2132 token = "test-token" ,
@@ -25,14 +36,65 @@ def test_client_creation_does_not_trigger_credential_resolution(self, caplog):
2536 with caplog .at_level (logging .DEBUG , logger = "botocore" ):
2637 client = passthrough .get_client ()
2738
39+ self ._assert_no_credential_resolution (caplog , client )
40+
41+ def test_get_bedrock_client_does_not_trigger_credential_resolution (self , caplog ):
42+ passthrough = AwsBedrockCompletionsPassthroughClient (
43+ model = "anthropic.claude-haiku-4-5-20251001" ,
44+ token = "test-token" ,
45+ api_flavor = "converse" ,
46+ )
47+
48+ with caplog .at_level (logging .DEBUG , logger = "botocore" ):
49+ client = passthrough .get_bedrock_client ()
50+
51+ self ._assert_no_credential_resolution (caplog , client )
52+
53+ @patch .dict (
54+ os .environ ,
55+ {
56+ "UIPATH_URL" : "https://example.com" ,
57+ "UIPATH_ORGANIZATION_ID" : "org" ,
58+ "UIPATH_TENANT_ID" : "tenant" ,
59+ "UIPATH_ACCESS_TOKEN" : "token" ,
60+ },
61+ )
62+ def test_uipath_chat_bedrock_converse_init_does_not_trigger_credential_resolution (
63+ self , caplog
64+ ):
65+ with caplog .at_level (logging .DEBUG , logger = "botocore" ):
66+ UiPathChatBedrockConverse ()
67+
68+ assert caplog .records
69+ credential_log_records = [
70+ r for r in caplog .records if r .name .startswith ("botocore.credentials" )
71+ ]
72+ assert not credential_log_records , (
73+ f"Unexpected credential resolution: { [r .getMessage () for r in credential_log_records ]} "
74+ )
75+
76+ @patch .dict (
77+ os .environ ,
78+ {
79+ "UIPATH_URL" : "https://example.com" ,
80+ "UIPATH_ORGANIZATION_ID" : "org" ,
81+ "UIPATH_TENANT_ID" : "tenant" ,
82+ "UIPATH_ACCESS_TOKEN" : "token" ,
83+ },
84+ )
85+ def test_uipath_chat_bedrock_init_does_not_trigger_credential_resolution (
86+ self , caplog
87+ ):
88+ with caplog .at_level (logging .DEBUG , logger = "botocore" ):
89+ UiPathChatBedrock ()
90+
2891 assert caplog .records
2992 credential_log_records = [
3093 r for r in caplog .records if r .name .startswith ("botocore.credentials" )
3194 ]
3295 assert not credential_log_records , (
3396 f"Unexpected credential resolution: { [r .getMessage () for r in credential_log_records ]} "
3497 )
35- assert client ._request_signer ._signature_version == botocore .UNSIGNED
3698
3799
38100class TestConvertFileBlocksToAnthropicDocuments :
0 commit comments