|
9 | 9 | from pygitguardian import GGClient |
10 | 10 | from pygitguardian.models import APITokensResponse, Detail, TokenScope |
11 | 11 |
|
12 | | -from ggshield.core.client import check_client_api_key, create_client_from_config |
| 12 | +from ggshield.core.client import ( |
| 13 | + check_client_api_key, |
| 14 | + create_client_from_config, |
| 15 | + create_session, |
| 16 | +) |
13 | 17 | from ggshield.core.config import Config |
14 | 18 | from ggshield.core.errors import ( |
15 | 19 | APIKeyCheckError, |
@@ -239,3 +243,37 @@ def test_retrieve_client_unknown_custom_dashboard_url(isolated_fs: FakeFilesyste |
239 | 243 | config = Config() |
240 | 244 | config.cmdline_instance_name = "https://example.com" |
241 | 245 | create_client_from_config(config) |
| 246 | + |
| 247 | + |
| 248 | +def test_create_session_pool_configuration(): |
| 249 | + """ |
| 250 | + GIVEN create_session is called |
| 251 | + WHEN the session is created |
| 252 | + THEN the HTTPAdapter has the correct pool configuration |
| 253 | + """ |
| 254 | + session = create_session() |
| 255 | + |
| 256 | + adapter = session.get_adapter("https://example.com") |
| 257 | + |
| 258 | + # Verify pool configuration by checking the init parameters |
| 259 | + assert getattr(adapter, "_pool_maxsize", None) == 100 |
| 260 | + |
| 261 | + |
| 262 | +@pytest.mark.parametrize("allow_self_signed", [True, False]) |
| 263 | +def test_create_session_with_self_signed_option(allow_self_signed: bool): |
| 264 | + """ |
| 265 | + GIVEN create_session is called with allow_self_signed parameter |
| 266 | + WHEN the session is created |
| 267 | + THEN HTTPAdapter is mounted regardless of allow_self_signed value |
| 268 | + AND verify is set correctly |
| 269 | + """ |
| 270 | + session = create_session(allow_self_signed=allow_self_signed) |
| 271 | + |
| 272 | + # Verify adapters are mounted |
| 273 | + assert "https://" in session.adapters |
| 274 | + |
| 275 | + # Verify SSL verification setting |
| 276 | + if allow_self_signed: |
| 277 | + assert session.verify is False |
| 278 | + else: |
| 279 | + assert session.verify is True |
0 commit comments