Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a few tests for cookie handling (ht/ @dobe)

  • Loading branch information...
commit b4eb3567decd955afd259143c8379661c47cbee3 1 parent d5397b6
@peritus authored
Showing with 38 additions and 0 deletions.
  1. +15 −0 tests/http/mockserver.py
  2. +23 −0 tests/http/simple.txt
View
15 tests/http/mockserver.py
@@ -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)
View
23 tests/http/simple.txt
@@ -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
+
Please sign in to comment.
Something went wrong with that request. Please try again.