File tree Expand file tree Collapse file tree 5 files changed +18
-6
lines changed
Expand file tree Collapse file tree 5 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ exceptiongroup==1.2.2
1616fastapi == 0.115.12
1717google-auth == 2.35.0
1818greenlet == 3.1.1
19+ httpcore == 1.0.9
1920h11 == 0.16.0
2021idna == 3.10
2122importlib_metadata == 8.5.0
Original file line number Diff line number Diff line change 11import pathlib
2+ import ssl
23from typing import AsyncGenerator , Optional
34
45import httpx
56import pytest
67from app .config import Settings
78from motor .motor_asyncio import AsyncIOMotorClient , AsyncIOMotorDatabase
89
10+
11+ def create_test_ssl_context () -> ssl .SSLContext :
12+ context = ssl .create_default_context ()
13+ context .check_hostname = False
14+ context .verify_mode = ssl .CERT_NONE
15+ return context
16+
917ENV_FILE_PATH = pathlib .Path (__file__ ).parent / '.env.test'
1018
1119@pytest .fixture (scope = "function" )
1220async def client () -> AsyncGenerator [httpx .AsyncClient , None ]:
1321 backend_service_url = "https://localhost:443"
1422 async with httpx .AsyncClient (
1523 base_url = backend_service_url ,
16- verify = False ,
24+ verify = create_test_ssl_context () ,
1725 timeout = 30.0
1826 ) as async_client :
1927 try :
Original file line number Diff line number Diff line change 44from app .schemas .user import UserCreate
55from httpx import AsyncClient
66from motor .motor_asyncio import AsyncIOMotorDatabase
7+ from tests .conftest import create_test_ssl_context
78
89
910@pytest .mark .integration
@@ -119,7 +120,7 @@ async def test_verify_token_invalid_token(self) -> None:
119120 """Verify an invalid/malformed token fails."""
120121 async with httpx .AsyncClient (
121122 base_url = "https://localhost:443" ,
122- verify = False ,
123+ verify = create_test_ssl_context () ,
123124 timeout = 30.0
124125 ) as new_client :
125126 response = await new_client .get ("/api/v1/verify-token" )
@@ -130,7 +131,7 @@ async def test_verify_token_no_token(self) -> None:
130131 """Verify request fails without token."""
131132 async with httpx .AsyncClient (
132133 base_url = "https://localhost:443" ,
133- verify = False ,
134+ verify = create_test_ssl_context () ,
134135 timeout = 30.0
135136 ) as new_client :
136137 response = await new_client .get ("/api/v1/verify-token" )
Original file line number Diff line number Diff line change 55from app .schemas .user import UserCreate
66from httpx import AsyncClient , HTTPStatusError
77from motor .motor_asyncio import AsyncIOMotorDatabase
8+ from tests .conftest import create_test_ssl_context
89
910POLL_INTERVAL = 2 # seconds
1011EXECUTION_TIMEOUT = 120 # seconds
@@ -147,7 +148,7 @@ async def test_execute_endpoint_without_auth(self) -> None:
147148 """Test accessing execute endpoint without authentication (should succeed)."""
148149 async with httpx .AsyncClient (
149150 base_url = "https://localhost:443" ,
150- verify = False ,
151+ verify = create_test_ssl_context () ,
151152 timeout = 30.0
152153 ) as new_client :
153154 execution_request = {"script" : "print('no auth test should pass')" }
@@ -163,7 +164,7 @@ async def test_result_endpoint_without_auth(self) -> None:
163164 import httpx
164165 async with httpx .AsyncClient (
165166 base_url = "https://localhost:443" ,
166- verify = False ,
167+ verify = create_test_ssl_context () ,
167168 timeout = 30.0
168169 ) as new_client :
169170 non_existent_id = "nonexistent-public-id-999"
Original file line number Diff line number Diff line change 44from app .schemas .user import UserCreate
55from httpx import AsyncClient
66from motor .motor_asyncio import AsyncIOMotorDatabase
7+ from tests .conftest import create_test_ssl_context
78
89
910@pytest .mark .integration
@@ -134,7 +135,7 @@ async def test_scripts_endpoints_without_auth(self) -> None:
134135 """Test accessing scripts endpoints without authentication."""
135136 async with httpx .AsyncClient (
136137 base_url = "https://localhost:443" ,
137- verify = False ,
138+ verify = create_test_ssl_context () ,
138139 timeout = 30.0
139140 ) as new_client :
140141 script_data = {"name" : "No Auth" , "script" : "print('no')" }
You can’t perform that action at this time.
0 commit comments