|
|
@@ -25,16 +25,12 @@ import Foundation
|
|
|
import XCTest
|
|
|
|
|
|
class AuthenticationTestCase: BaseTestCase {
|
|
|
- // MARK: Properties
|
|
|
-
|
|
|
let user = "user"
|
|
|
let password = "password"
|
|
|
var URLString = ""
|
|
|
|
|
|
- // MARK: Setup and Teardown
|
|
|
-
|
|
|
- override func tearDown() {
|
|
|
- super.tearDown()
|
|
|
+ override func setUp() {
|
|
|
+ super.setUp()
|
|
|
|
|
|
let credentialStorage = NSURLCredentialStorage.sharedCredentialStorage()
|
|
|
let allCredentials = credentialStorage.allCredentials as! [NSURLProtectionSpace: AnyObject]
|
|
|
@@ -52,15 +48,11 @@ class AuthenticationTestCase: BaseTestCase {
|
|
|
// MARK: -
|
|
|
|
|
|
class BasicAuthenticationTestCase: AuthenticationTestCase {
|
|
|
- // MARK: Setup and Teardown
|
|
|
-
|
|
|
override func setUp() {
|
|
|
super.setUp()
|
|
|
self.URLString = "http://httpbin.org/basic-auth/\(self.user)/\(self.password)"
|
|
|
}
|
|
|
|
|
|
- // MARK: Tests
|
|
|
-
|
|
|
func testHTTPBasicAuthenticationWithInvalidCredentials() {
|
|
|
// Given
|
|
|
let expectation = expectationWithDescription("\(self.URLString) 401")
|
|
|
@@ -127,19 +119,13 @@ class BasicAuthenticationTestCase: AuthenticationTestCase {
|
|
|
// MARK: -
|
|
|
|
|
|
class HTTPDigestAuthenticationTestCase: AuthenticationTestCase {
|
|
|
- // MARK: Properties
|
|
|
-
|
|
|
let qop = "auth"
|
|
|
|
|
|
- // MARK: Setup and Teardown
|
|
|
-
|
|
|
override func setUp() {
|
|
|
super.setUp()
|
|
|
self.URLString = "http://httpbin.org/digest-auth/\(self.qop)/\(self.user)/\(self.password)"
|
|
|
}
|
|
|
|
|
|
- // MARK: Tests
|
|
|
-
|
|
|
func testHTTPDigestAuthenticationWithInvalidCredentials() {
|
|
|
// Given
|
|
|
let expectation = expectationWithDescription("\(self.URLString) 401")
|