acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
439 stars 48 forks source link

How to mock test user authentication (hello.js and google+) #65

Open kaidatavis opened 7 years ago

kaidatavis commented 7 years ago

Hi,

I am working on a chrome extension that requires user to sign in and using hello.js to handle the authentication with different oauth services. So far I am only using google+ authentication because this is a chrome extension and user should have a google account.

I want to 'mock' the google+ authentication service using sinon-chrome, so the extension does not have to communicate with google+ during the test. I can see two problems:

  1. The authentication communication is meant to be secure, so I am not sure how to capture the response from google+ oauth service and use it in the test;
  2. Currently I treat hello.js as a black box, and would like to keep it that way for the testing: ideally no change of the code is needed for anything inside hello.js.

Thanks,