{"action":"created","comment":{"url":"https://api.github.com/repos/Mashape/kong/pulls/comments/100167954","pull_request_review_id":20866461,"id":100167954,"diff_hunk":"@@ -771,31 +771,52 @@ describe(\"Router\", function()\n         router = assert(Router.new(use_case_apis))\n       end)\n \n-      it(\"uses the request's Host header if preserve_host\", function()\n-        local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = \"preserve.com\" })\n+      describe(\"when preserve_host is true\", function()\n+        local host = \"preserve.com\"\n \n-        local api, _, upstream_host, _, host_header = router.exec(_ngx)\n-        assert.same(use_case_apis[1], api)\n-        assert.equal(\"httpbin.org\", upstream_host)\n-        assert.equal(\"preserve.com\", host_header)\n-      end)\n+        it(\"uses the request's Host header\", function()\n+          local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = host })\n \n-      it(\"uses the request's Host header incl. port if preserve_host\", function()\n-        local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = \"preserve.com:123\" })\n+          local api, _, _, _, host_header = router.exec(_ngx)\n+          assert.same(use_case_apis[1], api)\n+          assert.equal(host, host_header)\n+        end)\n \n-        local api, _, upstream_host, _, host_header = router.exec(_ngx)\n-        assert.same(use_case_apis[1], api)\n-        assert.equal(\"httpbin.org\", upstream_host)\n-        assert.equal(\"preserve.com:123\", host_header)\n+        it(\"uses the request's Host header incl. port\", function()\n+          local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = host .. \":123\" })\n+\n+          local api, _, _, _, host_header = router.exec(_ngx)\n+          assert.same(use_case_apis[1], api)\n+          assert.equal(host .. \":123\", host_header)\n+        end)\n+\n+        it(\"does not change the target upstream\", function()\n+          local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = host })\n+\n+          local api, _, upstream_host, _, _ = router.exec(_ngx)\n+          assert.same(use_case_apis[1], api)\n+          assert.equal(\"httpbin.org\", upstream_host)\n+        end)\n       end)\n \n-      it(\"uses the API's upstream_url host if not preserve_host\", function()\n-        local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = \"discard.com\" })\n+      describe(\"when preserve_host is false\", function()\n+        local host = \"discard.com\"\n \n-        local api, _, upstream_host, _, host_header = router.exec(_ngx)\n-        assert.same(use_case_apis[2], api)\n-        assert.equal(\"httpbin.org\", upstream_host)\n-        assert.is_nil(host_header)\n+        it(\"does not change the target upstream\", function()\n+          local _ngx = mock_ngx(\"GET\", \"/\", { [\"host\"] = host })\n+\n+          local api, _, upstream_host, _, host_header = router.exec(_ngx)","path":"spec/01-unit/12-router_spec.lua","position":57,"original_position":57,"commit_id":"50115dca964f41ae2ea013c1a36c4b1b55e6795b","original_commit_id":"50115dca964f41ae2ea013c1a36c4b1b55e6795b","user":{"login":"thibaultcha","id":1125431,"avatar_url":"https://avatars.githubusercontent.com/u/1125431?v=3","gravatar_id":"","url":"https://api.github.com/users/thibaultcha","html_url":"https://github.com/thibaultcha","followers_url":"https://api.github.com/users/thibaultcha/followers","following_url":"https://api.github.com/users/thibaultcha/following{/other_user}","gists_url":"https://api.github.com/users/thibaultcha/gists{/gist_id}","starred_url":"https://api.github.com/users/thibaultcha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thibaultcha/subscriptions","organizations_url":"https://api.github.com/users/thibaultcha/orgs","repos_url":"https://api.github.com/users/thibaultcha/repos","events_url":"https://api.github.com/users/thibaultcha/events{/privacy}","received_events_url":"https://api.github.com/users/thibaultcha/received_events","type":"User","site_admin":false},"body":"The unused `host_header` is making the linting fail. I think we can remove the last two variables `_, host_header` for this test.","created_at":"2017-02-08T20:56:56Z","updated_at":"2017-02-08T20:57:00Z","html_url":"https://github.com/Mashape/kong/pull/2059#discussion_r100167954","pull_request_url":"https://api.github.com/repos/Mashape/kong/pulls/2059","_links":{"self":{"href":"https://api.github.com/repos/Mashape/kong/pulls/comments/100167954"},"html":{"href":"https://github.com/Mashape/kong/pull/2059#discussion_r100167954"},"pull_request":{"href":"https://api.github.com/repos/Mashape/kong/pulls/2059"}}},"pull_request":{"url":"https://api.github.com/repos/Mashape/kong/pulls/2059","id":105302505,"html_url":"https://github.com/Mashape/kong/pull/2059","diff_url":"https://github.com/Mashape/kong/pull/2059.diff","patch_url":"https://github.com/Mashape/kong/pull/2059.patch","issue_url":"https://api.github.com/repos/Mashape/kong/issues/2059","number":2059,"state":"open","locked":false,"title":"Refactor the preserve_host specs","user":{"login":"cheald","id":9830,"avatar_url":"https://avatars.githubusercontent.com/u/9830?v=3","gravatar_id":"","url":"https://api.github.com/users/cheald","html_url":"https://github.com/cheald","followers_url":"https://api.github.com/users/cheald/followers","following_url":"https://api.github.com/users/cheald/following{/other_user}","gists_url":"https://api.github.com/users/cheald/gists{/gist_id}","starred_url":"https://api.github.com/users/cheald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheald/subscriptions","organizations_url":"https://api.github.com/users/cheald/orgs","repos_url":"https://api.github.com/users/cheald/repos","events_url":"https://api.github.com/users/cheald/events{/privacy}","received_events_url":"https://api.github.com/users/cheald/received_events","type":"User","site_admin":false},"body":"Specs are now explicit about testing the issue surfaced in #2052 (preservation of upstream_host)\r\n\r\n### Summary\r\n\r\nThe changes in 37e8ed30c68d592ddd54cd3ccf6b3ccffe453f1a added specs which incidentally cover the issue of the incorrect upstream_host being returned from the router when `preserve_host = true`. This just refactors those tests to be explicit about that test, and to assert a single case per test.\r\n\r\n### Full changelog\r\n\r\n* Refactored router preserve_host tests\r\n\r\n### Issues resolved\r\n\r\n* Fulfills the requirements to close #2052\r\n","created_at":"2017-02-08T20:52:51Z","updated_at":"2017-02-08T20:57:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3b60c00a3833128d933595a59530b0b9285b39d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Mashape/kong/pulls/2059/commits","review_comments_url":"https://api.github.com/repos/Mashape/kong/pulls/2059/comments","review_comment_url":"https://api.github.com/repos/Mashape/kong/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Mashape/kong/issues/2059/comments","statuses_url":"https://api.github.com/repos/Mashape/kong/statuses/50115dca964f41ae2ea013c1a36c4b1b55e6795b","head":{"label":"cheald:refactor-router-specs","ref":"refactor-router-specs","sha":"50115dca964f41ae2ea013c1a36c4b1b55e6795b","user":{"login":"cheald","id":9830,"avatar_url":"https://avatars.githubusercontent.com/u/9830?v=3","gravatar_id":"","url":"https://api.github.com/users/cheald","html_url":"https://github.com/cheald","followers_url":"https://api.github.com/users/cheald/followers","following_url":"https://api.github.com/users/cheald/following{/other_user}","gists_url":"https://api.github.com/users/cheald/gists{/gist_id}","starred_url":"https://api.github.com/users/cheald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheald/subscriptions","organizations_url":"https://api.github.com/users/cheald/orgs","repos_url":"https://api.github.com/users/cheald/repos","events_url":"https://api.github.com/users/cheald/events{/privacy}","received_events_url":"https://api.github.com/users/cheald/received_events","type":"User","site_admin":false},"repo":{"id":81374489,"name":"kong","full_name":"cheald/kong","owner":{"login":"cheald","id":9830,"avatar_url":"https://avatars.githubusercontent.com/u/9830?v=3","gravatar_id":"","url":"https://api.github.com/users/cheald","html_url":"https://github.com/cheald","followers_url":"https://api.github.com/users/cheald/followers","following_url":"https://api.github.com/users/cheald/following{/other_user}","gists_url":"https://api.github.com/users/cheald/gists{/gist_id}","starred_url":"https://api.github.com/users/cheald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheald/subscriptions","organizations_url":"https://api.github.com/users/cheald/orgs","repos_url":"https://api.github.com/users/cheald/repos","events_url":"https://api.github.com/users/cheald/events{/privacy}","received_events_url":"https://api.github.com/users/cheald/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cheald/kong","description":":monkey: The API Gateway & Microservice Management Layer, built on NGINX","fork":true,"url":"https://api.github.com/repos/cheald/kong","forks_url":"https://api.github.com/repos/cheald/kong/forks","keys_url":"https://api.github.com/repos/cheald/kong/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cheald/kong/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cheald/kong/teams","hooks_url":"https://api.github.com/repos/cheald/kong/hooks","issue_events_url":"https://api.github.com/repos/cheald/kong/issues/events{/number}","events_url":"https://api.github.com/repos/cheald/kong/events","assignees_url":"https://api.github.com/repos/cheald/kong/assignees{/user}","branches_url":"https://api.github.com/repos/cheald/kong/branches{/branch}","tags_url":"https://api.github.com/repos/cheald/kong/tags","blobs_url":"https://api.github.com/repos/cheald/kong/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cheald/kong/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cheald/kong/git/refs{/sha}","trees_url":"https://api.github.com/repos/cheald/kong/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cheald/kong/statuses/{sha}","languages_url":"https://api.github.com/repos/cheald/kong/languages","stargazers_url":"https://api.github.com/repos/cheald/kong/stargazers","contributors_url":"https://api.github.com/repos/cheald/kong/contributors","subscribers_url":"https://api.github.com/repos/cheald/kong/subscribers","subscription_url":"https://api.github.com/repos/cheald/kong/subscription","commits_url":"https://api.github.com/repos/cheald/kong/commits{/sha}","git_commits_url":"https://api.github.com/repos/cheald/kong/git/commits{/sha}","comments_url":"https://api.github.com/repos/cheald/kong/comments{/number}","issue_comment_url":"https://api.github.com/repos/cheald/kong/issues/comments{/number}","contents_url":"https://api.github.com/repos/cheald/kong/contents/{+path}","compare_url":"https://api.github.com/repos/cheald/kong/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cheald/kong/merges","archive_url":"https://api.github.com/repos/cheald/kong/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cheald/kong/downloads","issues_url":"https://api.github.com/repos/cheald/kong/issues{/number}","pulls_url":"https://api.github.com/repos/cheald/kong/pulls{/number}","milestones_url":"https://api.github.com/repos/cheald/kong/milestones{/number}","notifications_url":"https://api.github.com/repos/cheald/kong/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cheald/kong/labels{/name}","releases_url":"https://api.github.com/repos/cheald/kong/releases{/id}","deployments_url":"https://api.github.com/repos/cheald/kong/deployments","created_at":"2017-02-08T20:48:19Z","updated_at":"2017-02-08T20:48:22Z","pushed_at":"2017-02-08T20:48:53Z","git_url":"git://github.com/cheald/kong.git","ssh_url":"git@github.com:cheald/kong.git","clone_url":"https://github.com/cheald/kong.git","svn_url":"https://github.com/cheald/kong","homepage":"https://getkong.org/","size":5431,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Mashape:release/0.10.0","ref":"release/0.10.0","sha":"37e8ed30c68d592ddd54cd3ccf6b3ccffe453f1a","user":{"login":"Mashape","id":962416,"avatar_url":"https://avatars.githubusercontent.com/u/962416?v=3","gravatar_id":"","url":"https://api.github.com/users/Mashape","html_url":"https://github.com/Mashape","followers_url":"https://api.github.com/users/Mashape/followers","following_url":"https://api.github.com/users/Mashape/following{/other_user}","gists_url":"https://api.github.com/users/Mashape/gists{/gist_id}","starred_url":"https://api.github.com/users/Mashape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mashape/subscriptions","organizations_url":"https://api.github.com/users/Mashape/orgs","repos_url":"https://api.github.com/users/Mashape/repos","events_url":"https://api.github.com/users/Mashape/events{/privacy}","received_events_url":"https://api.github.com/users/Mashape/received_events","type":"Organization","site_admin":false},"repo":{"id":26783295,"name":"kong","full_name":"Mashape/kong","owner":{"login":"Mashape","id":962416,"avatar_url":"https://avatars.githubusercontent.com/u/962416?v=3","gravatar_id":"","url":"https://api.github.com/users/Mashape","html_url":"https://github.com/Mashape","followers_url":"https://api.github.com/users/Mashape/followers","following_url":"https://api.github.com/users/Mashape/following{/other_user}","gists_url":"https://api.github.com/users/Mashape/gists{/gist_id}","starred_url":"https://api.github.com/users/Mashape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mashape/subscriptions","organizations_url":"https://api.github.com/users/Mashape/orgs","repos_url":"https://api.github.com/users/Mashape/repos","events_url":"https://api.github.com/users/Mashape/events{/privacy}","received_events_url":"https://api.github.com/users/Mashape/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Mashape/kong","description":":monkey: The API Gateway & Microservice Management Layer, built on NGINX","fork":false,"url":"https://api.github.com/repos/Mashape/kong","forks_url":"https://api.github.com/repos/Mashape/kong/forks","keys_url":"https://api.github.com/repos/Mashape/kong/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mashape/kong/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mashape/kong/teams","hooks_url":"https://api.github.com/repos/Mashape/kong/hooks","issue_events_url":"https://api.github.com/repos/Mashape/kong/issues/events{/number}","events_url":"https://api.github.com/repos/Mashape/kong/events","assignees_url":"https://api.github.com/repos/Mashape/kong/assignees{/user}","branches_url":"https://api.github.com/repos/Mashape/kong/branches{/branch}","tags_url":"https://api.github.com/repos/Mashape/kong/tags","blobs_url":"https://api.github.com/repos/Mashape/kong/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mashape/kong/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mashape/kong/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mashape/kong/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mashape/kong/statuses/{sha}","languages_url":"https://api.github.com/repos/Mashape/kong/languages","stargazers_url":"https://api.github.com/repos/Mashape/kong/stargazers","contributors_url":"https://api.github.com/repos/Mashape/kong/contributors","subscribers_url":"https://api.github.com/repos/Mashape/kong/subscribers","subscription_url":"https://api.github.com/repos/Mashape/kong/subscription","commits_url":"https://api.github.com/repos/Mashape/kong/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mashape/kong/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mashape/kong/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mashape/kong/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mashape/kong/contents/{+path}","compare_url":"https://api.github.com/repos/Mashape/kong/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mashape/kong/merges","archive_url":"https://api.github.com/repos/Mashape/kong/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mashape/kong/downloads","issues_url":"https://api.github.com/repos/Mashape/kong/issues{/number}","pulls_url":"https://api.github.com/repos/Mashape/kong/pulls{/number}","milestones_url":"https://api.github.com/repos/Mashape/kong/milestones{/number}","notifications_url":"https://api.github.com/repos/Mashape/kong/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mashape/kong/labels{/name}","releases_url":"https://api.github.com/repos/Mashape/kong/releases{/id}","deployments_url":"https://api.github.com/repos/Mashape/kong/deployments","created_at":"2014-11-17T23:56:08Z","updated_at":"2017-02-08T19:07:16Z","pushed_at":"2017-02-08T20:52:53Z","git_url":"git://github.com/Mashape/kong.git","ssh_url":"git@github.com:Mashape/kong.git","clone_url":"https://github.com/Mashape/kong.git","svn_url":"https://github.com/Mashape/kong","homepage":"https://getkong.org/","size":5431,"stargazers_count":8421,"watchers_count":8421,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":861,"mirror_url":null,"open_issues_count":332,"forks":861,"open_issues":332,"watchers":8421,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Mashape/kong/pulls/2059"},"html":{"href":"https://github.com/Mashape/kong/pull/2059"},"issue":{"href":"https://api.github.com/repos/Mashape/kong/issues/2059"},"comments":{"href":"https://api.github.com/repos/Mashape/kong/issues/2059/comments"},"review_comments":{"href":"https://api.github.com/repos/Mashape/kong/pulls/2059/comments"},"review_comment":{"href":"https://api.github.com/repos/Mashape/kong/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Mashape/kong/pulls/2059/commits"},"statuses":{"href":"https://api.github.com/repos/Mashape/kong/statuses/50115dca964f41ae2ea013c1a36c4b1b55e6795b"}}}}
{"actor":{"display_login":"thibaultcha"}}