diff --git a/packages/toolbox-core/src/toolbox_core/tool.py b/packages/toolbox-core/src/toolbox_core/tool.py index 98d04e17..5a9bca6e 100644 --- a/packages/toolbox-core/src/toolbox_core/tool.py +++ b/packages/toolbox-core/src/toolbox_core/tool.py @@ -239,7 +239,7 @@ async def __call__(self, *args: Any, **kwargs: Any) -> str: for s in self.__required_authn_params.values(): req_auth_services.update(s) req_auth_services.update(self.__required_authz_tokens) - raise ValueError( + raise PermissionError( f"One or more of the following authn services are required to invoke this tool" f": {','.join(req_auth_services)}" ) diff --git a/packages/toolbox-core/tests/test_e2e.py b/packages/toolbox-core/tests/test_e2e.py index c8111b6f..8920bc3b 100644 --- a/packages/toolbox-core/tests/test_e2e.py +++ b/packages/toolbox-core/tests/test_e2e.py @@ -147,7 +147,7 @@ async def test_run_tool_no_auth(self, toolbox: ToolboxClient): """Tests running a tool requiring auth without providing auth.""" tool = await toolbox.load_tool("get-row-by-id-auth") with pytest.raises( - Exception, + PermissionError, match="One or more of the following authn services are required to invoke this tool: my-test-auth", ): await tool(id="2") @@ -188,7 +188,7 @@ async def test_run_tool_param_auth_no_auth(self, toolbox: ToolboxClient): """Tests running a tool with a param requiring auth, without auth.""" tool = await toolbox.load_tool("get-row-by-email-auth") with pytest.raises( - ValueError, + PermissionError, match="One or more of the following authn services are required to invoke this tool: my-test-auth", ): await tool() diff --git a/packages/toolbox-core/tests/test_sync_client.py b/packages/toolbox-core/tests/test_sync_client.py index 4b43e466..28f2b27b 100644 --- a/packages/toolbox-core/tests/test_sync_client.py +++ b/packages/toolbox-core/tests/test_sync_client.py @@ -541,7 +541,7 @@ def test_auth_with_load_tool_fail_no_token( tool = sync_client.load_tool(tool_name_auth) with pytest.raises( - ValueError, + PermissionError, match="One or more of the following authn services are required to invoke this tool: my-auth-service", ): tool(argA=15, argB=True) diff --git a/packages/toolbox-core/tests/test_sync_e2e.py b/packages/toolbox-core/tests/test_sync_e2e.py index 885724e9..f2730e47 100644 --- a/packages/toolbox-core/tests/test_sync_e2e.py +++ b/packages/toolbox-core/tests/test_sync_e2e.py @@ -129,7 +129,7 @@ def test_run_tool_no_auth(self, toolbox: ToolboxSyncClient): """Tests running a tool requiring auth without providing auth.""" tool = toolbox.load_tool("get-row-by-id-auth") with pytest.raises( - Exception, + PermissionError, match="One or more of the following authn services are required to invoke this tool: my-test-auth", ): tool(id="2") @@ -156,7 +156,7 @@ def test_run_tool_param_auth_no_auth(self, toolbox: ToolboxSyncClient): """Tests running a tool with a param requiring auth, without auth.""" tool = toolbox.load_tool("get-row-by-email-auth") with pytest.raises( - ValueError, + PermissionError, match="One or more of the following authn services are required to invoke this tool: my-test-auth", ): tool()