11import pytest
2+
3+ from socketsecurity import socketcli
24from socketsecurity .config import CliConfig
35
6+
47class TestCliConfig :
58 def test_api_token_from_env (self , monkeypatch ):
69 monkeypatch .setenv ("SOCKET_SECURITY_API_KEY" , "test-token" )
@@ -81,4 +84,25 @@ def test_workspace_is_independent_of_workspace_name(self):
8184 "--workspace-name" , "monorepo-suffix" ,
8285 ])
8386 assert config .workspace == "my-workspace"
84- assert config .workspace_name == "monorepo-suffix"
87+ assert config .workspace_name == "monorepo-suffix"
88+
89+ def test_api_request_timeout_defaults_to_twenty_minutes (self ):
90+ config = CliConfig .from_args (["--api-token" , "test" ])
91+ assert socketcli .get_api_request_timeout (config ) == 1200
92+
93+ def test_socket_sdk_receives_cli_timeout (self , monkeypatch ):
94+ captured = {}
95+
96+ def fake_socketdev (** kwargs ):
97+ captured .update (kwargs )
98+ return object ()
99+
100+ monkeypatch .setattr (socketcli , "socketdev" , fake_socketdev )
101+ config = CliConfig .from_args (["--api-token" , "test" , "--timeout" , "1800" ])
102+
103+ socketcli .build_socket_sdk (config )
104+
105+ assert captured ["token" ] == "test"
106+ assert captured ["timeout" ] == 1800
107+ assert captured ["allow_unverified" ] is False
108+ assert captured ["user_agent" ] == f"SocketPythonCLI/{ config .version } "
0 commit comments