Skip to content

Commit d2bf85b

Browse files
committed
refactor(knowledgebase): 添加STS token支持并优化代码格式
本次提交主要完成了以下改进: 1. 在多个数据API类中添加了STS token的支持 2. 对长参数列表进行了适当的换行处理,提高代码可读性 3. 更新相关单元测试以验证新的STS token功能 这些改动增强了系统的安全性和灵活性,同时保持了良好的代码风格。 Co-developed-by: Aone Copilot <noreply@alibaba-inc.com> Signed-off-by: Sodawyx <sodawyx@126.com>
1 parent f8318f7 commit d2bf85b

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

agentrun/knowledgebase/api/__data_async_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ def _build_agent_storage_client(
595595
return AgentStorageClient(
596596
access_key_id=cfg.get_access_key_id(),
597597
access_key_secret=cfg.get_access_key_secret(),
598+
sts_token=cfg.get_security_token(),
598599
ots_endpoint=ots_endpoint,
599600
ots_instance_name=self.provider_settings.ots_instance_name,
600601
)

agentrun/knowledgebase/api/data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ def _build_agent_storage_client(
854854
return AgentStorageClient(
855855
access_key_id=cfg.get_access_key_id(),
856856
access_key_secret=cfg.get_access_key_secret(),
857+
sts_token=cfg.get_security_token(),
857858
ots_endpoint=ots_endpoint,
858859
ots_instance_name=self.provider_settings.ots_instance_name,
859860
)

tests/unittests/knowledgebase/test_ots_knowledgebase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ def test_build_client(self, mock_client_class):
600600
mock_config.get_region_id.return_value = "cn-hangzhou"
601601
mock_config.get_access_key_id.return_value = "test-ak"
602602
mock_config.get_access_key_secret.return_value = "test-sk"
603+
mock_config.get_security_token.return_value = "test-sts"
603604

604605
with patch.object(Config, "with_configs", return_value=mock_config):
605606
api = OTSDataAPI(
@@ -613,6 +614,7 @@ def test_build_client(self, mock_client_class):
613614
mock_client_class.assert_called_once_with(
614615
access_key_id="test-ak",
615616
access_key_secret="test-sk",
617+
sts_token="test-sts",
616618
ots_endpoint="http://ots-cn-hangzhou.aliyuncs.com",
617619
ots_instance_name="test-instance",
618620
)

0 commit comments

Comments
 (0)