Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Clean up fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
todoubled committed Jul 29, 2015
1 parent 8a6f9bc commit 9fdadab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
34 changes: 15 additions & 19 deletions test/fixtures/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,31 @@ oauth = ->
nock("https://oauth.intuit.com:443")
.filteringRequestBody((body) -> return "SAML")
.post("/oauth/v1/get_access_token_by_saml", "SAML")
.matchHeader("Authorization", authorizationHeader)
.reply(200, "oauth_token_secret=L63cI4q5UhP4mQzpCi1RHBMSLe2TNOaI98vxyIBL&oauth_token=qyprdcvDh5V2XoJRwYmxxdL5vOJ54Z6sNVohlNLQHyyhHaAy")

jsonHeader = (header) ->
header is "application/json"

signedHeader = (header) ->
/oauth_signature/.test header

authorizationHeader = (header) ->
regex = new RegExp "#{config.consumerKey}"
regex.test header

fixtures =
oauth: oauth

# Fail the test if these headers aren't generated
signedJson: ->
oauth()
nock("https://financialdatafeed.platform.intuit.com:443", {
reqheaders:
"Content-Type": "application/json"
"Accept": "application/json"
})
nock("https://financialdatafeed.platform.intuit.com:443")
.get("/v1/institutions/100000")
.matchHeader("Authorization", (header) ->
/oauth_signature/.test header
)
.matchHeader("Content-Type", jsonHeader)
.matchHeader("Accept", jsonHeader)
.matchHeader("Authorization", signedHeader)
.reply(200, {})

signedSaml: ->
nock("https://oauth.intuit.com:443")
.filteringRequestBody((body) -> return "SAML")
.post("/oauth/v1/get_access_token_by_saml", "SAML")
.matchHeader("Authorization", (header) ->
regex = new RegExp "#{config.consumerKey}"
regex.test header
)
.reply(200, "oauth_token_secret=L63cI4q5UhP4mQzpCi1RHBMSLe2TNOaI98vxyIBL&oauth_token=qyprdcvDh5V2XoJRwYmxxdL5vOJ54Z6sNVohlNLQHyyhHaAy")

getInstitutionDetails: ->
oauth()
load "getInstitutionDetails"
Expand Down
2 changes: 1 addition & 1 deletion test/lib/oauth.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fixture = require "../fixtures"
describe "OAuth", ->
describe "getToken", ->
before -> @spy = bond(request, "post").through()
before -> fixture.load "signedSaml"
before -> fixture.load "oauth"
before (done) ->
oauth = new OAuth config
oauth.getToken (@err, @token, @secret) =>
Expand Down

0 comments on commit 9fdadab

Please sign in to comment.