From dd23bc57575aff9535c8a7f41a004d71c7059814 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Sun, 19 Nov 2017 00:28:50 +0100 Subject: [PATCH 1/2] Update destinations --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index ee7ecba8..4f1edc37 100644 --- a/Rakefile +++ b/Rakefile @@ -2,7 +2,7 @@ desc 'Build an iOS scheme' task :ios, [:scheme, :ios_version, :action, :additional_args] do |_,args| - destination = "name=iPhone 5,OS=#{args.ios_version}" + destination = "name=iPhone 7,OS=#{args.ios_version}" build("OHHTTPStubs #{args.scheme}", "iphonesimulator", destination, args.action, args.additional_args) end @@ -14,7 +14,7 @@ end desc 'Build a tvOS scheme' task :tvos, [:scheme, :tvos_version, :action, :additional_args] do |_,args| - destination = "name=Apple TV 1080p,OS=#{args.tvos_version}" + destination = "name=Apple TV,OS=#{args.tvos_version}" build("OHHTTPStubs #{args.scheme}", "appletvsimulator", destination, args.action, args.additional_args) end From 6bf198294575d7ed0ba9110bd7a9b728bc0b5ffb Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Sun, 19 Nov 2017 01:05:24 +0100 Subject: [PATCH 2/2] Use distinct sessions for parallel loop tests to secure results --- .../UnitTests/Test Suites/NSURLSessionTests.m | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m b/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m index f0fd0b7d..49191d09 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m @@ -296,13 +296,8 @@ - (void)test_NSURLSessionDefaultConfig_notFollowingRedirects **/ - (void)test_NSURLSessionDefaultConfig_MethodAndDataRetentionOnRedirect { - NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; - if ([NSURLSessionConfiguration class] && [NSURLSession class]) { - NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; - NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; - NSDictionary* json = @{ @"query": @"Hello World" }; NSArray* allMethods = @[@"GET", @"HEAD", @"POST", @"PATCH", @"PUT"]; @@ -310,6 +305,11 @@ - (void)test_NSURLSessionDefaultConfig_MethodAndDataRetentionOnRedirect for (NSNumber* redirectStatusCode in @[@301, @302, @307, @308]) { int statusCode = redirectStatusCode.intValue; for (NSString* method in allMethods) { + + NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; + NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; + NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; + [self _test_redirect_NSURLSession:session httpMethod:method jsonBody:json delays:0.0 redirectStatusCode:statusCode completion:^(NSString *redirectedRequestMethod, id redirectedRequestJSONBody, NSHTTPURLResponse *redirectHTTPResponse, id finalJSONResponse, NSError *errorResponse) { @@ -323,11 +323,18 @@ - (void)test_NSURLSessionDefaultConfig_MethodAndDataRetentionOnRedirect @"Unexpected JSON response received after %d redirect", statusCode); XCTAssertNil(errorResponse, @"Unexpected error during %d redirect", statusCode); }]; + + [session finishTasksAndInvalidate]; } } /** 303: GET, HEAD, POST, PATCH, PUT should use a GET HTTP method after redirection and not forward the body **/ for (NSString* method in allMethods) { + + NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; + NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; + NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; + [self _test_redirect_NSURLSession:session httpMethod:method jsonBody:json delays:0.0 redirectStatusCode:303 completion:^(NSString *redirectedRequestMethod, id redirectedRequestJSONBody, NSHTTPURLResponse *redirectHTTPResponse, id finalJSONResponse, NSError *errorResponse) { @@ -337,9 +344,9 @@ - (void)test_NSURLSessionDefaultConfig_MethodAndDataRetentionOnRedirect XCTAssertEqualObjects(finalJSONResponse, @{ @"RequestBody": json }, @"Unexpected JSON response received after 303 redirect"); XCTAssertNil(errorResponse, @"Unexpected error during 303 redirect"); }]; - } - [session finishTasksAndInvalidate]; + [session finishTasksAndInvalidate]; + } } else {