1717import threading
1818import time
1919from http .server import BaseHTTPRequestHandler , HTTPServer
20- from typing import Dict , Any , Optional
21- from urllib .parse import parse_qs , urlparse , urlencode
20+ from typing import Any , Optional
21+ from urllib .parse import parse_qs , urlencode , urlparse
2222
2323
2424class MockOAuthServer :
@@ -38,9 +38,9 @@ def __init__(self, host: str = "localhost", port: int = 9999):
3838 self .base_url = f"http://{ host } :{ port } "
3939
4040 # Storage for active flows
41- self .auth_codes : Dict [str , Dict [str , Any ]] = {}
42- self .device_codes : Dict [str , Dict [str , Any ]] = {}
43- self .tokens : Dict [str , Dict [str , Any ]] = {}
41+ self .auth_codes : dict [str , dict [str , Any ]] = {}
42+ self .device_codes : dict [str , dict [str , Any ]] = {}
43+ self .tokens : dict [str , dict [str , Any ]] = {}
4444
4545 # Configuration
4646 self .issuer = self .base_url
@@ -135,7 +135,7 @@ def _handle_openshift_discovery(self):
135135 }
136136 self ._send_json (200 , discovery )
137137
138- def _handle_authorize (self , params : Dict [str , list ]):
138+ def _handle_authorize (self , params : dict [str , list ]):
139139 """Handle authorization request."""
140140 client_id = params .get ("client_id" , ["" ])[0 ]
141141 redirect_uri = params .get ("redirect_uri" , ["" ])[0 ]
@@ -171,7 +171,7 @@ def _handle_authorize(self, params: Dict[str, list]):
171171 # Return approval page (for manual testing)
172172 self ._send_html (200 , "<h1>Approval Page</h1><p>Auto-approve is disabled</p>" )
173173
174- def _handle_token (self , params : Dict [str , list ]):
174+ def _handle_token (self , params : dict [str , list ]):
175175 """Handle token endpoint requests."""
176176 grant_type = params .get ("grant_type" , ["" ])[0 ]
177177 client_id = params .get ("client_id" , ["" ])[0 ]
@@ -188,10 +188,10 @@ def _handle_token(self, params: Dict[str, list]):
188188 "error_description" : f"Grant type '{ grant_type } ' is not supported"
189189 })
190190
191- def _handle_token_auth_code (self , params : Dict [str , list ], client_id : str ):
191+ def _handle_token_auth_code (self , params : dict [str , list ], client_id : str ):
192192 """Handle authorization code grant."""
193193 code = params .get ("code" , ["" ])[0 ]
194- redirect_uri = params .get ("redirect_uri" , ["" ])[0 ]
194+ params .get ("redirect_uri" , ["" ])[0 ]
195195 code_verifier = params .get ("code_verifier" , ["" ])[0 ]
196196
197197 # Validate auth code
@@ -259,7 +259,7 @@ def _handle_token_auth_code(self, params: Dict[str, list], client_id: str):
259259 "scope" : "openid profile email"
260260 })
261261
262- def _handle_token_refresh (self , params : Dict [str , list ], client_id : str ):
262+ def _handle_token_refresh (self , params : dict [str , list ], client_id : str ):
263263 """Handle refresh token grant."""
264264 refresh_token = params .get ("refresh_token" , ["" ])[0 ]
265265
@@ -285,7 +285,7 @@ def _handle_token_refresh(self, params: Dict[str, list], client_id: str):
285285 "scope" : "openid profile email"
286286 })
287287
288- def _handle_device_code (self , params : Dict [str , list ]):
288+ def _handle_device_code (self , params : dict [str , list ]):
289289 """Handle device code request."""
290290 client_id = params .get ("client_id" , ["" ])[0 ]
291291
@@ -308,7 +308,7 @@ def _handle_device_code(self, params: Dict[str, list]):
308308 "interval" : 1 # Fast polling for tests
309309 })
310310
311- def _handle_token_device_code (self , params : Dict [str , list ], client_id : str ):
311+ def _handle_token_device_code (self , params : dict [str , list ], client_id : str ):
312312 """Handle device code token request (polling)."""
313313 device_code = params .get ("device_code" , ["" ])[0 ]
314314
0 commit comments