Skip to content

Commit b4eb356

Browse files
committed
Add a few tests for cookie handling (ht/ @dobe)
1 parent d5397b6 commit b4eb356

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/http/mockserver.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ def do_GET(self):
7979
self.send_header('Duplicate', 'Si!')
8080
self.end_headers()
8181
self.finish()
82+
elif self.path == '/set_cookie':
83+
self.send_response(200, 'OK')
84+
self.send_header('Set-Cookie', 'cookie_monster=happy')
85+
self.wfile.write("The cookie has been set.")
86+
self.end_headers()
87+
self.finish()
88+
elif self.path == '/verify_cookie':
89+
self.send_response(200, 'OK')
90+
self.end_headers()
91+
self.wfile.write("<h1>Cookie verification page</h1>")
92+
if 'cookie_monster=happy' in self.headers.get("Cookie", ""):
93+
self.wfile.write("Cookie Monster is happy.")
94+
else:
95+
self.wfile.write("Cookie Monster is sad.")
96+
self.finish()
8297
else:
8398
self.send_error(500)
8499

tests/http/simple.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,26 @@ Test Duplicate Headers
263263
Should Be Equal ${x[0]} Yes
264264
Should Be Equal ${x[1]} Si!
265265

266+
Mockserver sets cookies
267+
GET /set_cookie
268+
Response Header Should Equal set-cookie cookie_monster=happy
269+
270+
No cookies should work
271+
GET /verify_cookie
272+
Response Body Should Contain Cookie Monster is sad
273+
274+
Cookies Should Work
275+
GET /set_cookie
276+
GET /verify_cookie
277+
278+
Response Body Should Contain Cookie Monster is happy
279+
280+
New HTTP Context should create a new cookie jar
281+
GET /set_cookie
282+
283+
Create HTTP Context ${HOST}
284+
285+
GET /verify_cookie
286+
287+
Response Body Should Contain Cookie Monster is sad
288+

0 commit comments

Comments
 (0)