Hi,
I uses OHHTTPStubs for Unit- and UI Testing. Since this project didn't handled authentication stuff I forked the project to add this special behavoir. This did worked fine for me aslong I used NSURLConnection and/or AFNetworking (which used in the end also NSURLConnection). Now we move our code to use the NSURLSession API's and our solution for handling the authentication challenge doesn't work anymore.
What happens:
1) I created a NSURLSession with a custom NSURLSessionConfiguration
2) I created a NSURLSessionDataTask loading some JOSN data from a protected web page (Basic Auth)
3) I've a NSURLProtocol implementation in place which identify the HTTP StatusCode 401 which I mocked in -startLoading
4) I manually call on the client variable -URLProtocol:didReceiveAuthenticationChallenge: with a custom created NSURLAuthenticationChallange object
=> my delegate for the NSURLSession (-URLSession:task:didReceiveChallenge:completionHandler:) get called with an valid looking completionHandler
5) I provide credentials to the completionHandler
=> nothing happens, none of the NSURLProtocl methods get called while calling the completionHandler
6) After some seconds the -stopLoading method of NSURLProtocol get called
Does somebody have solved or seen this problem and an idea to solve or way to investigate into this?
Kind Regards,
Thomas
GitHub-Forked project: http://github.com/ThomWee/OHHTTPStubs