提交 c3983bc1 编写于 作者: C Christian Noon

Merge pull request #1164 from 0xced/invalid-credentials-401

Requests with invalid credentials should terminate with a 401 code
......@@ -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)
......
......@@ -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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册