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

Side by Side Diff: tests/standalone/io/http_headers_test.dart

Issue 443373003: Make the default HTTP server configuration more secure (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed more review comments Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart.io; 5 library dart.io;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import "dart:async"; 8 import "dart:async";
9 import "dart:collection"; 9 import "dart:collection";
10 import "dart:convert"; 10 import "dart:convert";
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 360
361 void checkCookie(cookie, s) { 361 void checkCookie(cookie, s) {
362 Expect.equals(s, cookie.toString()); 362 Expect.equals(s, cookie.toString());
363 var c = new _Cookie.fromSetCookieValue(s); 363 var c = new _Cookie.fromSetCookieValue(s);
364 checkCookiesEquals(cookie, c); 364 checkCookiesEquals(cookie, c);
365 } 365 }
366 366
367 Cookie cookie; 367 Cookie cookie;
368 cookie = new Cookie(name, value); 368 cookie = new Cookie(name, value);
369 Expect.equals("$name=$value", cookie.toString()); 369 Expect.equals("$name=$value; HttpOnly", cookie.toString());
370 DateTime date = new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0); 370 DateTime date = new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0);
371 cookie.expires = date; 371 cookie.expires = date;
372 checkCookie(cookie, "$name=$value" 372 checkCookie(cookie, "$name=$value"
373 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"); 373 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
374 "; HttpOnly");
374 cookie.maxAge = 567; 375 cookie.maxAge = 567;
375 checkCookie(cookie, "$name=$value" 376 checkCookie(cookie, "$name=$value"
376 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT" 377 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
377 "; Max-Age=567"); 378 "; Max-Age=567"
379 "; HttpOnly");
378 cookie.domain = "example.com"; 380 cookie.domain = "example.com";
379 checkCookie(cookie, "$name=$value" 381 checkCookie(cookie, "$name=$value"
380 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT" 382 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
381 "; Max-Age=567" 383 "; Max-Age=567"
382 "; Domain=example.com"); 384 "; Domain=example.com"
385 "; HttpOnly");
383 cookie.path = "/xxx"; 386 cookie.path = "/xxx";
384 checkCookie(cookie, "$name=$value" 387 checkCookie(cookie, "$name=$value"
385 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT" 388 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
386 "; Max-Age=567" 389 "; Max-Age=567"
387 "; Domain=example.com" 390 "; Domain=example.com"
388 "; Path=/xxx"); 391 "; Path=/xxx"
392 "; HttpOnly");
389 cookie.secure = true; 393 cookie.secure = true;
390 checkCookie(cookie, "$name=$value" 394 checkCookie(cookie, "$name=$value"
391 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT" 395 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
392 "; Max-Age=567" 396 "; Max-Age=567"
393 "; Domain=example.com" 397 "; Domain=example.com"
394 "; Path=/xxx" 398 "; Path=/xxx"
395 "; Secure");
396 cookie.httpOnly = true;
397 checkCookie(cookie, "$name=$value"
398 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
399 "; Max-Age=567"
400 "; Domain=example.com"
401 "; Path=/xxx"
402 "; Secure" 399 "; Secure"
403 "; HttpOnly"); 400 "; HttpOnly");
401 cookie.httpOnly = false;
402 checkCookie(cookie, "$name=$value"
403 "; Expires=Sun, 05 Jan 2014 23:59:59 GMT"
404 "; Max-Age=567"
405 "; Domain=example.com"
406 "; Path=/xxx"
407 "; Secure");
404 cookie.expires = null; 408 cookie.expires = null;
405 checkCookie(cookie, "$name=$value" 409 checkCookie(cookie, "$name=$value"
406 "; Max-Age=567" 410 "; Max-Age=567"
407 "; Domain=example.com" 411 "; Domain=example.com"
408 "; Path=/xxx" 412 "; Path=/xxx"
409 "; Secure" 413 "; Secure");
410 "; HttpOnly");
411 cookie.maxAge = null; 414 cookie.maxAge = null;
412 checkCookie(cookie, "$name=$value" 415 checkCookie(cookie, "$name=$value"
413 "; Domain=example.com" 416 "; Domain=example.com"
414 "; Path=/xxx" 417 "; Path=/xxx"
415 "; Secure" 418 "; Secure");
416 "; HttpOnly");
417 cookie.domain = null; 419 cookie.domain = null;
418 checkCookie(cookie, "$name=$value" 420 checkCookie(cookie, "$name=$value"
419 "; Path=/xxx" 421 "; Path=/xxx"
420 "; Secure" 422 "; Secure");
421 "; HttpOnly");
422 cookie.path = null; 423 cookie.path = null;
423 checkCookie(cookie, "$name=$value" 424 checkCookie(cookie, "$name=$value"
424 "; Secure" 425 "; Secure");
425 "; HttpOnly");
426 cookie.secure = false; 426 cookie.secure = false;
427 checkCookie(cookie, "$name=$value"
428 "; HttpOnly");
429 cookie.httpOnly = false;
430 checkCookie(cookie, "$name=$value"); 427 checkCookie(cookie, "$name=$value");
431 } 428 }
432 test("name", "value"); 429 test("name", "value");
433 test("abc", "def"); 430 test("abc", "def");
434 test("ABC", "DEF"); 431 test("ABC", "DEF");
435 test("Abc", "Def"); 432 test("Abc", "Def");
436 test("SID", "sJdkjKSJD12343kjKj78"); 433 test("SID", "sJdkjKSJD12343kjKj78");
437 } 434 }
438 435
439 void testInvalidCookie() { 436 void testInvalidCookie() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 (e) => e is FormatException); 489 (e) => e is FormatException);
493 } 490 }
494 } 491 }
495 test('\r'); 492 test('\r');
496 test('\n'); 493 test('\n');
497 test('test\x00'); 494 test('test\x00');
498 // Test we handle other types correctly. 495 // Test we handle other types correctly.
499 test(new StringBuffer('\x00'), remove: false); 496 test(new StringBuffer('\x00'), remove: false);
500 } 497 }
501 498
499 void testClear() {
500 _HttpHeaders headers = new _HttpHeaders("1.1");
501 headers.add("a", "b");
502 headers.contentLength = 7;
503 headers.chunkedTransferEncoding = true;
504 headers.clear();
505 Expect.isNull(headers["a"]);
506 Expect.equals(headers.contentLength, -1);
507 Expect.isFalse(headers.chunkedTransferEncoding);
508 }
509
502 main() { 510 main() {
503 testMultiValue(); 511 testMultiValue();
504 testDate(); 512 testDate();
505 testExpires(); 513 testExpires();
506 testIfModifiedSince(); 514 testIfModifiedSince();
507 testHost(); 515 testHost();
508 testEnumeration(); 516 testEnumeration();
509 testHeaderValue(); 517 testHeaderValue();
510 testContentType(); 518 testContentType();
511 testContentTypeCache(); 519 testContentTypeCache();
512 testCookie(); 520 testCookie();
513 testInvalidCookie(); 521 testInvalidCookie();
514 testHeaderLists(); 522 testHeaderLists();
515 testInvalidFieldName(); 523 testInvalidFieldName();
516 testInvalidFieldValue(); 524 testInvalidFieldValue();
525 testClear();
517 } 526 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_detach_socket_test.dart ('k') | tests/standalone/io/http_server_response_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698