Frage

I am using passport.js as back-end library To handle authentication from OAuth providers like google, Facebook and Twitter.

As I am now writing the tests I would like to avoid creating own accounts just for testing.

So are there something like open credentials for the used providers?

How do yo mockup the accounts in tests?

War es hilfreich?

Lösung

See http://term.ie/oauth/example with the explanation on this other post

Andere Tipps

Take a look at the tests included in the multiple passport strategies. They often offer good examples of mocks for the entire interaction (for unit tests). Integration tests will require the entire flow (and likely some UI automation tool). Here's an example on Facebook strategy tests.

I'm not aware of any "dev only" credentials from any of these providers. In any case you will have to setup callback URLs pointing back to your app. Hopefully you will not do this very often...

In our system (which is an intermediary for authentication), we decided to supply default credentials for all well-known identity providers, if you don't want to deal with that while you are testing. In production, it is recommended that you get your own registration. The final architecture would be slightly different though, and not sure it would fit your needs:

App (passportjs) -> Our Server -> * Identity Providers

Note: even though ours is a paid service, the free tier allows you to do tests with no expiration.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top