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

Side by Side Diff: components/cronet/ios/test/cronet_http_test.mm

Issue 2671713006: [Cronet] Don't spam log if system cookie doesn't have creation time. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | ios/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cronet/Cronet.h> 5 #import <Cronet/Cronet.h>
6 #import <Foundation/Foundation.h> 6 #import <Foundation/Foundation.h>
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 [systemCookieStorage setCookie:systemCookie]; 315 [systemCookieStorage setCookie:systemCookie];
316 316
317 StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:echoCookieUrl]); 317 StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:echoCookieUrl]);
318 [systemCookieStorage deleteCookie:systemCookie]; 318 [systemCookieStorage deleteCookie:systemCookie];
319 EXPECT_EQ(nil, [delegate_ error]); 319 EXPECT_EQ(nil, [delegate_ error]);
320 // Verify that cookie set in system store was sent to the serever. 320 // Verify that cookie set in system store was sent to the serever.
321 EXPECT_TRUE([[delegate_ responseBody] containsString:cookieName]); 321 EXPECT_TRUE([[delegate_ responseBody] containsString:cookieName]);
322 EXPECT_TRUE([[delegate_ responseBody] containsString:cookieValue]); 322 EXPECT_TRUE([[delegate_ responseBody] containsString:cookieValue]);
323 } 323 }
324 324
325 TEST_F(HttpTest, SystemCookieWithNullCreationTime) {
326 const char kCookieHeader[] = "Cookie";
327 NSString* cookieName = [NSString
328 stringWithFormat:@"SetSystemCookie-%@", [[NSUUID UUID] UUIDString]];
329 NSString* cookieValue = [[NSUUID UUID] UUIDString];
330 NSHTTPCookieStorage* systemCookieStorage =
331 [NSHTTPCookieStorage sharedHTTPCookieStorage];
332 NSURL* echoCookieUrl =
333 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL(kCookieHeader)));
334 NSHTTPCookie* nullCreationTimeCookie = [NSHTTPCookie cookieWithProperties:@{
335 NSHTTPCookiePath : [echoCookieUrl path],
336 NSHTTPCookieName : cookieName,
337 NSHTTPCookieValue : cookieValue,
338 NSHTTPCookieDomain : [echoCookieUrl host],
339 @"Created" : [NSNumber numberWithDouble:0.0],
340 }];
341 [systemCookieStorage setCookie:nullCreationTimeCookie];
342 NSHTTPCookie* normalCookie = [NSHTTPCookie cookieWithProperties:@{
343 NSHTTPCookiePath : [echoCookieUrl path],
344 NSHTTPCookieName : [cookieName stringByAppendingString:@"-normal"],
345 NSHTTPCookieValue : cookieValue,
346 NSHTTPCookieDomain : [echoCookieUrl host],
347 }];
348 [systemCookieStorage setCookie:normalCookie];
349 StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:echoCookieUrl]);
350 [systemCookieStorage deleteCookie:nullCreationTimeCookie];
351 [systemCookieStorage deleteCookie:normalCookie];
352 EXPECT_EQ(nil, [delegate_ error]);
353 // Verify that cookie set in system store was sent to the serever.
354 EXPECT_TRUE([[delegate_ responseBody] containsString:cookieName]);
355 EXPECT_TRUE([[delegate_ responseBody] containsString:cookieValue]);
356 }
357
325 TEST_F(HttpTest, FilterOutRequest) { 358 TEST_F(HttpTest, FilterOutRequest) {
326 NSURL* url = 359 NSURL* url =
327 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("User-Agent"))); 360 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("User-Agent")));
328 __block BOOL block_used = NO; 361 __block BOOL block_used = NO;
329 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url]; 362 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url];
330 [Cronet setRequestFilterBlock:^(NSURLRequest* request) { 363 [Cronet setRequestFilterBlock:^(NSURLRequest* request) {
331 block_used = YES; 364 block_used = YES;
332 EXPECT_EQ([request URL], url); 365 EXPECT_EQ([request URL], url);
333 return NO; 366 return NO;
334 }]; 367 }];
335 StartDataTaskAndWaitForCompletion(task); 368 StartDataTaskAndWaitForCompletion(task);
336 EXPECT_TRUE(block_used); 369 EXPECT_TRUE(block_used);
337 EXPECT_EQ(nil, [delegate_ error]); 370 EXPECT_EQ(nil, [delegate_ error]);
338 EXPECT_FALSE([[delegate_ responseBody] 371 EXPECT_FALSE([[delegate_ responseBody]
339 containsString:base::SysUTF8ToNSString(kUserAgent)]); 372 containsString:base::SysUTF8ToNSString(kUserAgent)]);
340 EXPECT_TRUE([[delegate_ responseBody] containsString:@"CFNetwork"]); 373 EXPECT_TRUE([[delegate_ responseBody] containsString:@"CFNetwork"]);
341 } 374 }
342 375
343 } // namespace cronet 376 } // namespace cronet
OLDNEW
« no previous file with comments | « no previous file | ios/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698