aws_sns_subscription 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aws_sns_subscription_confirmer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sean Devine
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # AWS SNS Subscription Confirmation for Ruby on Rails
2
+
3
+ If you use AWS SNS for notifications (such as email bounces or complaints), you'll need to confirm the subscription request.
4
+
5
+ This makes that easier for Ruby on Rails apps.
6
+
7
+ ## Instructions
8
+
9
+ ### Step 1: Add the gem to your gemfile
10
+
11
+ `gem "aws_sns_subscription"`
12
+
13
+ ### Step 2: Add a before filter to the controllers that you're using as endpoints
14
+
15
+ class ExampleEmailBouncesController < ApplicationController
16
+ before_filter :respond_to_aws_sns_subscription_confirmations, only: [:create]
17
+ end
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aws_sns_subscription/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "aws_sns_subscription"
8
+ gem.version = AWSSNSSubscription::VERSION
9
+ gem.authors = ["Sean Devine"]
10
+ gem.email = ["sean@buytruckload.com"]
11
+ gem.description = %q{Easy confirmation of Amazon SNS subscription requests in Rails apps}
12
+ gem.summary = %q{Auto responds to AWS SNS subscription confirmations}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_development_dependency "rspec"
20
+ gem.add_dependency "require_all"
21
+ gem.add_dependency "activesupport"
22
+ gem.add_dependency "httparty"
23
+ end
@@ -0,0 +1,12 @@
1
+ module AWSSNSSubscription
2
+ module Confirmer
3
+ extend ActiveSupport::Concern
4
+
5
+ def respond_to_aws_sns_subscription_confirmations
6
+ if request.headers["x-amz-sns-message-type"] == "SubscriptionConfirmation"
7
+ HTTParty.get JSON.parse(request.raw_post)["SubscribeURL"]
8
+ head :ok and return
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module AWSSNSSubscription
2
+ class Railtie < Rails::Railtie
3
+ initializer "aws_sns_subscription.action_controller" do
4
+ ActiveSupport.on_load(:action_controller) do
5
+ puts "Extending #{self} with AWSSNSSubscription::Confirmer"
6
+ include AWSSNSSubscription::Confirmer
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module AWSSNSSubscription
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'httparty'
2
+ require 'active_support/all'
3
+ require 'require_all'
4
+ require_rel 'aws_sns_subscription'
5
+
6
+ module AwsSnsSubscription
7
+
8
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'active_support/all'
3
+ require 'httparty'
4
+ require File.expand_path('../../lib/aws_sns_subscription/confirmer.rb', __FILE__)
5
+
6
+ module AWSSNSSubscription
7
+ class Controller
8
+ include AWSSNSSubscription::Confirmer
9
+ def head(status)
10
+ end
11
+ end
12
+ describe Confirmer do
13
+ subject { Controller.new }
14
+ describe "receiving the subcription confirmation request" do
15
+ let(:raw_post) do
16
+ File.read(File.expand_path("../fixtures/raw_post.txt", __FILE__))
17
+ end
18
+ before(:each) do
19
+ subject.stub(:request).and_return(mock("request", headers: { "x-amz-sns-message-type" => "SubscriptionConfirmation" }, raw_post: raw_post))
20
+ end
21
+ it "should send a get request to the appropriate url" do
22
+ HTTParty.should_receive(:get).with("https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:123456789012:MyTopic&Token=2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736")
23
+ subject.respond_to_aws_sns_subscription_confirmations
24
+ end
25
+ end
26
+ describe "not receiving a subscription confirmation request" do
27
+ before(:each) do
28
+ subject.stub(:request).and_return(mock("request", headers: { "x-amz-sns-message-type" => nil }))
29
+ end
30
+ it "should not send a get request" do
31
+ HTTParty.should_receive(:get).exactly(0).times
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "Type" : "SubscriptionConfirmation",
3
+ "MessageId" : "165545c9-2a5c-472c-8df2-7ff2be2b3b1b",
4
+ "Token" : "2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736",
5
+ "TopicArn" : "arn:aws:sns:us-east-1:123456789012:MyTopic",
6
+ "Message" : "You have chosen to subscribe to the topic arn:aws:sns:us-east-1:123456789012:MyTopic.\nTo confirm the subscription, visit the SubscribeURL included in this message.",
7
+ "SubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:123456789012:MyTopic&Token=2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736",
8
+ "Timestamp" : "2012-04-26T20:45:04.751Z",
9
+ "SignatureVersion" : "1",
10
+ "Signature" : "EXAMPLEpH+DcEwjAPg8O9mY8dReBSwksfg2S7WKQcikcNKWLQjwu6A4VbeS0QHVCkhRS7fUQvi2egU3N858fiTDN6bkkOxYDVrY0Ad8L10Hs3zH81mtnPk5uvvolIC1CXGu43obcgFxeL3khZl8IKvO61GWB6jI9b5+gLPoBc1Q=",
11
+ "SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"
12
+ }
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+ config.order = 'random'
9
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aws_sns_subscription
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sean Devine
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: require_all
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: activesupport
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: httparty
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Easy confirmation of Amazon SNS subscription requests in Rails apps
79
+ email:
80
+ - sean@buytruckload.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - aws_sns_subscription.gemspec
92
+ - lib/aws_sns_subscription.rb
93
+ - lib/aws_sns_subscription/confirmer.rb
94
+ - lib/aws_sns_subscription/railtie.rb
95
+ - lib/aws_sns_subscription/version.rb
96
+ - spec/confirmer_spec.rb
97
+ - spec/fixtures/raw_post.txt
98
+ - spec/spec_helper.rb
99
+ homepage: ''
100
+ licenses: []
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 1.8.24
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Auto responds to AWS SNS subscription confirmations
123
+ test_files:
124
+ - spec/confirmer_spec.rb
125
+ - spec/fixtures/raw_post.txt
126
+ - spec/spec_helper.rb