right_aws 2.1.0 → 3.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.
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/right_aws'
@@ -0,0 +1,153 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestSns < Test::Unit::TestCase
4
+
5
+ # You can change these things to whatever you like
6
+ @@subscriber_email = 'foo@bar.baz'
7
+ @@topic_name = 'RightTestTopic'
8
+ @@topic_display_name = 'right_aws test notification topic'
9
+ @@queue_name = "sns_subscribe_queue_#{Time.now.utc.to_i}"
10
+
11
+ # These are placeholders for values that get set, and consumed during the course of testing.
12
+ @@topic_arn = ''
13
+ @@subscription_arn = ''
14
+ @@queue_url = ''
15
+ @@queue_arn = ''
16
+
17
+ @@policy_template = <<-EOF
18
+ {
19
+ "Id": "Policy1300753700208",
20
+ "Statement": [
21
+ {
22
+ "Sid": "Stmt1300753696680",
23
+ "Action": [
24
+ "SNS:Publish",
25
+ "SNS:RemovePermission",
26
+ "SNS:SetTopicAttributes",
27
+ "SNS:DeleteTopic",
28
+ "SNS:ListSubscriptionsByTopic",
29
+ "SNS:GetTopicAttributes",
30
+ "SNS:Receive",
31
+ "SNS:AddPermission",
32
+ "SNS:Subscribe"
33
+ ],
34
+ "Effect": "Allow",
35
+ "Resource": "@@topic_arn@@",
36
+ "Principal": {
37
+ "AWS": [
38
+ "*"
39
+ ]
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ EOF
45
+
46
+ def policy_text
47
+ @@policy_template.gsub('@@topic_arn@@', @@topic_arn)
48
+ end
49
+
50
+ def setup
51
+ @sns = Rightscale::SnsInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
52
+ @sqs = Rightscale::SqsGen2Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
53
+ end
54
+
55
+ def test_01_create_topic
56
+ response = @sns.create_topic(@@topic_name)
57
+ assert_not_nil(response)
58
+ @@topic_arn = response
59
+ end
60
+
61
+ def test_02_set_topic_attributes
62
+ response = @sns.set_topic_attribute(@@topic_arn, 'Policy', policy_text())
63
+ assert_not_nil(response)
64
+
65
+ response = @sns.set_topic_attribute(@@topic_arn, 'DisplayName', @@topic_display_name)
66
+ assert_not_nil(response)
67
+
68
+ assert_raise ArgumentError do
69
+ @sns.set_topic_attribute(@@topic_arn, 'Foo', 'val')
70
+ end
71
+ end
72
+
73
+ def test_03_get_topic_attributes
74
+ response = @sns.get_topic_attributes(@@topic_arn)
75
+ assert_not_nil(response)
76
+ assert(response['DisplayName'] == @@topic_display_name)
77
+ assert(response['Policy'] =~ /Policy1300753700208/)
78
+ end
79
+
80
+ def test_04_list_topics
81
+ sleep(1)
82
+ assert(@sns.list_topics.collect{|topic| topic[:arn] }.include?(@@topic_arn))
83
+ end
84
+
85
+ def test_05_subscribe_email
86
+ response = @sns.subscribe(@@topic_arn, 'email', @@subscriber_email)
87
+ assert_not_nil(response)
88
+ @@subscription_arn = response
89
+ end
90
+
91
+ def test_06_list_subscriptions
92
+ sleep(1)
93
+
94
+ response = @sns.list_subscriptions()
95
+ assert_not_nil(response)
96
+ assert(response.count == 1)
97
+ assert(response[0][:endpoint] == @@subscriber_email)
98
+ assert(response[0][:protocol] == 'email')
99
+ assert(response[0][:subscription_arn] == 'PendingConfirmation')
100
+ assert(response[0][:topic_arn] == @@topic_arn)
101
+ end
102
+
103
+ def test_07_list_subscriptions_by_topic
104
+ response = @sns.list_subscriptions(@@topic_arn)
105
+ assert_not_nil(response)
106
+ assert(response.count == 1)
107
+ assert(response[0][:endpoint] == @@subscriber_email)
108
+ assert(response[0][:protocol] == 'email')
109
+ assert(response[0][:subscription_arn] == 'PendingConfirmation')
110
+ assert(response[0][:topic_arn] == @@topic_arn)
111
+ end
112
+
113
+ def test_08_unsubscribe
114
+ @@queue_url = @sqs.create_queue(@@queue_name)
115
+ @@queue_arn = "arn:aws:sqs:us-east-1:#{TestCredentials.account_number.gsub('-','')}:#{@@queue_name}"
116
+ sub_response = @sns.subscribe(@@topic_arn, 'sqs', @@queue_arn)
117
+ assert_not_nil(sub_response)
118
+ unsub_response = @sns.unsubscribe(sub_response)
119
+ @sqs.delete_queue(@@queue_url)
120
+ end
121
+
122
+ def test_09_publish
123
+ response = @sns.publish(@@topic_arn, 'Message to publish', 'Message Subject')
124
+ assert_not_nil(response)
125
+ end
126
+
127
+ def test_10_add_and_remove_permission
128
+ acct_num = TestCredentials.account_number.gsub('-','')
129
+
130
+ add_response = @sns.add_permission(@@topic_arn, 'PermissionLbl', [
131
+ {:aws_account_id => acct_num, :action => "GetTopicAttributes"},
132
+ {:aws_account_id => acct_num, :action => "Publish"}
133
+ ])
134
+ assert_not_nil(add_response)
135
+
136
+ remove_response = @sns.remove_permission(@@topic_arn, 'PermissionLbl')
137
+ assert_not_nil(remove_response)
138
+ end
139
+
140
+ # TODO: Cannot easily test confirming subscription because it's only valid for http(s) and email subscriptions.
141
+ # Since we don't want to setup an email box or HTTP server to recive the token, we can't really simulate this
142
+ # def test_10_confirm_subscription
143
+ # response = @sns.confirm_subscription(@@topic_arn, 'SomeToken')
144
+ # assert_not_null(response)
145
+ # end
146
+
147
+ def test_30_delete_topic
148
+ response = @sns.delete_topic(@@topic_arn)
149
+ assert_not_nil(response)
150
+ sleep(1)
151
+ assert(!@sns.list_topics.collect{|topic| topic[:arn] }.include?(@@topic_arn))
152
+ end
153
+ end
@@ -12,3 +12,4 @@ require 'sqs/test_right_sqs.rb'
12
12
  require 'sqs/test_right_sqs_gen2.rb'
13
13
  require 'sdb/test_right_sdb.rb'
14
14
  require 'acf/test_right_acf.rb'
15
+ require 'sns/test_right_sns.rb'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_aws
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
4
+ hash: 7
5
+ prerelease:
6
6
  segments:
7
- - 2
8
- - 1
7
+ - 3
8
+ - 0
9
9
  - 0
10
- version: 2.1.0
10
+ version: 3.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - RightScale, Inc.
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-25 00:00:00 -07:00
19
- default_executable:
18
+ date: 2011-11-15 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: right_http_connection
@@ -135,8 +134,10 @@ files:
135
134
  - lib/ec2/right_ec2_spot_instances.rb
136
135
  - lib/ec2/right_ec2_tags.rb
137
136
  - lib/ec2/right_ec2_vpc.rb
137
+ - lib/ec2/right_ec2_vpc2.rb
138
138
  - lib/ec2/right_ec2_windows_mobility.rb
139
139
  - lib/elb/right_elb_interface.rb
140
+ - lib/emr/right_emr_interface.rb
140
141
  - lib/iam/right_iam_access_keys.rb
141
142
  - lib/iam/right_iam_groups.rb
142
143
  - lib/iam/right_iam_interface.rb
@@ -149,20 +150,28 @@ files:
149
150
  - lib/s3/right_s3_interface.rb
150
151
  - lib/sdb/active_sdb.rb
151
152
  - lib/sdb/right_sdb_interface.rb
153
+ - lib/sns/right_sns_interface.rb
152
154
  - lib/sqs/right_sqs.rb
153
155
  - lib/sqs/right_sqs_gen2.rb
154
156
  - lib/sqs/right_sqs_gen2_interface.rb
155
157
  - lib/sqs/right_sqs_interface.rb
156
158
  - right_aws.gemspec
159
+ - test/README.mdown
157
160
  - test/acf/test_helper.rb
158
161
  - test/acf/test_right_acf.rb
159
162
  - test/awsbase/test_helper.rb
160
163
  - test/awsbase/test_right_awsbase.rb
161
164
  - test/ec2/test_helper.rb
162
165
  - test/ec2/test_right_ec2.rb
166
+ - test/elb/test_helper.rb
167
+ - test/elb/test_right_elb.rb
163
168
  - test/http_connection.rb
164
169
  - test/rds/test_helper.rb
165
170
  - test/rds/test_right_rds.rb
171
+ - test/route_53/fixtures/a_record.xml
172
+ - test/route_53/fixtures/alias_record.xml
173
+ - test/route_53/test_helper.rb
174
+ - test/route_53/test_right_route_53.rb
166
175
  - test/s3/test_helper.rb
167
176
  - test/s3/test_right_s3.rb
168
177
  - test/s3/test_right_s3_stubbed.rb
@@ -170,12 +179,13 @@ files:
170
179
  - test/sdb/test_batch_put_attributes.rb
171
180
  - test/sdb/test_helper.rb
172
181
  - test/sdb/test_right_sdb.rb
182
+ - test/sns/test_helper.rb
183
+ - test/sns/test_right_sns.rb
173
184
  - test/sqs/test_helper.rb
174
185
  - test/sqs/test_right_sqs.rb
175
186
  - test/sqs/test_right_sqs_gen2.rb
176
187
  - test/test_credentials.rb
177
188
  - test/ts_right_aws.rb
178
- has_rdoc: true
179
189
  homepage:
180
190
  licenses: []
181
191
 
@@ -210,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
220
  requirements:
211
221
  - libxml-ruby >= 0.5.2.0 is encouraged
212
222
  rubyforge_project: rightaws
213
- rubygems_version: 1.3.7
223
+ rubygems_version: 1.7.2
214
224
  signing_key:
215
225
  specification_version: 3
216
226
  summary: Interface classes for the Amazon EC2, SQS, and S3 Web Services
@@ -221,9 +231,16 @@ test_files:
221
231
  - test/awsbase/test_right_awsbase.rb
222
232
  - test/ec2/test_helper.rb
223
233
  - test/ec2/test_right_ec2.rb
234
+ - test/elb/test_helper.rb
235
+ - test/elb/test_right_elb.rb
224
236
  - test/http_connection.rb
225
237
  - test/rds/test_helper.rb
226
238
  - test/rds/test_right_rds.rb
239
+ - test/README.mdown
240
+ - test/route_53/fixtures/a_record.xml
241
+ - test/route_53/fixtures/alias_record.xml
242
+ - test/route_53/test_helper.rb
243
+ - test/route_53/test_right_route_53.rb
227
244
  - test/s3/test_helper.rb
228
245
  - test/s3/test_right_s3.rb
229
246
  - test/s3/test_right_s3_stubbed.rb
@@ -231,6 +248,8 @@ test_files:
231
248
  - test/sdb/test_batch_put_attributes.rb
232
249
  - test/sdb/test_helper.rb
233
250
  - test/sdb/test_right_sdb.rb
251
+ - test/sns/test_helper.rb
252
+ - test/sns/test_right_sns.rb
234
253
  - test/sqs/test_helper.rb
235
254
  - test/sqs/test_right_sqs.rb
236
255
  - test/sqs/test_right_sqs_gen2.rb