02-06-2015 04:56
02-06-2015 04:56
I am working on adding Fitbit SSO functionality to a Java server. As such, I am currently integrating Fitbit API functionality, such as Oauth sign-in, to my server.
I want to be able to write automated unit tests for all new features that I write to the server related to the Fitbit API. Most of these services will require authorization via an Oauth token. However, I want the test to be completely automated so that there are no manual steps to writing the test, such as pasting a URL into the browser so I can enter credentials or press the Allow button. I want it so that my server can complete all steps of the Oauth process on its own, from obtaining the request token at the start to receiving the Oauth token at the end.
Is there any way that I can do this with the Fitbit API? Can I bake some sort of test user that doesn't require manual authentication into my server?
Thank you!
02-06-2015 08:20
02-06-2015 08:20
We are currently not provide any bootstrap code or functionality for what you've explained.
But you certainly can create a user and test against it. It still will require manual authentication.
If you want to make the oauth flow completely automatically tested you can check out selenium framework. It will let you be able to open browser and automatically click on a button of your choise from your code.
Just beware you're testing against production and this is normally not the beast approach. If youre test will query Fitbit API too many time you may be banned by Fitbit API.
02-06-2015 08:35
02-06-2015 08:35
Well I obviously wouldn't use my "production app" for my unit tests. I would make my own development app to hit for my Fitbit-based unit tests. Isn't that an acceptable practice to use for automated testing, especially when I am trying to run the tests in a continuous integration tool like Jenkins or Travis?
I find it beyond belief that you would consider banning someone for trying to write unit tests against the Fitbit API.
02-06-2015 08:38
02-06-2015 08:38
Tests are written by humans. Meaning there is always that you may have a bug in your tests. If your test will start spamming Fitbit API servers to frequently you will be banned.