jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.07k stars 218 forks source link

Figure out how authentication / storage requests work into the API #9

Closed jvilk closed 11 years ago

jvilk commented 11 years ago

IndexedDB requires the user to allow the webpage to store data on the current webpage, Dropbox requires the user to log in...

lavelle commented 11 years ago

This is proving problematic for automated testing. None of Dropbox.js' auth drivers work with this setup. The redirect driver breaks Karma because it can't handle page reloads. The popup driver fails to do anything, and the Node driver only works for server applications where the Dropbox API calls are made within Node.

Until there's a way of delaying API calls until the async calls in the constructor have finished I can't see a way to test the Dropbox backend with Karma.

jvilk commented 11 years ago

Yeah, I can make a way. We already asynchronously trigger karma to run, so I'd just have to fix up the test runner logic for async constructors.

jvilk commented 11 years ago

Btw, there's a way to pregenerate credentials on the command line for unit testing. Check out the Cakefile for Dropbox-js; you might be able to use that logic.

jvilk commented 11 years ago

Delaying this line should delay test kickoff/API usage: https://github.com/jvilk/BrowserFS/blob/master/test/zzz-test_def.js#L71

jvilk commented 11 years ago

Alrighty. @lavelle and I have figured this out.

For Dropbox, the website handles authenticating with the Dropbox-js library, and is responsible for handing the authenticated client over to us.

For storage requests, we can handle doing this asynchronously through the constructor.

In the future, when we support multiple cloud storage backends, we could potentially have handy factory methods that can present the user with a choice of which cloud storage account they wish to use.