taxjar / help_scout-sdk

Ruby Help Scout (aka HelpScout) SDK Using Mailbox API v2.0
MIT License
18 stars 27 forks source link

Fix Stale Connections #10

Closed andremleblanc closed 5 years ago

andremleblanc commented 5 years ago

In order to better troubleshoot issues with access token refreshes, this PR makes it so only 200s are accepted and al unexpected status codes will raise an error with the response body.

The main change is to lib/help_scout/api/access_token.rb, the other changes are to more closely match our test suite to production use.

prsimp commented 5 years ago

Sidenote: I couldn't get the test suite to run locally without an API key.

You should be able to run it locally with nonsense for your credentials, but you will need to specify some test values (everything that starts with TEST_ below). None of these values needs to be accurate, they just need to be set. Here's the config I just ran the specs locally with:

export HELP_SCOUT_APP_ID="utter"
export HELP_SCOUT_APP_SECRET="nonsense"
export HELP_SCOUT_DEFAULT_MAILBOX="1"
export TEST_MAILBOX_ID="1"
export TEST_CONVERSATION_ID="2"
export TEST_CUSTOMER_EMAIL="foo@bar.com"
export TEST_USER_EMAIL="baz@bat.ltd"
export TEST_USER_ID="3"
export TEST_CUSTOMER_ID="4"
export TEST_THREAD_ID="5"

The TEST_ values are mostly important when re-recording cassettes, but we've tried to do a good job filtering out those and any sensitive values to make running the specs easier.

Eventually, I'd like us to get to a point where a small setup script is included such that the entire test suite can be "live" executed against the Help Scout API on an empty Mailbox with assuming anything exists. This would make it easier for new contributors or anyone needing to re-record cassettes.

jcypret commented 5 years ago

Eventually, I'd like us to get to a point where a small setup script is included such that the entire test suite can be "live" executed against the Help Scout API on an empty Mailbox with assuming anything exists. This would make it easier for new contributors or anyone needing to re-record cassettes.

Ah, that makes sense. I ran the bin/setup script specified in the README, but looking now that just did a bundle install. Would be great to have that also add the environment variables.