vadymmarkov / Malibu

:surfer: Malibu is a networking library built on promises
https://vadymmarkov.github.io
Other
414 stars 39 forks source link

Fix: authentication challenge #63

Closed vadymmarkov closed 7 years ago

vadymmarkov commented 7 years ago

The way we handled authentication challenges doesn't handle all the cases, basically it worked only when there is a base URL. Now we do multiple validations and call completionHandler in the end of the delegate function.

vadymmarkov commented 7 years ago

@JohnSundell I have troubles with mocking serverTrust in URLProtectionSpace, it's get only property. So I can add tests, but it's not gonna cover all the cases.

JohnSundell commented 7 years ago

@vadymmarkov So the way I would do it is extract that property into a protocol (for example ServerTrustProvider or similar), then mock that protocol in your tests. Would that work?

vadymmarkov commented 7 years ago

@JohnSundell It would work with protocol, but it's not that easy to create an instance of this SecTrust type without valid certificate. And without that instance I can't really simulate the case when it's not nil. I ended up with tests that partially cover this patch. https://github.com/hyperoslo/Malibu/pull/63/commits/543f8bd14549313124fb76a7c73e9383108ccd41