Skip to content

Commit 19215d0

Browse files
vipinmenonparkera
authored andcommitted
Implementation of NSURLCredential.copy(with:) (#579)
1 parent 14b428e commit 19215d0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Foundation/NSURLCredential.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ open class URLCredential : NSObject, NSSecureCoding, NSCopying {
8181
}
8282

8383
open func copy(with zone: NSZone? = nil) -> Any {
84-
NSUnimplemented()
84+
return self
8585
}
8686

8787
/*!

TestFoundation/TestNSURLCredential.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class TestNSURLCredential : XCTestCase {
2020

2121
static var allTests: [(String, (TestNSURLCredential) -> () throws -> Void)] {
2222
return [
23-
("test_construction", test_construction)
23+
("test_construction", test_construction),
24+
("test_copy", test_copy)
2425
]
2526
}
2627

@@ -32,4 +33,10 @@ class TestNSURLCredential : XCTestCase {
3233
XCTAssertEqual(credential.persistence, URLCredential.Persistence.forSession)
3334
XCTAssertEqual(credential.hasPassword, true)
3435
}
36+
37+
func test_copy() {
38+
let credential = URLCredential(user: "swiftUser", password: "swiftPassword", persistence: .forSession)
39+
let copy = credential.copy() as! URLCredential
40+
XCTAssertTrue(copy.isEqual(credential))
41+
}
3542
}

0 commit comments

Comments
 (0)