diff --git a/Source/Request.swift b/Source/Request.swift index 1f58de9dddcc37e525dfb1fdd0d172b868984777..f16262bad4b9d798af5bed2c53b6c4ff38215f62 100644 --- a/Source/Request.swift +++ b/Source/Request.swift @@ -284,7 +284,7 @@ public class Request { } } else { if challenge.previousFailureCount > 0 { - disposition = .CancelAuthenticationChallenge + disposition = .RejectProtectionSpace } else { credential = self.credential ?? session.configuration.URLCredentialStorage?.defaultCredentialForProtectionSpace(challenge.protectionSpace) diff --git a/Tests/AuthenticationTests.swift b/Tests/AuthenticationTests.swift index 4826f23ff2ad3f1550ce74d6ddb42f65b8ef8f50..0792468c6e826a6d6afefae077404bf5c50b3b8a 100644 --- a/Tests/AuthenticationTests.swift +++ b/Tests/AuthenticationTests.swift @@ -84,13 +84,10 @@ class BasicAuthenticationTestCase: AuthenticationTestCase { // Then XCTAssertNotNil(request, "request should not be nil") - XCTAssertNil(response, "response should be nil") + XCTAssertNotNil(response, "response should not be nil") + XCTAssertEqual(response?.statusCode ?? 0, 401, "response status code should be 401") XCTAssertNotNil(data, "data should not be nil") - XCTAssertNotNil(error, "error should not be nil") - - if let code = error?.code { - XCTAssertEqual(code, -999, "error should be NSURLErrorDomain Code -999 'cancelled'") - } + XCTAssertNil(error, "error should be nil") } func testHTTPBasicAuthenticationWithValidCredentials() { @@ -160,13 +157,10 @@ class HTTPDigestAuthenticationTestCase: AuthenticationTestCase { // Then XCTAssertNotNil(request, "request should not be nil") - XCTAssertNil(response, "response should be nil") + XCTAssertNotNil(response, "response should not be nil") + XCTAssertEqual(response?.statusCode ?? 0, 401, "response status code should be 401") XCTAssertNotNil(data, "data should not be nil") - XCTAssertNotNil(error, "error should not be nil") - - if let code = error?.code { - XCTAssertEqual(code, -999, "error should be NSURLErrorDomain Code -999 'cancelled'") - } + XCTAssertNil(error, "error should be nil") } func testHTTPDigestAuthenticationWithValidCredentials() {