{"action":"created","comment":{"url":"https://api.github.com/repos/ello/ello-notifications/pulls/comments/77700641","id":77700641,"diff_hunk":"@@ -0,0 +1,132 @@\n+require 'rails_helper'\n+\n+describe Callbacks::AwsController, type: :request do\n+  Basic = ActionController::HttpAuthentication::Basic\n+\n+  before do\n+    allow_any_instance_of(Aws::SNS::Client).to receive(:confirm_subscription)\n+  end\n+\n+  let(:headers) { {} }\n+  let(:body) { '' }\n+\n+  describe 'POST #push_failed' do\n+\n+    context \"when verifying subscription\" do\n+\n+      before do\n+        allow_any_instance_of(Aws::SNS::Client).to receive(:confirm_subscription).and_return(confirmation_response)\n+      end\n+\n+      let(:body) {{ Token: '123', TopicArn: '456'}}\n+      let(:headers) do\n+        {\n+          'x-amz-sns-message-type' => 'SubscriptionConfirmation',\n+          'Content-Type' => 'application/json',\n+          'HTTP_AUTHORIZATION' => Basic.encode_credentials('admin','admin')\n+        }\n+      end\n+\n+      context \"when the verification is successful\" do\n+        let(:confirmation_response) {\n+          instance_double(\"Seahorse::Client::Response\", successful?: true)\n+        }\n+\n+        it \"returns a 200\" do\n+          post '/callbacks/aws/push_failed', body.to_json, headers\n+          expect(response.status).to be(200)\n+        end\n+      end\n+\n+      context \"when the verification is unsuccessful\" do\n+        let(:confirmation_response) {\n+          instance_double(\"Seahorse::Client::Response\", successful?: false)\n+        }\n+\n+        it \"returns a 406\" do\n+          post '/callbacks/aws/push_failed', body.to_json, headers\n+          expect(response.status).to be(406)\n+        end\n+      end\n+    end\n+\n+    context \"with a validated message\" do\n+\n+      before do\n+        allow_any_instance_of(Aws::SNS::MessageVerifier).to receive(:authentic?).and_return(true)\n+      end\n+\n+      context \"message is a failed push notification\" do\n+        let!(:subscription) {\n+          create(:device_subscription, :gcm, platform_device_identifier: '123')\n+        }\n+\n+        let(:headers) do\n+          {\n+            'x-amz-sns-message-type' => 'Notification',\n+            'Content-Type' => 'application/json',\n+            'HTTP_AUTHORIZATION' => Basic.encode_credentials('admin','admin')\n+          }\n+        end\n+\n+        let(:body) {{ delivery: { token: '123' }, status: 'FAILURE'}}\n+\n+        it \"deletes the device subscription\" do\n+          expect(DeviceSubscription.find(subscription.id)).to be_truthy\n+          post '/callbacks/aws/push_failed', body.to_json, headers\n+          expect(response.status).to be(200)\n+          expect(DeviceSubscription.find_by(id: subscription.id)).to be_nil\n+        end\n+      end\n+\n+      context \"message is NOT a failed push notification\" do\n+\n+        let!(:subscription) {\n+          create(:device_subscription, :gcm, platform_device_identifier: '123')\n+        }\n+\n+        let(:headers) do\n+          {\n+           'Content-Type' => 'application/json',\n+           'HTTP_AUTHORIZATION' => Basic.encode_credentials('admin','admin')\n+          }\n+        end\n+\n+        let(:body) {{ deliver: { token: '123' }, status: 'NOT FAILURE'}}\n+\n+        it \"does not delete a device subscription\" do\n+          expect(DeviceSubscription.find(subscription.id)).to be_truthy\n+          post '/callbacks/aws/push_failed', body.to_json, headers\n+          expect(response.status).to be(200)\n+          expect(DeviceSubscription.find(subscription.id)).to be_truthy\n+        end\n+      end\n+    end\n+\n+    context \"with an unvalidated message\" do\n+","path":"spec/controllers/callbacks/aws_controller_spec.rb","position":107,"original_position":107,"commit_id":"3691111afc3e5c29d6a9e2d60aa35fd2d1993789","original_commit_id":"3691111afc3e5c29d6a9e2d60aa35fd2d1993789","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":"Extra empty line detected at block body beginning.","created_at":"2016-09-06T19:19:03Z","updated_at":"2016-09-06T19:19:03Z","html_url":"https://github.com/ello/ello-notifications/pull/10#discussion_r77700641","pull_request_url":"https://api.github.com/repos/ello/ello-notifications/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/ello/ello-notifications/pulls/comments/77700641"},"html":{"href":"https://github.com/ello/ello-notifications/pull/10#discussion_r77700641"},"pull_request":{"href":"https://api.github.com/repos/ello/ello-notifications/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/ello/ello-notifications/pulls/10","id":84165645,"html_url":"https://github.com/ello/ello-notifications/pull/10","diff_url":"https://github.com/ello/ello-notifications/pull/10.diff","patch_url":"https://github.com/ello/ello-notifications/pull/10.patch","issue_url":"https://api.github.com/repos/ello/ello-notifications/issues/10","number":10,"state":"open","locked":false,"title":"Remove failed push tokens","user":{"login":"steam","id":12459,"avatar_url":"https://avatars.githubusercontent.com/u/12459?v=3","gravatar_id":"","url":"https://api.github.com/users/steam","html_url":"https://github.com/steam","followers_url":"https://api.github.com/users/steam/followers","following_url":"https://api.github.com/users/steam/following{/other_user}","gists_url":"https://api.github.com/users/steam/gists{/gist_id}","starred_url":"https://api.github.com/users/steam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steam/subscriptions","organizations_url":"https://api.github.com/users/steam/orgs","repos_url":"https://api.github.com/users/steam/repos","events_url":"https://api.github.com/users/steam/events{/privacy}","received_events_url":"https://api.github.com/users/steam/received_events","type":"User","site_admin":false},"body":"We've been seeing a rash of failed AWS SNS push failures with Android GCM. In order to better understand these we implemented a failure top subscription endpoint to remove failed device tokens.\r\n\r\nThis will hopefully reduce the number of failures and/or allow us to better understand the nature of the failures. The hypothesis is that GCM is frequently issuing new device tokens for existing devices, causing our notification service to fill up with invalid tokens.\r\n\r\n![img](http://kelly.cybr.org/wp-content/uploads/2009/03/1926-switchboards.gif)","created_at":"2016-09-06T17:45:16Z","updated_at":"2016-09-06T19:19:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5e02e3f8041dc74f9b6cf8747ff42115c8ede12","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ello/ello-notifications/pulls/10/commits","review_comments_url":"https://api.github.com/repos/ello/ello-notifications/pulls/10/comments","review_comment_url":"https://api.github.com/repos/ello/ello-notifications/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ello/ello-notifications/issues/10/comments","statuses_url":"https://api.github.com/repos/ello/ello-notifications/statuses/3691111afc3e5c29d6a9e2d60aa35fd2d1993789","head":{"label":"ello:sd/feature/add-push-failure-endpoint","ref":"sd/feature/add-push-failure-endpoint","sha":"3691111afc3e5c29d6a9e2d60aa35fd2d1993789","user":{"login":"ello","id":9370718,"avatar_url":"https://avatars.githubusercontent.com/u/9370718?v=3","gravatar_id":"","url":"https://api.github.com/users/ello","html_url":"https://github.com/ello","followers_url":"https://api.github.com/users/ello/followers","following_url":"https://api.github.com/users/ello/following{/other_user}","gists_url":"https://api.github.com/users/ello/gists{/gist_id}","starred_url":"https://api.github.com/users/ello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ello/subscriptions","organizations_url":"https://api.github.com/users/ello/orgs","repos_url":"https://api.github.com/users/ello/repos","events_url":"https://api.github.com/users/ello/events{/privacy}","received_events_url":"https://api.github.com/users/ello/received_events","type":"Organization","site_admin":false},"repo":{"id":56102256,"name":"ello-notifications","full_name":"ello/ello-notifications","owner":{"login":"ello","id":9370718,"avatar_url":"https://avatars.githubusercontent.com/u/9370718?v=3","gravatar_id":"","url":"https://api.github.com/users/ello","html_url":"https://github.com/ello","followers_url":"https://api.github.com/users/ello/followers","following_url":"https://api.github.com/users/ello/following{/other_user}","gists_url":"https://api.github.com/users/ello/gists{/gist_id}","starred_url":"https://api.github.com/users/ello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ello/subscriptions","organizations_url":"https://api.github.com/users/ello/orgs","repos_url":"https://api.github.com/users/ello/repos","events_url":"https://api.github.com/users/ello/events{/privacy}","received_events_url":"https://api.github.com/users/ello/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ello/ello-notifications","description":"Push notification generation and delivery service","fork":false,"url":"https://api.github.com/repos/ello/ello-notifications","forks_url":"https://api.github.com/repos/ello/ello-notifications/forks","keys_url":"https://api.github.com/repos/ello/ello-notifications/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ello/ello-notifications/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ello/ello-notifications/teams","hooks_url":"https://api.github.com/repos/ello/ello-notifications/hooks","issue_events_url":"https://api.github.com/repos/ello/ello-notifications/issues/events{/number}","events_url":"https://api.github.com/repos/ello/ello-notifications/events","assignees_url":"https://api.github.com/repos/ello/ello-notifications/assignees{/user}","branches_url":"https://api.github.com/repos/ello/ello-notifications/branches{/branch}","tags_url":"https://api.github.com/repos/ello/ello-notifications/tags","blobs_url":"https://api.github.com/repos/ello/ello-notifications/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ello/ello-notifications/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ello/ello-notifications/git/refs{/sha}","trees_url":"https://api.github.com/repos/ello/ello-notifications/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ello/ello-notifications/statuses/{sha}","languages_url":"https://api.github.com/repos/ello/ello-notifications/languages","stargazers_url":"https://api.github.com/repos/ello/ello-notifications/stargazers","contributors_url":"https://api.github.com/repos/ello/ello-notifications/contributors","subscribers_url":"https://api.github.com/repos/ello/ello-notifications/subscribers","subscription_url":"https://api.github.com/repos/ello/ello-notifications/subscription","commits_url":"https://api.github.com/repos/ello/ello-notifications/commits{/sha}","git_commits_url":"https://api.github.com/repos/ello/ello-notifications/git/commits{/sha}","comments_url":"https://api.github.com/repos/ello/ello-notifications/comments{/number}","issue_comment_url":"https://api.github.com/repos/ello/ello-notifications/issues/comments{/number}","contents_url":"https://api.github.com/repos/ello/ello-notifications/contents/{+path}","compare_url":"https://api.github.com/repos/ello/ello-notifications/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ello/ello-notifications/merges","archive_url":"https://api.github.com/repos/ello/ello-notifications/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ello/ello-notifications/downloads","issues_url":"https://api.github.com/repos/ello/ello-notifications/issues{/number}","pulls_url":"https://api.github.com/repos/ello/ello-notifications/pulls{/number}","milestones_url":"https://api.github.com/repos/ello/ello-notifications/milestones{/number}","notifications_url":"https://api.github.com/repos/ello/ello-notifications/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ello/ello-notifications/labels{/name}","releases_url":"https://api.github.com/repos/ello/ello-notifications/releases{/id}","deployments_url":"https://api.github.com/repos/ello/ello-notifications/deployments","created_at":"2016-04-12T22:28:24Z","updated_at":"2016-06-06T13:22:08Z","pushed_at":"2016-09-06T19:18:53Z","git_url":"git://github.com/ello/ello-notifications.git","ssh_url":"git@github.com:ello/ello-notifications.git","clone_url":"https://github.com/ello/ello-notifications.git","svn_url":"https://github.com/ello/ello-notifications","homepage":"","size":165,"stargazers_count":2,"watchers_count":2,"language":"Ruby","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":2,"default_branch":"master"}},"base":{"label":"ello:master","ref":"master","sha":"752acd7506983f7980b5aef5a5ab3c92810b9588","user":{"login":"ello","id":9370718,"avatar_url":"https://avatars.githubusercontent.com/u/9370718?v=3","gravatar_id":"","url":"https://api.github.com/users/ello","html_url":"https://github.com/ello","followers_url":"https://api.github.com/users/ello/followers","following_url":"https://api.github.com/users/ello/following{/other_user}","gists_url":"https://api.github.com/users/ello/gists{/gist_id}","starred_url":"https://api.github.com/users/ello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ello/subscriptions","organizations_url":"https://api.github.com/users/ello/orgs","repos_url":"https://api.github.com/users/ello/repos","events_url":"https://api.github.com/users/ello/events{/privacy}","received_events_url":"https://api.github.com/users/ello/received_events","type":"Organization","site_admin":false},"repo":{"id":56102256,"name":"ello-notifications","full_name":"ello/ello-notifications","owner":{"login":"ello","id":9370718,"avatar_url":"https://avatars.githubusercontent.com/u/9370718?v=3","gravatar_id":"","url":"https://api.github.com/users/ello","html_url":"https://github.com/ello","followers_url":"https://api.github.com/users/ello/followers","following_url":"https://api.github.com/users/ello/following{/other_user}","gists_url":"https://api.github.com/users/ello/gists{/gist_id}","starred_url":"https://api.github.com/users/ello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ello/subscriptions","organizations_url":"https://api.github.com/users/ello/orgs","repos_url":"https://api.github.com/users/ello/repos","events_url":"https://api.github.com/users/ello/events{/privacy}","received_events_url":"https://api.github.com/users/ello/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ello/ello-notifications","description":"Push notification generation and delivery service","fork":false,"url":"https://api.github.com/repos/ello/ello-notifications","forks_url":"https://api.github.com/repos/ello/ello-notifications/forks","keys_url":"https://api.github.com/repos/ello/ello-notifications/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ello/ello-notifications/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ello/ello-notifications/teams","hooks_url":"https://api.github.com/repos/ello/ello-notifications/hooks","issue_events_url":"https://api.github.com/repos/ello/ello-notifications/issues/events{/number}","events_url":"https://api.github.com/repos/ello/ello-notifications/events","assignees_url":"https://api.github.com/repos/ello/ello-notifications/assignees{/user}","branches_url":"https://api.github.com/repos/ello/ello-notifications/branches{/branch}","tags_url":"https://api.github.com/repos/ello/ello-notifications/tags","blobs_url":"https://api.github.com/repos/ello/ello-notifications/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ello/ello-notifications/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ello/ello-notifications/git/refs{/sha}","trees_url":"https://api.github.com/repos/ello/ello-notifications/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ello/ello-notifications/statuses/{sha}","languages_url":"https://api.github.com/repos/ello/ello-notifications/languages","stargazers_url":"https://api.github.com/repos/ello/ello-notifications/stargazers","contributors_url":"https://api.github.com/repos/ello/ello-notifications/contributors","subscribers_url":"https://api.github.com/repos/ello/ello-notifications/subscribers","subscription_url":"https://api.github.com/repos/ello/ello-notifications/subscription","commits_url":"https://api.github.com/repos/ello/ello-notifications/commits{/sha}","git_commits_url":"https://api.github.com/repos/ello/ello-notifications/git/commits{/sha}","comments_url":"https://api.github.com/repos/ello/ello-notifications/comments{/number}","issue_comment_url":"https://api.github.com/repos/ello/ello-notifications/issues/comments{/number}","contents_url":"https://api.github.com/repos/ello/ello-notifications/contents/{+path}","compare_url":"https://api.github.com/repos/ello/ello-notifications/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ello/ello-notifications/merges","archive_url":"https://api.github.com/repos/ello/ello-notifications/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ello/ello-notifications/downloads","issues_url":"https://api.github.com/repos/ello/ello-notifications/issues{/number}","pulls_url":"https://api.github.com/repos/ello/ello-notifications/pulls{/number}","milestones_url":"https://api.github.com/repos/ello/ello-notifications/milestones{/number}","notifications_url":"https://api.github.com/repos/ello/ello-notifications/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ello/ello-notifications/labels{/name}","releases_url":"https://api.github.com/repos/ello/ello-notifications/releases{/id}","deployments_url":"https://api.github.com/repos/ello/ello-notifications/deployments","created_at":"2016-04-12T22:28:24Z","updated_at":"2016-06-06T13:22:08Z","pushed_at":"2016-09-06T19:18:53Z","git_url":"git://github.com/ello/ello-notifications.git","ssh_url":"git@github.com:ello/ello-notifications.git","clone_url":"https://github.com/ello/ello-notifications.git","svn_url":"https://github.com/ello/ello-notifications","homepage":"","size":165,"stargazers_count":2,"watchers_count":2,"language":"Ruby","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":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ello/ello-notifications/pulls/10"},"html":{"href":"https://github.com/ello/ello-notifications/pull/10"},"issue":{"href":"https://api.github.com/repos/ello/ello-notifications/issues/10"},"comments":{"href":"https://api.github.com/repos/ello/ello-notifications/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/ello/ello-notifications/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/ello/ello-notifications/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ello/ello-notifications/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/ello/ello-notifications/statuses/3691111afc3e5c29d6a9e2d60aa35fd2d1993789"}}}}
{"actor":{"display_login":"houndci-bot"}}