{"action":"created","comment":{"url":"https://api.github.com/repos/8thlight/cob_spec/pulls/comments/44686958","id":44686958,"diff_hunk":"@@ -0,0 +1,47 @@\n+package util;\n+\n+import org.apache.http.client.methods.*;\n+import org.apache.http.RequestLine;\n+import org.apache.http.ProtocolVersion;\n+import org.apache.http.message.BasicRequestLine;\n+import java.net.URI;\n+import java.net.URISyntaxException;\n+import java.util.Random;\n+\n+public class BogusRequest extends HttpRequestBase {\n+    private final String PROTOCOL = \"HTTP\";\n+\n+    private final String method;\n+    private final URI uri;\n+    private final ProtocolVersion protocolVersion;\n+\n+    public BogusRequest(String uri) throws URISyntaxException {\n+        this.method = generateRandomMethod();\n+        this.uri = new URI(uri);\n+        this.protocolVersion = new ProtocolVersion(PROTOCOL, 1, 1);\n+    }\n+\n+    private String generateRandomMethod() {\n+        String randomMethod = \"\";\n+        Random r = new Random();\n+        for(int i=0; i<8; i++)\n+            randomMethod += (char)(r.nextInt(26) + 'A');\n+        return randomMethod;\n+    }\n+\n+    public String getMethod() {\n+        return method;","path":"src/main/java/util/BogusRequest.java","position":33,"original_position":33,"commit_id":"e3286495b5199a66011575e3a3f7f34a4dffdf76","original_commit_id":"e3286495b5199a66011575e3a3f7f34a4dffdf76","user":{"login":"KevinLiddle","id":753435,"avatar_url":"https://avatars.githubusercontent.com/u/753435?v=3","gravatar_id":"","url":"https://api.github.com/users/KevinLiddle","html_url":"https://github.com/KevinLiddle","followers_url":"https://api.github.com/users/KevinLiddle/followers","following_url":"https://api.github.com/users/KevinLiddle/following{/other_user}","gists_url":"https://api.github.com/users/KevinLiddle/gists{/gist_id}","starred_url":"https://api.github.com/users/KevinLiddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KevinLiddle/subscriptions","organizations_url":"https://api.github.com/users/KevinLiddle/orgs","repos_url":"https://api.github.com/users/KevinLiddle/repos","events_url":"https://api.github.com/users/KevinLiddle/events{/privacy}","received_events_url":"https://api.github.com/users/KevinLiddle/received_events","type":"User","site_admin":false},"body":"Can't you just inline `generateRandomMethod` here?","created_at":"2015-11-12T17:27:49Z","updated_at":"2015-11-12T17:27:49Z","html_url":"https://github.com/8thlight/cob_spec/pull/41#discussion_r44686958","pull_request_url":"https://api.github.com/repos/8thlight/cob_spec/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/8thlight/cob_spec/pulls/comments/44686958"},"html":{"href":"https://github.com/8thlight/cob_spec/pull/41#discussion_r44686958"},"pull_request":{"href":"https://api.github.com/repos/8thlight/cob_spec/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/8thlight/cob_spec/pulls/41","id":50308483,"html_url":"https://github.com/8thlight/cob_spec/pull/41","diff_url":"https://github.com/8thlight/cob_spec/pull/41.diff","patch_url":"https://github.com/8thlight/cob_spec/pull/41.patch","issue_url":"https://api.github.com/repos/8thlight/cob_spec/issues/41","number":41,"state":"open","locked":false,"title":"MethodNotAllowed test enforces whitelisting","user":{"login":"swalker-","id":3260649,"avatar_url":"https://avatars.githubusercontent.com/u/3260649?v=3","gravatar_id":"","url":"https://api.github.com/users/swalker-","html_url":"https://github.com/swalker-","followers_url":"https://api.github.com/users/swalker-/followers","following_url":"https://api.github.com/users/swalker-/following{/other_user}","gists_url":"https://api.github.com/users/swalker-/gists{/gist_id}","starred_url":"https://api.github.com/users/swalker-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swalker-/subscriptions","organizations_url":"https://api.github.com/users/swalker-/orgs","repos_url":"https://api.github.com/users/swalker-/repos","events_url":"https://api.github.com/users/swalker-/events{/privacy}","received_events_url":"https://api.github.com/users/swalker-/received_events","type":"User","site_admin":false},"body":"- Instead of testing specific routes (which may encourage blacklisting\r\n  routes), the test generates a request with a bogus, random method.\r\n\r\n@KevinLiddle @dougbradbury \r\nAs mentioned during our IPM, the 'execute' method of a request expects an HttpRequestBase (which only allows GET, PUT, POST, etc). 'Execute' has an overloaded method that accepts a HttpUriRequest which BogusRequest implements. The only purpose of BogusRequest is to generate a request with a bogus, randomized method name. \r\n\r\nThe test checks:\r\n- Response code 200 with GET (since the resources are located in the public folder)\r\n- Response code 405 for PUT/POST (original tests. I leave them in so that people will not create logic that looks like \"if (!Http.Methods.Contains(method)) { return 405; }\")\r\n- Response code 405 for bogusRequest (forces a whitelist approach)","created_at":"2015-11-10T20:44:53Z","updated_at":"2015-11-12T17:27:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"217f99197702a96b41589baf914522d39bf9bee4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/8thlight/cob_spec/pulls/41/commits","review_comments_url":"https://api.github.com/repos/8thlight/cob_spec/pulls/41/comments","review_comment_url":"https://api.github.com/repos/8thlight/cob_spec/pulls/comments{/number}","comments_url":"https://api.github.com/repos/8thlight/cob_spec/issues/41/comments","statuses_url":"https://api.github.com/repos/8thlight/cob_spec/statuses/e3286495b5199a66011575e3a3f7f34a4dffdf76","head":{"label":"8thlight:method-not-allowed","ref":"method-not-allowed","sha":"e3286495b5199a66011575e3a3f7f34a4dffdf76","user":{"login":"8thlight","id":69132,"avatar_url":"https://avatars.githubusercontent.com/u/69132?v=3","gravatar_id":"","url":"https://api.github.com/users/8thlight","html_url":"https://github.com/8thlight","followers_url":"https://api.github.com/users/8thlight/followers","following_url":"https://api.github.com/users/8thlight/following{/other_user}","gists_url":"https://api.github.com/users/8thlight/gists{/gist_id}","starred_url":"https://api.github.com/users/8thlight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8thlight/subscriptions","organizations_url":"https://api.github.com/users/8thlight/orgs","repos_url":"https://api.github.com/users/8thlight/repos","events_url":"https://api.github.com/users/8thlight/events{/privacy}","received_events_url":"https://api.github.com/users/8thlight/received_events","type":"Organization","site_admin":false},"repo":{"id":1777767,"name":"cob_spec","full_name":"8thlight/cob_spec","owner":{"login":"8thlight","id":69132,"avatar_url":"https://avatars.githubusercontent.com/u/69132?v=3","gravatar_id":"","url":"https://api.github.com/users/8thlight","html_url":"https://github.com/8thlight","followers_url":"https://api.github.com/users/8thlight/followers","following_url":"https://api.github.com/users/8thlight/following{/other_user}","gists_url":"https://api.github.com/users/8thlight/gists{/gist_id}","starred_url":"https://api.github.com/users/8thlight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8thlight/subscriptions","organizations_url":"https://api.github.com/users/8thlight/orgs","repos_url":"https://api.github.com/users/8thlight/repos","events_url":"https://api.github.com/users/8thlight/events{/privacy}","received_events_url":"https://api.github.com/users/8thlight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/8thlight/cob_spec","description":"A fitnesse suite for a web server","fork":false,"url":"https://api.github.com/repos/8thlight/cob_spec","forks_url":"https://api.github.com/repos/8thlight/cob_spec/forks","keys_url":"https://api.github.com/repos/8thlight/cob_spec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/8thlight/cob_spec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/8thlight/cob_spec/teams","hooks_url":"https://api.github.com/repos/8thlight/cob_spec/hooks","issue_events_url":"https://api.github.com/repos/8thlight/cob_spec/issues/events{/number}","events_url":"https://api.github.com/repos/8thlight/cob_spec/events","assignees_url":"https://api.github.com/repos/8thlight/cob_spec/assignees{/user}","branches_url":"https://api.github.com/repos/8thlight/cob_spec/branches{/branch}","tags_url":"https://api.github.com/repos/8thlight/cob_spec/tags","blobs_url":"https://api.github.com/repos/8thlight/cob_spec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/8thlight/cob_spec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/8thlight/cob_spec/git/refs{/sha}","trees_url":"https://api.github.com/repos/8thlight/cob_spec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/8thlight/cob_spec/statuses/{sha}","languages_url":"https://api.github.com/repos/8thlight/cob_spec/languages","stargazers_url":"https://api.github.com/repos/8thlight/cob_spec/stargazers","contributors_url":"https://api.github.com/repos/8thlight/cob_spec/contributors","subscribers_url":"https://api.github.com/repos/8thlight/cob_spec/subscribers","subscription_url":"https://api.github.com/repos/8thlight/cob_spec/subscription","commits_url":"https://api.github.com/repos/8thlight/cob_spec/commits{/sha}","git_commits_url":"https://api.github.com/repos/8thlight/cob_spec/git/commits{/sha}","comments_url":"https://api.github.com/repos/8thlight/cob_spec/comments{/number}","issue_comment_url":"https://api.github.com/repos/8thlight/cob_spec/issues/comments{/number}","contents_url":"https://api.github.com/repos/8thlight/cob_spec/contents/{+path}","compare_url":"https://api.github.com/repos/8thlight/cob_spec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/8thlight/cob_spec/merges","archive_url":"https://api.github.com/repos/8thlight/cob_spec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/8thlight/cob_spec/downloads","issues_url":"https://api.github.com/repos/8thlight/cob_spec/issues{/number}","pulls_url":"https://api.github.com/repos/8thlight/cob_spec/pulls{/number}","milestones_url":"https://api.github.com/repos/8thlight/cob_spec/milestones{/number}","notifications_url":"https://api.github.com/repos/8thlight/cob_spec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/8thlight/cob_spec/labels{/name}","releases_url":"https://api.github.com/repos/8thlight/cob_spec/releases{/id}","created_at":"2011-05-20T18:16:05Z","updated_at":"2015-06-21T00:33:43Z","pushed_at":"2015-11-11T21:57:48Z","git_url":"git://github.com/8thlight/cob_spec.git","ssh_url":"git@github.com:8thlight/cob_spec.git","clone_url":"https://github.com/8thlight/cob_spec.git","svn_url":"https://github.com/8thlight/cob_spec","homepage":"","size":19393,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":11,"forks":14,"open_issues":11,"watchers":8,"default_branch":"master"}},"base":{"label":"8thlight:master","ref":"master","sha":"e86c130224897e062d6ad4d58ae05d61345530a2","user":{"login":"8thlight","id":69132,"avatar_url":"https://avatars.githubusercontent.com/u/69132?v=3","gravatar_id":"","url":"https://api.github.com/users/8thlight","html_url":"https://github.com/8thlight","followers_url":"https://api.github.com/users/8thlight/followers","following_url":"https://api.github.com/users/8thlight/following{/other_user}","gists_url":"https://api.github.com/users/8thlight/gists{/gist_id}","starred_url":"https://api.github.com/users/8thlight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8thlight/subscriptions","organizations_url":"https://api.github.com/users/8thlight/orgs","repos_url":"https://api.github.com/users/8thlight/repos","events_url":"https://api.github.com/users/8thlight/events{/privacy}","received_events_url":"https://api.github.com/users/8thlight/received_events","type":"Organization","site_admin":false},"repo":{"id":1777767,"name":"cob_spec","full_name":"8thlight/cob_spec","owner":{"login":"8thlight","id":69132,"avatar_url":"https://avatars.githubusercontent.com/u/69132?v=3","gravatar_id":"","url":"https://api.github.com/users/8thlight","html_url":"https://github.com/8thlight","followers_url":"https://api.github.com/users/8thlight/followers","following_url":"https://api.github.com/users/8thlight/following{/other_user}","gists_url":"https://api.github.com/users/8thlight/gists{/gist_id}","starred_url":"https://api.github.com/users/8thlight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8thlight/subscriptions","organizations_url":"https://api.github.com/users/8thlight/orgs","repos_url":"https://api.github.com/users/8thlight/repos","events_url":"https://api.github.com/users/8thlight/events{/privacy}","received_events_url":"https://api.github.com/users/8thlight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/8thlight/cob_spec","description":"A fitnesse suite for a web server","fork":false,"url":"https://api.github.com/repos/8thlight/cob_spec","forks_url":"https://api.github.com/repos/8thlight/cob_spec/forks","keys_url":"https://api.github.com/repos/8thlight/cob_spec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/8thlight/cob_spec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/8thlight/cob_spec/teams","hooks_url":"https://api.github.com/repos/8thlight/cob_spec/hooks","issue_events_url":"https://api.github.com/repos/8thlight/cob_spec/issues/events{/number}","events_url":"https://api.github.com/repos/8thlight/cob_spec/events","assignees_url":"https://api.github.com/repos/8thlight/cob_spec/assignees{/user}","branches_url":"https://api.github.com/repos/8thlight/cob_spec/branches{/branch}","tags_url":"https://api.github.com/repos/8thlight/cob_spec/tags","blobs_url":"https://api.github.com/repos/8thlight/cob_spec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/8thlight/cob_spec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/8thlight/cob_spec/git/refs{/sha}","trees_url":"https://api.github.com/repos/8thlight/cob_spec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/8thlight/cob_spec/statuses/{sha}","languages_url":"https://api.github.com/repos/8thlight/cob_spec/languages","stargazers_url":"https://api.github.com/repos/8thlight/cob_spec/stargazers","contributors_url":"https://api.github.com/repos/8thlight/cob_spec/contributors","subscribers_url":"https://api.github.com/repos/8thlight/cob_spec/subscribers","subscription_url":"https://api.github.com/repos/8thlight/cob_spec/subscription","commits_url":"https://api.github.com/repos/8thlight/cob_spec/commits{/sha}","git_commits_url":"https://api.github.com/repos/8thlight/cob_spec/git/commits{/sha}","comments_url":"https://api.github.com/repos/8thlight/cob_spec/comments{/number}","issue_comment_url":"https://api.github.com/repos/8thlight/cob_spec/issues/comments{/number}","contents_url":"https://api.github.com/repos/8thlight/cob_spec/contents/{+path}","compare_url":"https://api.github.com/repos/8thlight/cob_spec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/8thlight/cob_spec/merges","archive_url":"https://api.github.com/repos/8thlight/cob_spec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/8thlight/cob_spec/downloads","issues_url":"https://api.github.com/repos/8thlight/cob_spec/issues{/number}","pulls_url":"https://api.github.com/repos/8thlight/cob_spec/pulls{/number}","milestones_url":"https://api.github.com/repos/8thlight/cob_spec/milestones{/number}","notifications_url":"https://api.github.com/repos/8thlight/cob_spec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/8thlight/cob_spec/labels{/name}","releases_url":"https://api.github.com/repos/8thlight/cob_spec/releases{/id}","created_at":"2011-05-20T18:16:05Z","updated_at":"2015-06-21T00:33:43Z","pushed_at":"2015-11-11T21:57:48Z","git_url":"git://github.com/8thlight/cob_spec.git","ssh_url":"git@github.com:8thlight/cob_spec.git","clone_url":"https://github.com/8thlight/cob_spec.git","svn_url":"https://github.com/8thlight/cob_spec","homepage":"","size":19393,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":11,"forks":14,"open_issues":11,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/8thlight/cob_spec/pulls/41"},"html":{"href":"https://github.com/8thlight/cob_spec/pull/41"},"issue":{"href":"https://api.github.com/repos/8thlight/cob_spec/issues/41"},"comments":{"href":"https://api.github.com/repos/8thlight/cob_spec/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/8thlight/cob_spec/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/8thlight/cob_spec/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/8thlight/cob_spec/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/8thlight/cob_spec/statuses/e3286495b5199a66011575e3a3f7f34a4dffdf76"}}}}