SQS 0.1.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/MIT-LICENSE +20 -0
- data/README +3 -0
- data/lib/sqs.rb +294 -0
- data/lib/sqs/grant.rb +34 -0
- data/lib/sqs/message.rb +43 -0
- data/lib/sqs/queue.rb +179 -0
- data/test/all_tests.rb +6 -0
- data/test/unit/sqs_grant_test.rb +67 -0
- data/test/unit/sqs_message_test.rb +81 -0
- data/test/unit/sqs_queue_test.rb +312 -0
- data/test/unit/sqs_test.rb +341 -0
- data/test/unit/test_setup.rb +51 -0
- metadata +63 -0
@@ -0,0 +1,341 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require "#{File.expand_path( File.dirname( __FILE__ ) )}/test_setup"
|
5
|
+
|
6
|
+
class DuckTypeParameter
|
7
|
+
def initialize( st )
|
8
|
+
@st = st
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
@st
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
class SQSTest < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@queue_prefix = 'testSQS'
|
21
|
+
@q = SQS.create_queue( @queue_prefix ) unless SQStest.skip_live_tests?
|
22
|
+
end
|
23
|
+
def teardown
|
24
|
+
SQS.list_queues( @queue_prefix ).each { |q| q.force_delete } unless SQStest.skip_live_tests?
|
25
|
+
print SQS.counter if SQStest.print_counter?
|
26
|
+
end
|
27
|
+
|
28
|
+
unless SQStest.skip_live_tests?
|
29
|
+
def test_list_queues
|
30
|
+
assert_respond_to SQS, :list_queues
|
31
|
+
queues = SQS.list_queues
|
32
|
+
assert_kind_of Array, queues
|
33
|
+
queues.each do |queue|
|
34
|
+
assert_kind_of SQS::Queue, queue
|
35
|
+
end
|
36
|
+
|
37
|
+
SQS.create_queue( "#{@queue_prefix}A1" )
|
38
|
+
SQS.create_queue( "#{@queue_prefix}A2" )
|
39
|
+
SQS.create_queue( "#{@queue_prefix}B1" )
|
40
|
+
SQS.create_queue( "#{@queue_prefix}B2" )
|
41
|
+
|
42
|
+
assert_equal 5, SQS.list_queues( :prefix => @queue_prefix ).size
|
43
|
+
assert_equal 2, SQS.list_queues( :prefix => "#{@queue_prefix}A" ).size
|
44
|
+
assert_equal 2, SQS.list_queues( :prefix => "#{@queue_prefix}B" ).size
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_each_queue
|
48
|
+
assert_respond_to SQS, :each_queue
|
49
|
+
SQS.each_queue do |q|
|
50
|
+
assert_kind_of SQS::Queue, q
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_get_queue
|
55
|
+
assert_respond_to SQS, :get_queue
|
56
|
+
|
57
|
+
queuename = "#{@queue_prefix}something"
|
58
|
+
q1 = SQS.create_queue( queuename )
|
59
|
+
q2 = SQS.get_queue( queuename )
|
60
|
+
|
61
|
+
assert q1.is_a?( SQS::Queue )
|
62
|
+
assert q2.is_a?( SQS::Queue )
|
63
|
+
assert_equal q1, q2
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_get_non_existent_queue
|
67
|
+
assert_respond_to SQS, :get_queue
|
68
|
+
|
69
|
+
queuename = "#{@queue_prefix}nonexist"
|
70
|
+
assert_raises RuntimeError do
|
71
|
+
q2 = SQS.get_queue( queuename )
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_create_queue
|
76
|
+
assert_respond_to SQS, :create_queue
|
77
|
+
assert_equal false, SQS.create_queue
|
78
|
+
assert_nothing_raised do
|
79
|
+
SQS.create_queue( "#{@queue_prefix}#{rand( 100000 )}" )
|
80
|
+
end
|
81
|
+
q = SQS.create_queue( "#{@queue_prefix}#{rand( 100000 )}" )
|
82
|
+
assert_kind_of( SQS::Queue, q )
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_counter
|
88
|
+
initial_counter = SQS.counter
|
89
|
+
assert SQS.reset_counter
|
90
|
+
assert_equal 0, SQS.counter
|
91
|
+
|
92
|
+
(1..10).to_a.each do |i|
|
93
|
+
assert SQS.increment_counter
|
94
|
+
end
|
95
|
+
assert_equal 10, SQS.counter
|
96
|
+
assert SQS.reset_counter
|
97
|
+
assert_equal 0, SQS.counter
|
98
|
+
|
99
|
+
while SQS.counter < initial_counter do
|
100
|
+
SQS.increment_counter
|
101
|
+
end
|
102
|
+
assert_equal initial_counter, SQS.counter
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def test_case_insensitivity_of_prepare_parameters_for_signing
|
107
|
+
assert_equal 1, 'a' <=> 'B'
|
108
|
+
assert_equal -1, 'a' <=> 'b'
|
109
|
+
assert_equal 'aaBB', SQS.prepare_parameters_for_signing( :a => 'a', :B => 'B' )
|
110
|
+
assert_equal 'aaBB', SQS.prepare_parameters_for_signing( :B => 'B', :a => 'a' )
|
111
|
+
assert_equal 'aabb', SQS.prepare_parameters_for_signing( :a => 'a', :b => 'b' )
|
112
|
+
assert_equal 'aabb', SQS.prepare_parameters_for_signing( :b => 'b', :a => 'a' )
|
113
|
+
end
|
114
|
+
def test_prepare_parameters_for_signing
|
115
|
+
assert_equal 'bobBOB', SQS.prepare_parameters_for_signing( :bob => 'BOB' )
|
116
|
+
assert_equal 'BOBbob', SQS.prepare_parameters_for_signing( :BOB => 'bob' )
|
117
|
+
assert_equal 'appleOrangeApricotsoranges', SQS.prepare_parameters_for_signing( :Apricots => 'oranges', :apple => 'Orange' )
|
118
|
+
end
|
119
|
+
def test_prepare_ducktype_values_for_signing
|
120
|
+
assert_equal 'bobBOB', SQS.prepare_parameters_for_signing( :bob => DuckTypeParameter.new( 'BOB' ) )
|
121
|
+
assert_equal 'BOBbob', SQS.prepare_parameters_for_signing( :BOB => DuckTypeParameter.new( 'bob' ) )
|
122
|
+
assert_equal 'appleOrangeApricotsoranges', SQS.prepare_parameters_for_signing( :Apricots => DuckTypeParameter.new( 'oranges' ), :apple => DuckTypeParameter.new( 'Orange' ) )
|
123
|
+
end
|
124
|
+
def test_prepare_ducktype_keys_for_signing
|
125
|
+
assert_equal 'bobBOB', SQS.prepare_parameters_for_signing( DuckTypeParameter.new( 'bob' ) => 'BOB' )
|
126
|
+
assert_equal 'BOBbob', SQS.prepare_parameters_for_signing( DuckTypeParameter.new( 'BOB' ) => 'bob' )
|
127
|
+
assert_equal 'appleOrangeApricotsoranges', SQS.prepare_parameters_for_signing( DuckTypeParameter.new( 'Apricots' ) => 'oranges', DuckTypeParameter.new( 'apple' ) => 'Orange' )
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_url_for_query
|
131
|
+
assert_respond_to SQS, :url_for_query
|
132
|
+
assert_equal 'http://queue.amazonaws.com/', SQS.url_for_query
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_create_signature
|
136
|
+
assert_respond_to SQS, :create_signature
|
137
|
+
params = { :you => 'crazy' }
|
138
|
+
assert !SQS.create_signature( params ).nil?
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_initialize_returns_class_not_instance
|
142
|
+
assert_equal 'Class', SQS.new.class.to_s
|
143
|
+
assert_equal 'SQS', SQS.new.name.to_s
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_api_version
|
147
|
+
assert_respond_to SQS, :api_version
|
148
|
+
assert_equal '2006-04-01', SQS.api_version
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
def test_access_key_id
|
153
|
+
assert SQS.respond_to?( :access_key_id )
|
154
|
+
assert SQS.respond_to?( :access_key_id= )
|
155
|
+
i = SQS.access_key_id
|
156
|
+
assert SQS.access_key_id = 'Something freaky'
|
157
|
+
assert_not_equal 'Replace this with your access key id', SQS.access_key_id, 'Please change the access key id'
|
158
|
+
SQS.access_key_id = i
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_secret_access_key
|
162
|
+
assert SQS.respond_to?( :secret_access_key )
|
163
|
+
assert SQS.respond_to?( :secret_access_key= )
|
164
|
+
k = SQS.secret_access_key
|
165
|
+
assert SQS.secret_access_key = 'Something freaky'
|
166
|
+
assert_not_equal 'Replace this with your secret access key', SQS.secret_access_key, 'Please change the secret access key.'
|
167
|
+
SQS.secret_access_key = k
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
def test_params_for_query
|
173
|
+
assert_respond_to SQS, :params_for_query
|
174
|
+
t = Time.now
|
175
|
+
|
176
|
+
assert_equal_hashes(
|
177
|
+
{ :Version => SQS.api_version, :AWSAccessKeyId => SQS.access_key_id, :SignatureVersion => SQS.signature_version, :Expires => t.to_iso8601, :DefaultVisibilityTimeout => SQS::Queue.default_visibility_timeout },
|
178
|
+
SQS.params_for_query( t )
|
179
|
+
)
|
180
|
+
|
181
|
+
assert_equal_hashes(
|
182
|
+
{ :Version => SQS.api_version, :AWSAccessKeyId => SQS.access_key_id, :SignatureVersion => SQS.signature_version, :Expires => ( Time.now + SQS.request_ttl ).to_iso8601, :DefaultVisibilityTimeout => SQS::Queue.default_visibility_timeout },
|
183
|
+
SQS.params_for_query
|
184
|
+
)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_signature_version
|
188
|
+
assert_respond_to SQS, :signature_version
|
189
|
+
assert_equal 1, SQS.signature_version
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_request_ttl
|
193
|
+
assert_respond_to SQS, :request_ttl
|
194
|
+
assert_kind_of Integer, SQS.request_ttl
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_retry_attempts
|
198
|
+
assert_respond_to SQS, :retry_attempts
|
199
|
+
assert_kind_of Integer, SQS.retry_attempts
|
200
|
+
assert 1 <= SQS.retry_attempts
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_iso8601
|
204
|
+
t = Time.now
|
205
|
+
assert_respond_to t, :to_iso8601
|
206
|
+
assert_equal t.utc.strftime( "%Y-%m-%dT%H:%M:%SZ" ), t.to_iso8601
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_request_expires
|
210
|
+
t = Time.now
|
211
|
+
assert_respond_to t, :request_expires
|
212
|
+
assert_equal t.request_expires, t + SQS.request_ttl
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_xpath
|
216
|
+
d = Document.new( "<?xml version='1.0'?><CreateQueueResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><QueueUrl>http://queue.amazonaws.com/A3ZVJ8HH1F466/nothing</QueueUrl><ResponseStatus><StatusCode>Success</StatusCode><RequestId>945de8b9-a820-4329-a56e-211053d89d0b</RequestId></ResponseStatus></CreateQueueResponse>" )
|
217
|
+
assert_equal 'Success', d.status
|
218
|
+
assert_equal 'http://queue.amazonaws.com/A3ZVJ8HH1F466/nothing', d.queue_url
|
219
|
+
|
220
|
+
|
221
|
+
d = Document.new( "<?xml version='1.0'?><Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to authenticate the request: access credentials are missing</Message></Error></Errors><RequestID>8f6707de-db6e-4bf7-909c-8dd6486bd42f</RequestID></Response>" )
|
222
|
+
assert_equal 'AuthFailure', d.error_code
|
223
|
+
assert_equal 'AWS was not able to authenticate the request: access credentials are missing', d.error_message
|
224
|
+
|
225
|
+
|
226
|
+
d = Document.new( "<?xml version='1.0'?><ListQueuesResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><QueueUrl>http://queue.amazonaws.com/A3ZVJ8HH1F466/nothing</QueueUrl><ResponseStatus><StatusCode>Success</StatusCode><RequestId>c2d4fe0b-f6f1-4874-9e6d-d081a1155b54</RequestId></ResponseStatus></ListQueuesResponse>" )
|
227
|
+
assert_equal 'Success', d.status
|
228
|
+
|
229
|
+
|
230
|
+
d = Document.new( "<?xml version='1.0'?><ListQueuesResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><QueueUrl>http://queue.amazonaws.com/A3ZVJ8HH1F466/nothingAgain</QueueUrl><QueueUrl>http://queue.amazonaws.com/A3ZVJ8HH1F466/nothing</QueueUrl><ResponseStatus><StatusCode>Success</StatusCode><RequestId>e27b54da-ff38-413b-b52f-82a6342cd151</RequestId></ResponseStatus></ListQueuesResponse>" )
|
231
|
+
assert_equal 'Success', d.status
|
232
|
+
assert_equal 'e27b54da-ff38-413b-b52f-82a6342cd151', d.request_id
|
233
|
+
|
234
|
+
|
235
|
+
d = Document.new( "<?xml version='1.0'?><SendMessageResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><MessageId>171Q1105D8GTGS9FR4QB|9CBMKVD6TTQX44QJ1S30|PT6DRTB278S4MNY77NJ0</MessageId><ResponseStatus><StatusCode>Success</StatusCode><RequestId>ddbab3dc-3910-4c86-a139-27e37cabeac4</RequestId></ResponseStatus></SendMessageResponse>" )
|
236
|
+
assert_equal '171Q1105D8GTGS9FR4QB|9CBMKVD6TTQX44QJ1S30|PT6DRTB278S4MNY77NJ0', d.message_id( :send )
|
237
|
+
assert_equal 'Success', d.status
|
238
|
+
assert_equal 'ddbab3dc-3910-4c86-a139-27e37cabeac4', d.request_id
|
239
|
+
|
240
|
+
|
241
|
+
d = Document.new( "<?xml version='1.0'?><PeekMessageResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><Message><MessageId>1WB69MM74V13FFJRTA65|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30</MessageId><MessageBody>what it is</MessageBody></Message><ResponseStatus><StatusCode>Success</StatusCode><RequestId>c23c96f4-6479-48d3-b1e4-158ebfe0cc17</RequestId></ResponseStatus></PeekMessageResponse>" )
|
242
|
+
assert_equal 'what it is', d.message_body
|
243
|
+
assert_equal '1WB69MM74V13FFJRTA65|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30', d.message_id( :peek )
|
244
|
+
assert_equal 'Success', d.status
|
245
|
+
assert_equal 'c23c96f4-6479-48d3-b1e4-158ebfe0cc17', d.request_id
|
246
|
+
|
247
|
+
|
248
|
+
d = Document.new( "<?xml version='1.0'?><ReceiveMessageResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><Message><MessageId>0C2GG4PAQACB5REHPA7W|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30</MessageId><MessageBody>you are silly person</MessageBody></Message><ResponseStatus><StatusCode>Success</StatusCode><RequestId>a901d3ec-24b6-4125-9345-36f01cd82021</RequestId></ResponseStatus></ReceiveMessageResponse>" )
|
249
|
+
assert_equal 'you are silly person', d.message_body( :receive )
|
250
|
+
assert_equal '0C2GG4PAQACB5REHPA7W|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30', d.message_id( :receive )
|
251
|
+
assert_equal 'Success', d.status
|
252
|
+
assert_equal 'a901d3ec-24b6-4125-9345-36f01cd82021', d.request_id
|
253
|
+
|
254
|
+
|
255
|
+
d = Document.new( "<?xml version='1.0'?><ReceiveMessageResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><Message><MessageId>0C2GG4PAQACB5REHPA7W|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30</MessageId><MessageBody>you are silly person</MessageBody></Message><Message><MessageId>12ZJQSDVXE728WJBXACC|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30</MessageId><MessageBody>whatever</MessageBody></Message><Message><MessageId>15YJSSXZ2R5XB0T1PXMY|3H4AA8J7EJKM0DQZR7E1|PT6DRTB278S4MNY77NJ0</MessageId><MessageBody>whatever</MessageBody></Message><Message><MessageId>0BRPBSW05BB9Z6HXWV4J|3H4AA8J7EJKM0DQZR7E1|9CBMKVD6TTQX44QJ1S30</MessageId><MessageBody>whatever</MessageBody></Message><ResponseStatus><StatusCode>Success</StatusCode><RequestId>ebf56590-665f-4077-8820-953c6663d220</RequestId></ResponseStatus></ReceiveMessageResponse>" )
|
256
|
+
assert d.messages.is_a?( Array )
|
257
|
+
d.messages.each do |m|
|
258
|
+
assert m.respond_to?( :message_id )
|
259
|
+
assert m.respond_to?( :message_body )
|
260
|
+
end
|
261
|
+
assert_equal 'Success', d.status
|
262
|
+
assert_equal 'ebf56590-665f-4077-8820-953c6663d220', d.request_id
|
263
|
+
|
264
|
+
d = Document.new( "<?xml version='1.0'?><GetVisibilityTimeoutResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><VisibilityTimeout>30</VisibilityTimeout><ResponseStatus><StatusCode>Success</StatusCode><RequestId>410fa43f-56f8-4e48-8c37-fa2f488f84aa</RequestId></ResponseStatus></GetVisibilityTimeoutResponse>" )
|
265
|
+
assert_equal 30, d.visibility_timeout
|
266
|
+
assert_equal 'Success', d.status
|
267
|
+
assert_equal '410fa43f-56f8-4e48-8c37-fa2f488f84aa', d.request_id
|
268
|
+
|
269
|
+
d = Document.new( "<?xml version='1.0'?><SetVisibilityTimeoutResponse xmlns='http://queue.amazonaws.com/doc/2006-04-01/'><ResponseStatus><StatusCode>Success</StatusCode><RequestId>26d8f4b9-a95a-4ead-85e0-a3c6ee642d64</RequestId></ResponseStatus></SetVisibilityTimeoutResponse>" )
|
270
|
+
assert_equal 'Success', d.status
|
271
|
+
assert_equal '26d8f4b9-a95a-4ead-85e0-a3c6ee642d64', d.request_id
|
272
|
+
|
273
|
+
|
274
|
+
d = Document.new( "<?xml version='1.0'?><ListGrantsResponse xmlns='http://access.amazonaws.com/doc/2006-01-01/'><GrantList><Grantee xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='CanonicalUser'><ID>2a3fad33685601e436445b8d283589b9d5ccd89a50da8fa91c664f2531ea5c71</ID><DisplayName>wzph</DisplayName></Grantee><Permission>FULLCONTROL</Permission></GrantList><ResponseStatus><StatusCode>Success</StatusCode></ResponseStatus></ListGrantsResponse>" )
|
275
|
+
assert d.grant_lists.is_a?( Array )
|
276
|
+
assert_equal 1, d.grant_lists.size
|
277
|
+
d.grant_lists.each do |list|
|
278
|
+
assert list.respond_to?( :permission )
|
279
|
+
assert list.respond_to?( :grantees )
|
280
|
+
list.grantees.each do |g|
|
281
|
+
assert g.respond_to?( :id )
|
282
|
+
assert g.respond_to?( :display_name )
|
283
|
+
assert g.respond_to?( :permission )
|
284
|
+
end
|
285
|
+
end
|
286
|
+
assert_equal 'Success', d.status
|
287
|
+
|
288
|
+
d = Document.new( "<?xml version='1.0'?><ListGrantsResponse xmlns='http://access.amazonaws.com/doc/2006-01-01/'><GrantList><Grantee xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='CanonicalUser'><ID>fde39a46472f20295511ed16510c2ff352e5d0cc0060e1aa3edfa77cbc6412bf</ID><DisplayName>lance3515</DisplayName></Grantee><Permission>RECEIVEMESSAGE</Permission></GrantList><GrantList><Grantee xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='CanonicalUser'><ID>2a3fad33685601e436445b8d283589b9d5ccd89a50da8fa91c664f2531ea5c71</ID><DisplayName>wzph</DisplayName></Grantee><Permission>FULLCONTROL</Permission></GrantList><ResponseStatus><StatusCode>Success</StatusCode></ResponseStatus></ListGrantsResponse>" )
|
289
|
+
assert d.grant_lists.is_a?( Array )
|
290
|
+
assert_equal 2, d.grant_lists.size
|
291
|
+
d.grant_lists.each do |list|
|
292
|
+
assert list.respond_to?( :permission )
|
293
|
+
assert list.respond_to?( :grantees )
|
294
|
+
list.grantees.each do |g|
|
295
|
+
assert g.respond_to?( :id )
|
296
|
+
assert g.respond_to?( :display_name )
|
297
|
+
assert g.respond_to?( :permission )
|
298
|
+
end
|
299
|
+
end
|
300
|
+
assert_equal 'Success', d.status
|
301
|
+
|
302
|
+
|
303
|
+
d = Document.new( "<?xml version='1.0'?><AddGrantResponse xmlns='http://access.amazonaws.com/doc/2006-01-01/'><ResponseStatus><StatusCode>Success</StatusCode></ResponseStatus></AddGrantResponse>" )
|
304
|
+
assert_equal 'Success', d.status
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_permissions
|
309
|
+
assert_equal 'RECEIVEMESSAGE', SQS.permissions[:receive]
|
310
|
+
assert_equal 'SENDMESSAGE', SQS.permissions[:send]
|
311
|
+
assert_equal 'FULLCONTROL', SQS.permissions[:full]
|
312
|
+
|
313
|
+
assert_equal 'RECEIVEMESSAGE', SQS.permissions( :receive )
|
314
|
+
assert_equal 'SENDMESSAGE', SQS.permissions( :send )
|
315
|
+
assert_equal 'FULLCONTROL', SQS.permissions( :full )
|
316
|
+
|
317
|
+
assert_equal 'RECEIVEMESSAGE', SQS.permissions( 'RECEIVEMESSAGE' )
|
318
|
+
assert_equal 'SENDMESSAGE', SQS.permissions( 'SENDMESSAGE' )
|
319
|
+
assert_equal 'FULLCONTROL', SQS.permissions( 'FULLCONTROL' )
|
320
|
+
end
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
module Test
|
326
|
+
module Unit
|
327
|
+
module Assertions
|
328
|
+
public
|
329
|
+
def assert_equal_hashes(hsh1, hsh2, message=nil)
|
330
|
+
_wrap_assertion do
|
331
|
+
assert_block( "assert_equal_hashes should not be called with a block." ) { !block_given? }
|
332
|
+
assert_block( "assert_equal_hashes expects a hash, but got a #{hsh1.class.to_s} in first parameter." ) { hsh1.is_a?( Hash ) }
|
333
|
+
assert_block( "assert_equal_hashes expects a hash, but got a #{hsh2.class.to_s} in second parameter." ) { hsh2.is_a?( Hash ) }
|
334
|
+
assert_block( build_message( message, "<?> is not equal to <?>.", hsh1, hsh2 ) ) do
|
335
|
+
hsh1 == hsh2
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
dir = File.expand_path( File::dirname( __FILE__ ) )
|
2
|
+
require "#{dir}/../../lib/sqs.rb"
|
3
|
+
|
4
|
+
#############################
|
5
|
+
# Change these settings
|
6
|
+
class SQStest
|
7
|
+
def self.skip_live_tests? ; false ; end
|
8
|
+
def self.print_counter? ; false ; end
|
9
|
+
def self.my_aws_account ; { :email => 'Replace this with your AWS account email address', :display_name => 'Replace this with your AWS display name' } ; end
|
10
|
+
def self.other_aws_account ; { :email => 'Replace this with another valid AWS account email address', :display_name => 'Replace this with another valid AWS display name' } ; end
|
11
|
+
def self.secret_access_key ; 'Replace this with your secret access key' ; end
|
12
|
+
def self.access_key_id ; 'Replace this with your access key id' ; end
|
13
|
+
end
|
14
|
+
# End change these settings
|
15
|
+
#############################
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
SQS.secret_access_key = SQStest.secret_access_key
|
20
|
+
SQS.access_key_id = SQStest.access_key_id
|
21
|
+
|
22
|
+
good = Hash.new
|
23
|
+
good[:access_key_id] = SQS.access_key_id != 'Replace this with your access key id'
|
24
|
+
good[:secret_access_key] = SQS.secret_access_key != 'Replace this with your secret access key'
|
25
|
+
good[:my_aws_email] = SQStest.my_aws_account[:email] != 'Replace this with your AWS account email address'
|
26
|
+
good[:my_aws_display_name] = SQStest.my_aws_account[:display_name] != 'Replace this with your AWS display name'
|
27
|
+
good[:other_aws_email] = SQStest.other_aws_account[:email] != 'Replace this with another valid AWS account email address'
|
28
|
+
good[:other_aws_display_name] = SQStest.other_aws_account[:display_name] != 'Replace this with another valid AWS display name'
|
29
|
+
|
30
|
+
message = good.reject{ |k,v| v }.keys.collect{ |k| k.to_s.gsub( /_/, ' ' ) }.join(", ")
|
31
|
+
|
32
|
+
unless message.to_s.empty?
|
33
|
+
puts "\nWHOOPS: In order to run these tests, please change the #{ message.index(',') ? 'values' : 'value' } of #{message} in #{File.expand_path( __FILE__ )}\n\n"
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
puts "\nREMINDERS:
|
38
|
+
* You are #{SQStest.skip_live_tests? ? 'skipping' : 'performing'} live tests.
|
39
|
+
* You are #{SQStest.print_counter? ? 'printing' : 'not printing'} the counter after each test.
|
40
|
+
* #{SQStest.my_aws_account[:email]} is the main email
|
41
|
+
* #{SQStest.other_aws_account[:email]} is the secondary email.
|
42
|
+
|
43
|
+
You can change all these settings in #{File.expand_path( __FILE__ )}\n\n"
|
44
|
+
|
45
|
+
SQS.reset_counter
|
46
|
+
|
47
|
+
class Symbol
|
48
|
+
def <=>( other )
|
49
|
+
return self.to_s <=> other.to_s
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: SQS
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2006-11-22 00:00:00 -08:00
|
8
|
+
summary: A Ruby interface to Amazon's Simple Queue Service
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: z@wzph.com
|
12
|
+
homepage:
|
13
|
+
rubyforge_project: SQS
|
14
|
+
description: SQS is a Ruby interface to Amazon's Simple Queue Service. SQS uses the Query API, exposing all the published API calls, plus a few more. For more information on the Simple Queue Service, see http://www.amazonaws.com
|
15
|
+
autorequire: sqs
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Zachary Holt
|
31
|
+
files:
|
32
|
+
- lib/sqs.rb
|
33
|
+
- lib/sqs/grant.rb
|
34
|
+
- lib/sqs/message.rb
|
35
|
+
- lib/sqs/queue.rb
|
36
|
+
- test/all_tests.rb
|
37
|
+
- test/unit/sqs_grant_test.rb
|
38
|
+
- test/unit/sqs_message_test.rb
|
39
|
+
- test/unit/sqs_queue_test.rb
|
40
|
+
- test/unit/sqs_test.rb
|
41
|
+
- test/unit/test_setup.rb
|
42
|
+
- README
|
43
|
+
- MIT-LICENSE
|
44
|
+
test_files:
|
45
|
+
- test/all_tests.rb
|
46
|
+
- test/unit/sqs_grant_test.rb
|
47
|
+
- test/unit/sqs_message_test.rb
|
48
|
+
- test/unit/sqs_queue_test.rb
|
49
|
+
- test/unit/sqs_test.rb
|
50
|
+
- test/unit/test_setup.rb
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
extra_rdoc_files:
|
54
|
+
- README
|
55
|
+
- MIT-LICENSE
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
dependencies: []
|
63
|
+
|