Skip to content

Commit

Permalink
Reverted NSURLSession Challenge Disposition to be `NSURLSessionAuthCh…
Browse files Browse the repository at this point in the history
…allengeCancelAuthenticationChallenge` to allow for more determistic pinning results.

- Updated test suite to check for new error code
  • Loading branch information
kcharwood committed Mar 31, 2016
1 parent 8a99f2d commit 280baf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions AFNetworking/AFURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ - (void)URLSession:(NSURLSession *)session
disposition = NSURLSessionAuthChallengePerformDefaultHandling;
}
} else {
disposition = NSURLSessionAuthChallengeRejectProtectionSpace;
disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
}
} else {
disposition = NSURLSessionAuthChallengePerformDefaultHandling;
Expand Down Expand Up @@ -1030,7 +1030,7 @@ - (void)URLSession:(NSURLSession *)session
disposition = NSURLSessionAuthChallengeUseCredential;
credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
} else {
disposition = NSURLSessionAuthChallengeRejectProtectionSpace;
disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
}
} else {
disposition = NSURLSessionAuthChallengePerformDefaultHandling;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tests/AFHTTPSessionManagerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ - (void)testInvalidServerTrustProducesCorrectErrorForCertificatePinning {
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
XCTAssertEqualObjects(error.domain, NSURLErrorDomain);
XCTAssertEqual(error.code, NSURLErrorServerCertificateUntrusted);
XCTAssertEqual(error.code, NSURLErrorCancelled);
[expectation fulfill];
}];
[self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
Expand All @@ -552,7 +552,7 @@ - (void)testInvalidServerTrustProducesCorrectErrorForPublicKeyPinning {
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
XCTAssertEqualObjects(error.domain, NSURLErrorDomain);
XCTAssertEqual(error.code, NSURLErrorServerCertificateUntrusted);
XCTAssertEqual(error.code, NSURLErrorCancelled);
[expectation fulfill];
}];
[self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
Expand Down

0 comments on commit 280baf5

Please sign in to comment.