firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.56k stars 1.45k forks source link

Custom URLProtocol doesn't work with firebase calls #138

Closed jerbeers closed 7 years ago

jerbeers commented 7 years ago

I use a custom URLProtocol class in my tests. If I register my URLProtocol class and use URLSession to load a URL, the custom class is used, but if I make a call to any firebase API, the custom class doesn't get used.

Steps to reproduce:

  1. Write a URLProtocol subclass, implement canInit(with request:), set a breakpoint here
  2. In the setUp() method of your test class, add URLProtocol.registerClass(CustomURLProtocol.self)
  3. Write a test and load any URL using URLSession.shared.dataTask(with:)
  4. Run the test and notice the breakpoint in canInit gets hit
  5. Change the test to call Auth.auth().createUser or Database.database().reference().child(path).setValue
  6. Run the test and notice the breakpoint in canInit does not get hit
jerbeers commented 7 years ago

Sorry, I think I misunderstood how registerClass would work. It works for the shared instance of URLSession, but not one with a set configuration. I'll look for another way to test.