6

I have a custom delegate class called CertificatePinningDelegate which conforms to URLSessionDelegate. I'm using the delegate method

urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) 

to authenticate with the server. Now I want to write a unit test for this.

I've been trying to manually call the delegate method to pass a custom URLAuthenticationChallenge object, which seems impossible. Does anyone know any alternative/better option for this?

Jayakumar Thangavel
  • 1,884
  • 1
  • 22
  • 29

0 Answers0