Skip to content

Commit 4319ebf

Browse files
committed
Update test_response_mode.py
1 parent a2ac365 commit 4319ebf

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

tests/test_response_mode.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,32 @@ def test_query_mode_get_request_rejected(self):
102102
with AuthCodeReceiver() as receiver:
103103
test_code = "test_auth_code_via_get"
104104

105-
# Try to send auth code via GET (query string)
106-
try:
107-
from urllib.parse import urlencode
108-
except ImportError:
109-
from urllib import urlencode
110-
111-
response = requests.get(
112-
"http://localhost:{}?{}".format(
113-
receiver.get_port(),
114-
urlencode({"code": test_code, "state": "test"})
105+
# Schedule the GET request to be sent after server starts
106+
def send_get_request():
107+
try:
108+
from urllib.parse import urlencode
109+
except ImportError:
110+
from urllib import urlencode
111+
112+
response = requests.get(
113+
"http://localhost:{}?{}".format(
114+
receiver.get_port(),
115+
urlencode({"code": test_code, "state": "test"})
116+
)
115117
)
116-
)
118+
119+
# Verify the GET request is rejected
120+
self.assertEqual(response.status_code, 400, "GET with auth code should be rejected")
121+
self.assertIn("not supported", response.text.lower(),
122+
"Error message should indicate method not supported")
123+
124+
receiver._scheduled_actions = [(1, send_get_request)]
125+
126+
# Start the server (it will timeout after rejecting the GET)
127+
result = receiver.get_auth_response(timeout=3)
117128

118-
# Verify the GET request is rejected
119-
self.assertEqual(response.status_code, 400, "GET with auth code should be rejected")
120-
self.assertIn("not supported", response.text.lower(),
121-
"Error message should indicate method not supported")
129+
# Result should be None because GET was rejected (no auth_response set)
130+
self.assertIsNone(result, "GET request should not produce auth response")
122131

123132

124133
if __name__ == '__main__':

0 commit comments

Comments
 (0)