Skip to content

Commit

Permalink
Add a few tests for cookie handling (ht/ @dobe)
Browse files Browse the repository at this point in the history
  • Loading branch information
peritus committed Jan 16, 2013
1 parent d5397b6 commit b4eb356
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/http/mockserver.py
Expand Up @@ -79,6 +79,21 @@ def do_GET(self):
self.send_header('Duplicate', 'Si!')
self.end_headers()
self.finish()
elif self.path == '/set_cookie':
self.send_response(200, 'OK')
self.send_header('Set-Cookie', 'cookie_monster=happy')
self.wfile.write("The cookie has been set.")
self.end_headers()
self.finish()
elif self.path == '/verify_cookie':
self.send_response(200, 'OK')
self.end_headers()
self.wfile.write("<h1>Cookie verification page</h1>")
if 'cookie_monster=happy' in self.headers.get("Cookie", ""):
self.wfile.write("Cookie Monster is happy.")
else:
self.wfile.write("Cookie Monster is sad.")
self.finish()
else:
self.send_error(500)

Expand Down
23 changes: 23 additions & 0 deletions tests/http/simple.txt
Expand Up @@ -263,3 +263,26 @@ Test Duplicate Headers
Should Be Equal ${x[0]} Yes
Should Be Equal ${x[1]} Si!

Mockserver sets cookies
GET /set_cookie
Response Header Should Equal set-cookie cookie_monster=happy

No cookies should work
GET /verify_cookie
Response Body Should Contain Cookie Monster is sad

Cookies Should Work
GET /set_cookie
GET /verify_cookie

Response Body Should Contain Cookie Monster is happy

New HTTP Context should create a new cookie jar
GET /set_cookie

Create HTTP Context ${HOST}

GET /verify_cookie

Response Body Should Contain Cookie Monster is sad

0 comments on commit b4eb356

Please sign in to comment.