我有一个名为的自定义委托类CertificatePinningDelegate
,它符合URLSessionDelegate
. 我正在使用委托方法
urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
与服务器进行身份验证。现在我想为此编写一个单元测试。
我一直在尝试手动调用委托方法来传递自定义URLAuthenticationChallenge
对象,这似乎是不可能的。有谁知道这个的任何替代/更好的选择?