{"action":"created","comment":{"url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/comments/27819745","id":27819745,"diff_hunk":"@@ -0,0 +1,85 @@\n+var specHelper = require('../spec-helper');\n+var expect = specHelper.expect;\n+var sinon = specHelper.sinon;\n+\n+var authHelper = require('../support/authentication-helper');\n+var oauthKey = authHelper.oauthKey;\n+var oauthPublicKey = authHelper.oauthPublicKey;\n+var clientPublicKey = authHelper.clientPublicKey;\n+var generateClientBearerToken = authHelper.generateClientBearerToken;\n+\n+var strategies = require('../../lib/strategies');\n+\n+describe('Strategies Module', function() {\n+  describe('#registerBearerStrategy', function() {\n+    var _this = this;\n+    before(function() {\n+      _this.passport = sinon.mock('passport');\n+      _this.passport.use = sinon.stub();\n+      _this.passport.deserializeUser = sinon.stub();\n+      _this.type = 'jwt-bearer';\n+      _this.publicKey = sinon.mock('publicKey');\n+      _this.builtVerificationFunction = sinon.stub();\n+      _this.strategyVerificationFunction = sinon.stub(strategies, 'verifyTokenStrategy').returns(_this.builtVerificationFunction);\n+      _this.bearerStrategy = sinon.stub(strategies, 'BearerStrategy');\n+      _this.bearerStrategyInstance = sinon.createStubInstance(strategies.BearerStrategy);\n+      strategies.registerBearerStrategy(_this.passport, _this.type, _this.publicKey);\n+    });\n+    after(function() {\n+      _this.strategyVerificationFunction.restore();\n+      _this.bearerStrategy.restore();\n+    });\n+    it('wraps a public key and verification callback in a function', function() {\n+      expect(_this.strategyVerificationFunction).to.have.been.calledWith(_this.publicKey);\n+    });\n+    it('constructs a BearerStrategy with the wrapped verification function', function() {\n+      expect(_this.bearerStrategy).to.have.been.calledWith(_this.builtVerificationFunction);\n+    });\n+    it('applies the BearerStrategy to passport', function() {\n+      expect(_this.passport.use).to.have.been.calledWith(_this.type, _this.bearerStrategyInstance);\n+    });\n+  });\n+\n+  describe('#verifyTokenStrategy', function() {\n+    var _this = this;\n+    before(function() {\n+      _this.tokenPayload = {\n+        some: 'value'\n+      };\n+      _this.user = sinon.mock('user');\n+      _this.info = sinon.mock('info');\n+      _this.verifyPayloadCallback = sinon.stub().returns(null, _this.user, _this.info);\n+      _this.strategyFunction = new strategies.verifyTokenStrategy(clientPublicKey);\n+    });","path":"test/lib/strategies.spec.js","position":53,"original_position":53,"commit_id":"2b1b1ef482008efa311282b1473ecedac511485a","original_commit_id":"bb17f650e21dc44b1a77f62e8c452a6087bdc9ed","user":{"login":"LilyJ","id":3296212,"avatar_url":"https://avatars.githubusercontent.com/u/3296212?v=3","gravatar_id":"","url":"https://api.github.com/users/LilyJ","html_url":"https://github.com/LilyJ","followers_url":"https://api.github.com/users/LilyJ/followers","following_url":"https://api.github.com/users/LilyJ/following{/other_user}","gists_url":"https://api.github.com/users/LilyJ/gists{/gist_id}","starred_url":"https://api.github.com/users/LilyJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LilyJ/subscriptions","organizations_url":"https://api.github.com/users/LilyJ/orgs","repos_url":"https://api.github.com/users/LilyJ/repos","events_url":"https://api.github.com/users/LilyJ/events{/privacy}","received_events_url":"https://api.github.com/users/LilyJ/received_events","type":"User","site_admin":false},"body":"Worth finding out then","created_at":"2015-04-06T18:54:13Z","updated_at":"2015-04-06T18:54:13Z","html_url":"https://github.com/apiaryio/jwt-oauth-utils/pull/7#discussion_r27819745","pull_request_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/comments/27819745"},"html":{"href":"https://github.com/apiaryio/jwt-oauth-utils/pull/7#discussion_r27819745"},"pull_request":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7","id":32538239,"html_url":"https://github.com/apiaryio/jwt-oauth-utils/pull/7","diff_url":"https://github.com/apiaryio/jwt-oauth-utils/pull/7.diff","patch_url":"https://github.com/apiaryio/jwt-oauth-utils/pull/7.patch","issue_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/7","number":7,"state":"open","locked":false,"title":"JavaScript rewrite & cleanup","user":{"login":"JackuB","id":1788727,"avatar_url":"https://avatars.githubusercontent.com/u/1788727?v=3","gravatar_id":"","url":"https://api.github.com/users/JackuB","html_url":"https://github.com/JackuB","followers_url":"https://api.github.com/users/JackuB/followers","following_url":"https://api.github.com/users/JackuB/following{/other_user}","gists_url":"https://api.github.com/users/JackuB/gists{/gist_id}","starred_url":"https://api.github.com/users/JackuB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackuB/subscriptions","organizations_url":"https://api.github.com/users/JackuB/orgs","repos_url":"https://api.github.com/users/JackuB/repos","events_url":"https://api.github.com/users/JackuB/events{/privacy}","received_events_url":"https://api.github.com/users/JackuB/received_events","type":"User","site_admin":false},"body":"- coffee -> js\r\n- removed jwt.decode (as it was unsafe and basically pointless)\r\n- rewrote almost all tests (previously they were giving false positives)\r\n- made passport strategy actually passport compatible\r\n- added option to query remote server for user data (it will be kotbod in our case)\r\n- updated few dependecies and readme\r\n\r\nComments are welcome","created_at":"2015-04-02T18:40:29Z","updated_at":"2015-04-06T18:54:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e618a340c1b185ddfe2648ff01d8ddda2678e72a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7/commits","review_comments_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7/comments","review_comment_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/7/comments","statuses_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/statuses/2b1b1ef482008efa311282b1473ecedac511485a","head":{"label":"apiaryio:JackuB/javascript_rewrite","ref":"JackuB/javascript_rewrite","sha":"2b1b1ef482008efa311282b1473ecedac511485a","user":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=3","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"repo":{"id":29672790,"name":"jwt-oauth-utils","full_name":"apiaryio/jwt-oauth-utils","owner":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=3","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apiaryio/jwt-oauth-utils","description":"Utilities for working with passport and JWT access tokens","fork":false,"url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils","forks_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/forks","keys_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/teams","hooks_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/hooks","issue_events_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/events{/number}","events_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/events","assignees_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/assignees{/user}","branches_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/branches{/branch}","tags_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/tags","blobs_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/languages","stargazers_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/stargazers","contributors_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/contributors","subscribers_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/subscribers","subscription_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/subscription","commits_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/contents/{+path}","compare_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/merges","archive_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/downloads","issues_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues{/number}","pulls_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/labels{/name}","releases_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/releases{/id}","created_at":"2015-01-22T10:16:08Z","updated_at":"2015-03-31T12:39:37Z","pushed_at":"2015-04-06T15:43:45Z","git_url":"git://github.com/apiaryio/jwt-oauth-utils.git","ssh_url":"git@github.com:apiaryio/jwt-oauth-utils.git","clone_url":"https://github.com/apiaryio/jwt-oauth-utils.git","svn_url":"https://github.com/apiaryio/jwt-oauth-utils","homepage":null,"size":358,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"apiaryio:master","ref":"master","sha":"754b5b0087ae0ceb8599e6e40c8bb05975b80f28","user":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=3","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"repo":{"id":29672790,"name":"jwt-oauth-utils","full_name":"apiaryio/jwt-oauth-utils","owner":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=3","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apiaryio/jwt-oauth-utils","description":"Utilities for working with passport and JWT access tokens","fork":false,"url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils","forks_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/forks","keys_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/teams","hooks_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/hooks","issue_events_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/events{/number}","events_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/events","assignees_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/assignees{/user}","branches_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/branches{/branch}","tags_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/tags","blobs_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/languages","stargazers_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/stargazers","contributors_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/contributors","subscribers_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/subscribers","subscription_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/subscription","commits_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/contents/{+path}","compare_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/merges","archive_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/downloads","issues_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues{/number}","pulls_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/labels{/name}","releases_url":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/releases{/id}","created_at":"2015-01-22T10:16:08Z","updated_at":"2015-03-31T12:39:37Z","pushed_at":"2015-04-06T15:43:45Z","git_url":"git://github.com/apiaryio/jwt-oauth-utils.git","ssh_url":"git@github.com:apiaryio/jwt-oauth-utils.git","clone_url":"https://github.com/apiaryio/jwt-oauth-utils.git","svn_url":"https://github.com/apiaryio/jwt-oauth-utils","homepage":null,"size":358,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7"},"html":{"href":"https://github.com/apiaryio/jwt-oauth-utils/pull/7"},"issue":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/7"},"comments":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/apiaryio/jwt-oauth-utils/statuses/2b1b1ef482008efa311282b1473ecedac511485a"}}}}