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