{"action":"created","comment":{"url":"https://api.github.com/repos/andela/project-ginsan/pulls/comments/82535975","pull_request_review_id":3437348,"id":82535975,"diff_hunk":"@@ -0,0 +1,91 @@\n+var request = require('supertest'),\n+    should = require('should'),\n+    mongoose = require('mongoose'),\n+    config = require('../../config/env/all');\n+\n+\n+describe('Login Integration test', function () {\n+    this.timeout(140008);\n+\n+    var url = 'http://localhost:' + process.env.PORT;\n+    console.log(url);\n+\n+    before(function () {\n+        mongoose.createConnection(process.env.DB_URL);\n+\n+        var newUser = {\n+            name: 'test user',\n+            email: 'test@test.com',\n+            password: 'Password1'\n+        };\n+\n+        request(url)\n+            .post('/api/auth/signup')\n+            .send(newUser)\n+            .end(function (err, res) {\n+                if (err) {\n+                    throw err;\n+                }\n+            });\n+    });\n+\n+    it('should return success=true when valid', function (done) {\n+\n+        var logInUser = {\n+            email: 'test@test.com',\n+            password: 'Password1'\n+        };\n+\n+        request(url)\n+            .post('/api/auth/login')\n+            .send(logInUser)\n+            .expect('Content-Type', 'application/json; charset=utf-8')\n+            .expect(200)\n+            .end(function (err, res) {\n+                if (err) throw err;\n+                res.body.should.have.property('success');\n+                res.body.success.should.equal(true);\n+                res.body.message.should.equal('Successfully logged on.');\n+            });\n+        setTimeout(done, 2500);\n+    });\n+\n+    it('should return error if password is not correct', function (done) {\n+        var logInUser = {\n+            email: 'test@test.com',\n+            password: 'pass'\n+        };\n+\n+        request(url)\n+            .post('/api/auth/login')\n+            .send(logInUser)\n+            .expect('Content-Type', 'application/json; charset=utf-8')\n+            .expect(401)\n+            .end(function (err, res) {\n+                if (err) throw err;","path":"test/routes/login.js","position":65,"original_position":65,"commit_id":"3f4d61032a887f5a240108034bbac4904642fd19","original_commit_id":"3f4d61032a887f5a240108034bbac4904642fd19","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Expected '{' and instead saw 'throw'.","created_at":"2016-10-10T00:23:59Z","updated_at":"2016-10-10T00:23:59Z","html_url":"https://github.com/andela/project-ginsan/pull/11#discussion_r82535975","pull_request_url":"https://api.github.com/repos/andela/project-ginsan/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/andela/project-ginsan/pulls/comments/82535975"},"html":{"href":"https://github.com/andela/project-ginsan/pull/11#discussion_r82535975"},"pull_request":{"href":"https://api.github.com/repos/andela/project-ginsan/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/andela/project-ginsan/pulls/11","id":88187926,"html_url":"https://github.com/andela/project-ginsan/pull/11","diff_url":"https://github.com/andela/project-ginsan/pull/11.diff","patch_url":"https://github.com/andela/project-ginsan/pull/11.patch","issue_url":"https://api.github.com/repos/andela/project-ginsan/issues/11","number":11,"state":"open","locked":false,"title":"#130341273 Added JWT authentication for login","user":{"login":"andela-akolawole","id":16742431,"avatar_url":"https://avatars.githubusercontent.com/u/16742431?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-akolawole","html_url":"https://github.com/andela-akolawole","followers_url":"https://api.github.com/users/andela-akolawole/followers","following_url":"https://api.github.com/users/andela-akolawole/following{/other_user}","gists_url":"https://api.github.com/users/andela-akolawole/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-akolawole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-akolawole/subscriptions","organizations_url":"https://api.github.com/users/andela-akolawole/orgs","repos_url":"https://api.github.com/users/andela-akolawole/repos","events_url":"https://api.github.com/users/andela-akolawole/events{/privacy}","received_events_url":"https://api.github.com/users/andela-akolawole/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\nThis PR adds a feature where users are given a JWT(JSON web token) after a successful login.\r\n\r\n#### Description of Task to be completed?\r\nIt completes the task for user login when the (/api/auth/login) endpoint is sent a POST method with the user's details.\r\n\r\n#### How should this be manually tested?\r\nTo test the feature, install postman and try this API endpoint with a POST method ```http://localhost:PORT/api/auth/login```\r\n\r\n##### Add the following form fields\r\n* email\r\n* password\r\n\r\nSuccess response\r\n\r\n```javascript\r\n{\r\n\"success\": true,\r\n\"message\": \"Successfully logged in\"\r\n\"token\":\"eyJhbGciOiJIUzI1NiIsInR5porpwirwcCI6IkpXVCJ9.eyJfaWQiOiI1N2YyZjBhYTgxOTA5NTNmNTgwMDAwMDEiLCJpYXQiOjE0NzU1difroeirorkwoieMzkxMTQsImV4cCI6MTQ3NTU0OTE5NH0.rCJdm6tvHa9v1XX9o3JXlTnEna1mVToEmh5vPH0V-O0\"\r\n}\r\n```\r\n#### Background context\r\nJSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA.\r\n\r\nJSON Web Tokens consist of three parts separated by dots (.), which are:\r\n* Header\r\n* Payload\r\n* Signature\r\n\r\n#### Pivotal tracker stories?\r\n#130341273","created_at":"2016-10-06T02:04:03Z","updated_at":"2016-10-10T00:23:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"03608a03286d50148a08440dbd207e6a3e9e5708","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/project-ginsan/pulls/11/commits","review_comments_url":"https://api.github.com/repos/andela/project-ginsan/pulls/11/comments","review_comment_url":"https://api.github.com/repos/andela/project-ginsan/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/project-ginsan/issues/11/comments","statuses_url":"https://api.github.com/repos/andela/project-ginsan/statuses/3f4d61032a887f5a240108034bbac4904642fd19","head":{"label":"andela:feature-jwt-implementation-login-130341273","ref":"feature-jwt-implementation-login-130341273","sha":"3f4d61032a887f5a240108034bbac4904642fd19","user":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":67411415,"name":"project-ginsan","full_name":"andela/project-ginsan","owner":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/project-ginsan","description":null,"fork":false,"url":"https://api.github.com/repos/andela/project-ginsan","forks_url":"https://api.github.com/repos/andela/project-ginsan/forks","keys_url":"https://api.github.com/repos/andela/project-ginsan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/project-ginsan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/project-ginsan/teams","hooks_url":"https://api.github.com/repos/andela/project-ginsan/hooks","issue_events_url":"https://api.github.com/repos/andela/project-ginsan/issues/events{/number}","events_url":"https://api.github.com/repos/andela/project-ginsan/events","assignees_url":"https://api.github.com/repos/andela/project-ginsan/assignees{/user}","branches_url":"https://api.github.com/repos/andela/project-ginsan/branches{/branch}","tags_url":"https://api.github.com/repos/andela/project-ginsan/tags","blobs_url":"https://api.github.com/repos/andela/project-ginsan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/project-ginsan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/project-ginsan/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/project-ginsan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/project-ginsan/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/project-ginsan/languages","stargazers_url":"https://api.github.com/repos/andela/project-ginsan/stargazers","contributors_url":"https://api.github.com/repos/andela/project-ginsan/contributors","subscribers_url":"https://api.github.com/repos/andela/project-ginsan/subscribers","subscription_url":"https://api.github.com/repos/andela/project-ginsan/subscription","commits_url":"https://api.github.com/repos/andela/project-ginsan/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/project-ginsan/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/project-ginsan/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/project-ginsan/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/project-ginsan/contents/{+path}","compare_url":"https://api.github.com/repos/andela/project-ginsan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/project-ginsan/merges","archive_url":"https://api.github.com/repos/andela/project-ginsan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/project-ginsan/downloads","issues_url":"https://api.github.com/repos/andela/project-ginsan/issues{/number}","pulls_url":"https://api.github.com/repos/andela/project-ginsan/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/project-ginsan/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/project-ginsan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/project-ginsan/labels{/name}","releases_url":"https://api.github.com/repos/andela/project-ginsan/releases{/id}","deployments_url":"https://api.github.com/repos/andela/project-ginsan/deployments","created_at":"2016-09-05T10:26:31Z","updated_at":"2016-10-06T16:16:51Z","pushed_at":"2016-10-10T00:23:48Z","git_url":"git://github.com/andela/project-ginsan.git","ssh_url":"git@github.com:andela/project-ginsan.git","clone_url":"https://github.com/andela/project-ginsan.git","svn_url":"https://github.com/andela/project-ginsan","homepage":null,"size":10644,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"andela:develop","ref":"develop","sha":"290a1c66a2242a2c207987c9ff3c098e1cd7a29a","user":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":67411415,"name":"project-ginsan","full_name":"andela/project-ginsan","owner":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/project-ginsan","description":null,"fork":false,"url":"https://api.github.com/repos/andela/project-ginsan","forks_url":"https://api.github.com/repos/andela/project-ginsan/forks","keys_url":"https://api.github.com/repos/andela/project-ginsan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/project-ginsan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/project-ginsan/teams","hooks_url":"https://api.github.com/repos/andela/project-ginsan/hooks","issue_events_url":"https://api.github.com/repos/andela/project-ginsan/issues/events{/number}","events_url":"https://api.github.com/repos/andela/project-ginsan/events","assignees_url":"https://api.github.com/repos/andela/project-ginsan/assignees{/user}","branches_url":"https://api.github.com/repos/andela/project-ginsan/branches{/branch}","tags_url":"https://api.github.com/repos/andela/project-ginsan/tags","blobs_url":"https://api.github.com/repos/andela/project-ginsan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/project-ginsan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/project-ginsan/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/project-ginsan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/project-ginsan/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/project-ginsan/languages","stargazers_url":"https://api.github.com/repos/andela/project-ginsan/stargazers","contributors_url":"https://api.github.com/repos/andela/project-ginsan/contributors","subscribers_url":"https://api.github.com/repos/andela/project-ginsan/subscribers","subscription_url":"https://api.github.com/repos/andela/project-ginsan/subscription","commits_url":"https://api.github.com/repos/andela/project-ginsan/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/project-ginsan/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/project-ginsan/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/project-ginsan/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/project-ginsan/contents/{+path}","compare_url":"https://api.github.com/repos/andela/project-ginsan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/project-ginsan/merges","archive_url":"https://api.github.com/repos/andela/project-ginsan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/project-ginsan/downloads","issues_url":"https://api.github.com/repos/andela/project-ginsan/issues{/number}","pulls_url":"https://api.github.com/repos/andela/project-ginsan/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/project-ginsan/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/project-ginsan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/project-ginsan/labels{/name}","releases_url":"https://api.github.com/repos/andela/project-ginsan/releases{/id}","deployments_url":"https://api.github.com/repos/andela/project-ginsan/deployments","created_at":"2016-09-05T10:26:31Z","updated_at":"2016-10-06T16:16:51Z","pushed_at":"2016-10-10T00:23:48Z","git_url":"git://github.com/andela/project-ginsan.git","ssh_url":"git@github.com:andela/project-ginsan.git","clone_url":"https://github.com/andela/project-ginsan.git","svn_url":"https://github.com/andela/project-ginsan","homepage":null,"size":10644,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/project-ginsan/pulls/11"},"html":{"href":"https://github.com/andela/project-ginsan/pull/11"},"issue":{"href":"https://api.github.com/repos/andela/project-ginsan/issues/11"},"comments":{"href":"https://api.github.com/repos/andela/project-ginsan/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/project-ginsan/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/project-ginsan/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/project-ginsan/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/andela/project-ginsan/statuses/3f4d61032a887f5a240108034bbac4904642fd19"}}}}
{"actor":{"display_login":"houndci-bot"}}