{"action":"created","comment":{"url":"https://api.github.com/repos/rapid7/nexpose-client/pulls/comments/25465893","id":25465893,"diff_hunk":"@@ -0,0 +1,133 @@\n+module Nexpose\n+\n+  class Wait\n+    attr_reader :error_message, :ready, :retry_count, :timeout, :polling_interval\n+\n+\n+    def initialize(retry_count: nil, timeout: nil, polling_interval: nil)\n+      @error_message = \"Default General Failure in Nexpose::Wait\"\n+      @ready = false\n+      @retry_count = retry_count.nil? ? 0 : retry_count\n+      @timeout = timeout\n+      @polling_interval = polling_interval\n+    end\n+\n+\n+    def is_ready?\n+      @ready\n+    end\n+\n+\n+    def for_report(nsc: nil, report_id: nil)\n+      begin\n+        poller = Nexpose::Poller.new(timeout: @timeout, polling_interval: @polling_interval)","path":"lib/nexpose/wait.rb","position":23,"original_position":23,"commit_id":"639f54dab9ead13be77712bc080377e957ed5315","original_commit_id":"639f54dab9ead13be77712bc080377e957ed5315","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [92/80]","created_at":"2015-02-26T21:25:28Z","updated_at":"2015-02-26T21:25:28Z","html_url":"https://github.com/rapid7/nexpose-client/pull/122#discussion_r25465893","pull_request_url":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122","_links":{"self":{"href":"https://api.github.com/repos/rapid7/nexpose-client/pulls/comments/25465893"},"html":{"href":"https://github.com/rapid7/nexpose-client/pull/122#discussion_r25465893"},"pull_request":{"href":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122"}}},"pull_request":{"url":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122","id":30117933,"html_url":"https://github.com/rapid7/nexpose-client/pull/122","diff_url":"https://github.com/rapid7/nexpose-client/pull/122.diff","patch_url":"https://github.com/rapid7/nexpose-client/pull/122.patch","issue_url":"https://api.github.com/repos/rapid7/nexpose-client/issues/122","number":122,"state":"open","locked":false,"title":"Wait update","user":{"login":"sgreen-r7","id":10285110,"avatar_url":"https://avatars.githubusercontent.com/u/10285110?v=3","gravatar_id":"","url":"https://api.github.com/users/sgreen-r7","html_url":"https://github.com/sgreen-r7","followers_url":"https://api.github.com/users/sgreen-r7/followers","following_url":"https://api.github.com/users/sgreen-r7/following{/other_user}","gists_url":"https://api.github.com/users/sgreen-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/sgreen-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgreen-r7/subscriptions","organizations_url":"https://api.github.com/users/sgreen-r7/orgs","repos_url":"https://api.github.com/users/sgreen-r7/repos","events_url":"https://api.github.com/users/sgreen-r7/events{/privacy}","received_events_url":"https://api.github.com/users/sgreen-r7/received_events","type":"User","site_admin":false},"body":"### Timeout Errors:\r\nCurrently using all of the wait methods, if the Timeout is reached, the error gets swallowed up by the surrounding code and errors do not get printed to the logs.\r\n\r\nThis causes the tests using these methods to continue with their test as if nothing bad has happened. \r\n\r\nExample:\r\n\r\n\tWhen /^the user configures a report on the asset while still in that state$/ do\r\n\t  config = Nexpose::ReportConfig.new(\"cucumber report-#{@site.id}.csv\", NSC.get_csv_template(@console), 'csv')\r\n\t  config.add_filter('site', @site.id)\r\n\t  config.save(@console, true)\r\n\t  at_scenario_exit { @console.delete_report_config(config.id) }\r\n\t  NSC.wait_for_report(@console, config.id)\r\n\t  @tmp_report = NSC.download_report(@console, @site.id, config.id)\r\n\tend\r\n\r\nIn the above example, if the `wait_for_report` hits a timeout, the next line `download_report` executes as if everything is okay.\r\n\r\n\r\n---\r\n\r\n### Current Landscape:\r\n \r\n#### wait_until (71)\r\nscanning status and scan integration, as well as waiting on UI elements. \r\n\r\n\r\n#### wait_for_report (37)\r\ngenerally only used when the next step is to download a CSV report, or verifying a report's status.\r\n\r\n\r\n#### wait_for_integration (84)\r\nused to wait for scan_status to become 'finished', or other passed in status. \r\n\r\n\r\n#### sleep (35)\r\nmostly seems to be used to slow down the UI after click events. however, other instances are used instead of the above methods.\r\n\r\n\r\n---\r\n\r\n\r\n### Proposed Enhancements: \r\n\r\nThe Nexpose-client gem can contain the following Wait object, to help deal with the Timeout concerns.\r\n\r\nCurrently [`Nexpose::Wait`](https://github.com/sgreen-r7/nexpose-client/blob/wait_update/lib/nexpose/wait.rb) has the following methods:\r\n`for_report`\r\n`for_integration`\r\n`for_judgement`\r\n\r\n\r\n`for_report` would replace `wait_for_report`  \r\n`for_integration` would replace `wait_for_integration`  \r\n`for_judgement` would _hopefully_ _mostly_ replace `wait_until`\r\n\r\n\r\n\r\nSo our example at the beginning for waiting on reports would look something like this now:\r\n\r\n\tWhen /^the user configures a report on the asset while still in that state$/ do\r\n\t config = Nexpose::ReportConfig.new(\"cucumber report-#{@site.id}.csv\", NSC.get_csv_template(@console), 'csv')\r\n\t config.add_filter('site', @site.id)\r\n\t config.save(@console, true)\r\n\t at_scenario_exit { @console.delete_report_config(config.id) }\r\n\r\n\t report_wait = Nexpose::Wait.new\r\n\t report_wait.for_report( nsc: @console, report_id: config.id )\r\n\t unless report_wait.is_ready?\r\n\t   expect(report_wait).to be_true, report_wait.error_message\r\n\t end\r\n\r\n\t @tmp_report = NSC.download_report(@console, @site.id, config.id)\r\n\tend\r\n\r\n\r\nOr you could wrap `is_ready?` in an if block (shown with adjusting the timeout, and having it retry if it fails):\r\n\r\n\tWhen /^the user configures a report on the asset while still in that state$/ do\r\n\t config = Nexpose::ReportConfig.new(\"cucumber report-#{@site.id}.csv\", NSC.get_csv_template(@console), 'csv')\r\n\t config.add_filter('site', @site.id)\r\n\t config.save(@console, true)\r\n\t at_scenario_exit { @console.delete_report_config(config.id) }\r\n\r\n\t report_wait = Nexpose::Wait.new(timeout: 60, retry: 2)\r\n\t report_wait.for_report( nsc: @console, report_id: config.id )\r\n\t if report_wait.is_ready?\r\n\t \t@tmp_report = NSC.download_report(@console, @site.id, config.id)\r\n\t else\r\n\t   expect(report_wait).to be_true, report_wait.error_message\r\n\t end\r\n\t \r\n\tend\r\n\r\n\r\n---\r\n\r\n\r\n### Nexpose::Wait.new\r\n\r\nCalling a new `Nexpose::Wait` object will allow you to initialize with the following options, which uses Ruby keyword arguments:\r\n\r\n`error_message`: Overwrite the default error message.  \r\n`retry_count`: The number of times to retry the wait if we hit the timeout limit.  \r\n`timeout`: Number of seconds before we consider the request timed out.  \r\n`polling_interval`: Number of seconds to sleep before we retry to execute for the desired result.  \r\n\r\n`Nexpose::Wait.new( retry_count: 3, timeout: 120, polling_interval: 1 )`\r\n\r\n\r\n\r\n<dl>\r\n  <dt>for_report</dt>\r\n  <dd>pass in nsc connection, and report config id.</dd>\r\n\r\n  <dt>for_integration</dt>\r\n  <dd>pass in nsc connection, scan id, and status that you're looking for.</dd>\r\n  \r\n   <dt>for_judgement</dt>\r\n  <dd>pass in a proc, and an optional description to display and output if an error or timeout occurs.</dd>\r\n</dl>\r\n\r\n\r\nAll `for_` methods support outputting an error message for timeouts, and additionally support API errors, and NoMethodErrors if reports or scans don't exist. \r\n\r\n","created_at":"2015-02-26T21:25:22Z","updated_at":"2015-02-26T21:25:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"871e2804fdbcb68fdd348e16e9beadd2705455bd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122/commits","review_comments_url":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122/comments","review_comment_url":"https://api.github.com/repos/rapid7/nexpose-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rapid7/nexpose-client/issues/122/comments","statuses_url":"https://api.github.com/repos/rapid7/nexpose-client/statuses/639f54dab9ead13be77712bc080377e957ed5315","head":{"label":"sgreen-r7:wait_update","ref":"wait_update","sha":"639f54dab9ead13be77712bc080377e957ed5315","user":{"login":"sgreen-r7","id":10285110,"avatar_url":"https://avatars.githubusercontent.com/u/10285110?v=3","gravatar_id":"","url":"https://api.github.com/users/sgreen-r7","html_url":"https://github.com/sgreen-r7","followers_url":"https://api.github.com/users/sgreen-r7/followers","following_url":"https://api.github.com/users/sgreen-r7/following{/other_user}","gists_url":"https://api.github.com/users/sgreen-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/sgreen-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgreen-r7/subscriptions","organizations_url":"https://api.github.com/users/sgreen-r7/orgs","repos_url":"https://api.github.com/users/sgreen-r7/repos","events_url":"https://api.github.com/users/sgreen-r7/events{/privacy}","received_events_url":"https://api.github.com/users/sgreen-r7/received_events","type":"User","site_admin":false},"repo":{"id":30619283,"name":"nexpose-client","full_name":"sgreen-r7/nexpose-client","owner":{"login":"sgreen-r7","id":10285110,"avatar_url":"https://avatars.githubusercontent.com/u/10285110?v=3","gravatar_id":"","url":"https://api.github.com/users/sgreen-r7","html_url":"https://github.com/sgreen-r7","followers_url":"https://api.github.com/users/sgreen-r7/followers","following_url":"https://api.github.com/users/sgreen-r7/following{/other_user}","gists_url":"https://api.github.com/users/sgreen-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/sgreen-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgreen-r7/subscriptions","organizations_url":"https://api.github.com/users/sgreen-r7/orgs","repos_url":"https://api.github.com/users/sgreen-r7/repos","events_url":"https://api.github.com/users/sgreen-r7/events{/privacy}","received_events_url":"https://api.github.com/users/sgreen-r7/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sgreen-r7/nexpose-client","description":"Rapid7 Nexpose API client library written in Ruby","fork":true,"url":"https://api.github.com/repos/sgreen-r7/nexpose-client","forks_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/forks","keys_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/teams","hooks_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/hooks","issue_events_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/issues/events{/number}","events_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/events","assignees_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/assignees{/user}","branches_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/branches{/branch}","tags_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/tags","blobs_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/statuses/{sha}","languages_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/languages","stargazers_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/stargazers","contributors_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/contributors","subscribers_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/subscribers","subscription_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/subscription","commits_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/contents/{+path}","compare_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/merges","archive_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/downloads","issues_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/issues{/number}","pulls_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/pulls{/number}","milestones_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/milestones{/number}","notifications_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/labels{/name}","releases_url":"https://api.github.com/repos/sgreen-r7/nexpose-client/releases{/id}","created_at":"2015-02-10T23:01:40Z","updated_at":"2015-02-10T23:01:40Z","pushed_at":"2015-02-26T21:19:40Z","git_url":"git://github.com/sgreen-r7/nexpose-client.git","ssh_url":"git@github.com:sgreen-r7/nexpose-client.git","clone_url":"https://github.com/sgreen-r7/nexpose-client.git","svn_url":"https://github.com/sgreen-r7/nexpose-client","homepage":"http://www.rapid7.com/","size":910,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"rapid7:master","ref":"master","sha":"90a437b438985d7e564d5896c474ad2d25bb81de","user":{"login":"rapid7","id":1013671,"avatar_url":"https://avatars.githubusercontent.com/u/1013671?v=3","gravatar_id":"","url":"https://api.github.com/users/rapid7","html_url":"https://github.com/rapid7","followers_url":"https://api.github.com/users/rapid7/followers","following_url":"https://api.github.com/users/rapid7/following{/other_user}","gists_url":"https://api.github.com/users/rapid7/gists{/gist_id}","starred_url":"https://api.github.com/users/rapid7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rapid7/subscriptions","organizations_url":"https://api.github.com/users/rapid7/orgs","repos_url":"https://api.github.com/users/rapid7/repos","events_url":"https://api.github.com/users/rapid7/events{/privacy}","received_events_url":"https://api.github.com/users/rapid7/received_events","type":"Organization","site_admin":false},"repo":{"id":2622467,"name":"nexpose-client","full_name":"rapid7/nexpose-client","owner":{"login":"rapid7","id":1013671,"avatar_url":"https://avatars.githubusercontent.com/u/1013671?v=3","gravatar_id":"","url":"https://api.github.com/users/rapid7","html_url":"https://github.com/rapid7","followers_url":"https://api.github.com/users/rapid7/followers","following_url":"https://api.github.com/users/rapid7/following{/other_user}","gists_url":"https://api.github.com/users/rapid7/gists{/gist_id}","starred_url":"https://api.github.com/users/rapid7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rapid7/subscriptions","organizations_url":"https://api.github.com/users/rapid7/orgs","repos_url":"https://api.github.com/users/rapid7/repos","events_url":"https://api.github.com/users/rapid7/events{/privacy}","received_events_url":"https://api.github.com/users/rapid7/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rapid7/nexpose-client","description":"Rapid7 Nexpose API client library written in Ruby","fork":false,"url":"https://api.github.com/repos/rapid7/nexpose-client","forks_url":"https://api.github.com/repos/rapid7/nexpose-client/forks","keys_url":"https://api.github.com/repos/rapid7/nexpose-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rapid7/nexpose-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rapid7/nexpose-client/teams","hooks_url":"https://api.github.com/repos/rapid7/nexpose-client/hooks","issue_events_url":"https://api.github.com/repos/rapid7/nexpose-client/issues/events{/number}","events_url":"https://api.github.com/repos/rapid7/nexpose-client/events","assignees_url":"https://api.github.com/repos/rapid7/nexpose-client/assignees{/user}","branches_url":"https://api.github.com/repos/rapid7/nexpose-client/branches{/branch}","tags_url":"https://api.github.com/repos/rapid7/nexpose-client/tags","blobs_url":"https://api.github.com/repos/rapid7/nexpose-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rapid7/nexpose-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rapid7/nexpose-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/rapid7/nexpose-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rapid7/nexpose-client/statuses/{sha}","languages_url":"https://api.github.com/repos/rapid7/nexpose-client/languages","stargazers_url":"https://api.github.com/repos/rapid7/nexpose-client/stargazers","contributors_url":"https://api.github.com/repos/rapid7/nexpose-client/contributors","subscribers_url":"https://api.github.com/repos/rapid7/nexpose-client/subscribers","subscription_url":"https://api.github.com/repos/rapid7/nexpose-client/subscription","commits_url":"https://api.github.com/repos/rapid7/nexpose-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/rapid7/nexpose-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/rapid7/nexpose-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/rapid7/nexpose-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/rapid7/nexpose-client/contents/{+path}","compare_url":"https://api.github.com/repos/rapid7/nexpose-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rapid7/nexpose-client/merges","archive_url":"https://api.github.com/repos/rapid7/nexpose-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rapid7/nexpose-client/downloads","issues_url":"https://api.github.com/repos/rapid7/nexpose-client/issues{/number}","pulls_url":"https://api.github.com/repos/rapid7/nexpose-client/pulls{/number}","milestones_url":"https://api.github.com/repos/rapid7/nexpose-client/milestones{/number}","notifications_url":"https://api.github.com/repos/rapid7/nexpose-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rapid7/nexpose-client/labels{/name}","releases_url":"https://api.github.com/repos/rapid7/nexpose-client/releases{/id}","created_at":"2011-10-21T19:04:49Z","updated_at":"2015-02-23T18:33:56Z","pushed_at":"2015-02-26T04:08:40Z","git_url":"git://github.com/rapid7/nexpose-client.git","ssh_url":"git@github.com:rapid7/nexpose-client.git","clone_url":"https://github.com/rapid7/nexpose-client.git","svn_url":"https://github.com/rapid7/nexpose-client","homepage":"http://www.rapid7.com/","size":3200,"stargazers_count":65,"watchers_count":65,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":52,"mirror_url":null,"open_issues_count":8,"forks":52,"open_issues":8,"watchers":65,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122"},"html":{"href":"https://github.com/rapid7/nexpose-client/pull/122"},"issue":{"href":"https://api.github.com/repos/rapid7/nexpose-client/issues/122"},"comments":{"href":"https://api.github.com/repos/rapid7/nexpose-client/issues/122/comments"},"review_comments":{"href":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122/comments"},"review_comment":{"href":"https://api.github.com/repos/rapid7/nexpose-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rapid7/nexpose-client/pulls/122/commits"},"statuses":{"href":"https://api.github.com/repos/rapid7/nexpose-client/statuses/639f54dab9ead13be77712bc080377e957ed5315"}}}}