11import pytest
2+ from typing import Generator , Any
23
34from app .main import app
45
6+ TestClient = Any
7+
58
69@pytest .fixture
7- def client ():
10+ def client () -> Generator [ Any , None , None ] :
811 """Create a test client for the Flask app."""
912 app .config ["TESTING" ] = True
1013 with app .test_client () as client :
1114 yield client
1215
1316
14- def test_health_endpoint (client ) :
17+ def test_health_endpoint (client : TestClient ) -> None :
1518 """Test the health check endpoint."""
1619 response = client .get ("/health" )
1720 assert response .status_code == 200
@@ -21,7 +24,7 @@ def test_health_endpoint(client):
2124 assert json_data ["status" ] == "ok"
2225
2326
24- def test_index_endpoint_without_headers (client ) :
27+ def test_index_endpoint_without_headers (client : TestClient ) -> None :
2528 """Test the index endpoint without client headers."""
2629 response = client .get ("/" )
2730 assert response .status_code == 200
@@ -32,7 +35,7 @@ def test_index_endpoint_without_headers(client):
3235 assert "Device ID: unknown" in text
3336
3437
35- def test_index_endpoint_with_client_subject (client ) :
38+ def test_index_endpoint_with_client_subject (client : TestClient ) -> None :
3639 """Test the index endpoint with X-Client-Subject header."""
3740 headers = {
"X-Client-Subject" :
"[email protected] ,O=Company" }
3841 response = client .get ("/" , headers = headers )
@@ -42,7 +45,7 @@ def test_index_endpoint_with_client_subject(client):
4245 assert "Client cert subject: [email protected] ,O=Company" in text 4346
4447
45- def test_index_endpoint_with_device_id (client ) :
48+ def test_index_endpoint_with_device_id (client : TestClient ) -> None :
4649 """Test the index endpoint with X-Device-ID header."""
4750 headers = {"X-Device-ID" : "laptop-001" }
4851 response = client .get ("/" , headers = headers )
@@ -52,7 +55,7 @@ def test_index_endpoint_with_device_id(client):
5255 assert "Device ID: laptop-001" in text
5356
5457
55- def test_index_endpoint_with_all_headers (client ) :
58+ def test_index_endpoint_with_all_headers (client : TestClient ) -> None :
5659 """Test the index endpoint with all client headers."""
5760 headers = {
5861 "X-Client-Subject" :
"[email protected] ,O=Company,OU=IT" ,
@@ -67,7 +70,7 @@ def test_index_endpoint_with_all_headers(client):
6770 assert "Device ID: workstation-123" in text
6871
6972
70- def test_step_up_endpoint (client ) :
73+ def test_step_up_endpoint (client : TestClient ) -> None :
7174 """Test the step-up authentication endpoint."""
7275 response = client .post ("/step-up" )
7376 assert response .status_code == 202
@@ -77,19 +80,19 @@ def test_step_up_endpoint(client):
7780 assert json_data ["status" ] == "step-up required"
7881
7982
80- def test_step_up_endpoint_wrong_method (client ) :
83+ def test_step_up_endpoint_wrong_method (client : TestClient ) -> None :
8184 """Test step-up endpoint rejects non-POST methods."""
8285 response = client .get ("/step-up" )
8386 assert response .status_code == 405 # Method Not Allowed
8487
8588
86- def test_nonexistent_endpoint (client ) :
89+ def test_nonexistent_endpoint (client : TestClient ) -> None :
8790 """Test that non-existent endpoints return 404."""
8891 response = client .get ("/nonexistent" )
8992 assert response .status_code == 404
9093
9194
92- def test_client_subject_prefix_removal (client ) :
95+ def test_client_subject_prefix_removal (client : TestClient ) -> None :
9396 """Test that Subject= prefix is properly removed from client subject."""
9497 headers = {
"X-Client-Subject" :
"[email protected] " }
9598 response = client .get ("/" , headers = headers )
@@ -101,7 +104,7 @@ def test_client_subject_prefix_removal(client):
101104 assert "[email protected] " not in text 102105
103106
104- def test_client_subject_without_prefix (client ) :
107+ def test_client_subject_without_prefix (client : TestClient ) -> None :
105108 """Test client subject header without Subject= prefix."""
106109 headers = {
"X-Client-Subject" :
"[email protected] " }
107110 response = client .get ("/" , headers = headers )
@@ -111,7 +114,7 @@ def test_client_subject_without_prefix(client):
111114 assert "Client cert subject: [email protected] " in text 112115
113116
114- def test_empty_headers (client ) :
117+ def test_empty_headers (client : TestClient ) -> None :
115118 """Test behavior with empty but present headers."""
116119 headers = {"X-Client-Subject" : "" , "X-Device-ID" : "" }
117120 response = client .get ("/" , headers = headers )
0 commit comments