Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1798)

Unified Diff: tests/standalone/io/http_headers_test.dart

Issue 10414076: Support for cookies in the HTTP library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/http_headers_test.dart
diff --git a/tests/standalone/io/http_headers_test.dart b/tests/standalone/io/http_headers_test.dart
index 137abe5c9d8cc63e8461ebb2ac44f58185c5b324..67d2c59a8f1e155f3914ceaf7bbb77fa1a647d0b 100644
--- a/tests/standalone/io/http_headers_test.dart
+++ b/tests/standalone/io/http_headers_test.dart
@@ -276,6 +276,87 @@ void testContentTypeCache() {
Expect.equals("/", headers.contentType.value);
}
+void testCookie() {
+ void checkCookiesEquals(a, b) {
+ Expect.equals(a.name, b.name);
+ Expect.equals(a.value, b.value);
+ Expect.equals(a.expires, b.expires);
+ Expect.equals(a.toString(), b.toString());
+ }
+
+ void checkCookie(cookie, s) {
+ Expect.equals(s, cookie.toString());
+ var c = new _Cookie.fromSetCookieValue(s);
+ checkCookiesEquals(cookie, c);
+ }
+
+ Cookie cookie;
+ cookie = new Cookie("name", "value");
+ Expect.equals("name=value", cookie.toString());
+ TimeZone utc = new TimeZone.utc();
+ Date date = new Date.withTimeZone(2014, Date.JAN, 5, 23, 59, 59, 0, utc);
+ cookie.expires = date;
+ checkCookie(cookie, "name=value"
+ "; Expires=Sun, 5 Jan 2014 23:59:59 GMT");
+ cookie.maxAge = 567;
+ checkCookie(cookie, "name=value"
+ "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
+ "; Max-Age=567");
+ cookie.domain = "example.com";
+ checkCookie(cookie, "name=value"
+ "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
+ "; Max-Age=567"
+ "; Domain=example.com");
+ cookie.path = "/xxx";
+ checkCookie(cookie, "name=value"
+ "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
+ "; Max-Age=567"
+ "; Domain=example.com"
+ "; Path=/xxx");
+ cookie.secure = true;
+ checkCookie(cookie, "name=value"
+ "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
+ "; Max-Age=567"
+ "; Domain=example.com"
+ "; Path=/xxx"
+ "; Secure");
+ cookie.httpOnly = true;
+ checkCookie(cookie, "name=value"
+ "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
+ "; Max-Age=567"
+ "; Domain=example.com"
+ "; Path=/xxx"
+ "; Secure"
+ "; HttpOnly");
+ cookie.expires = null;
+ checkCookie(cookie, "name=value"
+ "; Max-Age=567"
+ "; Domain=example.com"
+ "; Path=/xxx"
+ "; Secure"
+ "; HttpOnly");
+ cookie.maxAge = null;
+ checkCookie(cookie, "name=value"
+ "; Domain=example.com"
+ "; Path=/xxx"
+ "; Secure"
+ "; HttpOnly");
+ cookie.domain = null;
+ checkCookie(cookie, "name=value"
+ "; Path=/xxx"
+ "; Secure"
+ "; HttpOnly");
+ cookie.path = null;
+ checkCookie(cookie, "name=value"
+ "; Secure"
+ "; HttpOnly");
+ cookie.secure = false;
+ checkCookie(cookie, "name=value"
+ "; HttpOnly");
+ cookie.httpOnly = false;
+ checkCookie(cookie, "name=value");
+}
+
main() {
testMultiValue();
testExpires();
@@ -284,4 +365,5 @@ main() {
testHeaderValue();
testContentType();
testContentTypeCache();
+ testCookie();
}

Powered by Google App Engine
This is Rietveld 408576698