propono 1.1.3 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 158f942077120ee93c8c02b1f44007ad1292eb3e
4
- data.tar.gz: aa5ad40b0f52a720e0c6f291453ab827d53a297a
3
+ metadata.gz: 19a7aae1334abb194ea3fe2ca03a3b7d6641a9b0
4
+ data.tar.gz: 181145ff80cc31864884a2ed6f6ca3b2c8757f24
5
5
  SHA512:
6
- metadata.gz: 98a05da78d36f413b9f1ae7be5fb3fa667c81348cce0d46b97cf0de95ad286f3fbfcb4b1e3588a0fa7f765c2687552a466d2bd1bbd9ea38bc3ae3db15a13563b
7
- data.tar.gz: 5e8f33d494c1cf232a51a0a4051fe0548e2a853df8c15ca707a6f270a1b7c27ca7a2256fc368ace22a2e97b29a3b006067f2033b39048ac6ea6175fd61baad7d
6
+ metadata.gz: 43c3d394220ac21226e33245ea52e10e07cb093a367c4747c750421c6c99f8e7267692f8470f1e5b885f7eef60571f9d0e6af1f355ea8e62773f3d8583684df3
7
+ data.tar.gz: f69c5512d119490b0ef13bd2fd8b219166f660f724cd6539a1176e987ea8d821b8310277700868ed6dff2e42429f252c802eea166535cb8a9af9ecf582248cbd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 1.2.0 / 2014-05-25
2
+ * [BUGFIX] Restrict SQS policy to only allow SNS topic publishes.
3
+
1
4
  # 1.1.3 / 2014-05-14
2
5
  * [FEATURE] Added ability to drain queue. Also allow dot releases of Fog.
3
6
 
@@ -26,50 +26,35 @@ module Propono
26
26
  @failed_queue = QueueCreator.find_or_create("#{queue_name}-failed")
27
27
  @corrupt_queue = QueueCreator.find_or_create("#{queue_name}-corrupt")
28
28
  sns.subscribe(@topic.arn, @queue.arn, 'sqs')
29
- sqs.set_queue_attributes(@queue.url, "Policy", generate_policy)
29
+ sqs.set_queue_attributes(@queue.url, "Policy", generate_policy(@queue, @topic))
30
30
 
31
31
  @slow_queue = QueueCreator.find_or_create("#{queue_name}-slow")
32
32
  @slow_topic = TopicCreator.find_or_create(@suffixed_slow_topic_id)
33
33
  sns.subscribe(@slow_topic.arn, @slow_queue.arn, 'sqs')
34
- sqs.set_queue_attributes(@slow_queue.url, "Policy", generate_slow_policy)
34
+ sqs.set_queue_attributes(@slow_queue.url, "Policy", generate_policy(@slow_queue, @slow_topic))
35
35
  end
36
36
 
37
37
  private
38
38
 
39
- def generate_policy
39
+ def generate_policy(queue, topic)
40
40
  <<-EOS
41
41
  {
42
42
  "Version": "2008-10-17",
43
- "Id": "#{@queue.arn}/SQSDefaultPolicy",
43
+ "Id": "#{queue.arn}/SQSDefaultPolicy",
44
44
  "Statement": [
45
45
  {
46
- "Sid": "#{@queue.arn}-Sid",
46
+ "Sid": "#{queue.arn}-Sid",
47
47
  "Effect": "Allow",
48
48
  "Principal": {
49
49
  "AWS": "*"
50
50
  },
51
51
  "Action": "SQS:*",
52
- "Resource": "#{@queue.arn}"
53
- }
54
- ]
55
- }
56
- EOS
57
- end
58
-
59
- def generate_slow_policy
60
- <<-EOS
61
- {
62
- "Version": "2008-10-17",
63
- "Id": "#{@slow_queue.arn}/SQSDefaultPolicy",
64
- "Statement": [
65
- {
66
- "Sid": "#{@slow_queue.arn}-Sid",
67
- "Effect": "Allow",
68
- "Principal": {
69
- "AWS": "*"
70
- },
71
- "Action": "SQS:*",
72
- "Resource": "#{@slow_queue.arn}"
52
+ "Resource": "#{queue.arn}",
53
+ "Condition": {
54
+ "StringEquals": {
55
+ "aws:SourceArn": "#{topic.arn}"
56
+ }
57
+ }
73
58
  }
74
59
  ]
75
60
  }
@@ -1,3 +1,3 @@
1
1
  module Propono
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -30,7 +30,7 @@ module Propono
30
30
  TopicCreator.stubs(find_or_create: Topic.new("1123"))
31
31
 
32
32
  queue_name = subscription.send(:queue_name)
33
-
33
+
34
34
  sqs = mock()
35
35
  sqs.expects(:create_queue).with(queue_name).returns(mock(body: {'QueueUrl' => Fog::AWS::SQS::Mock::QueueUrl}))
36
36
  sqs.expects(:create_queue).with(queue_name + '-failed').returns(mock(body: {'QueueUrl' => Fog::AWS::SQS::Mock::QueueUrl}))
@@ -75,18 +75,15 @@ module Propono
75
75
  def test_create_calls_set_queue_attributes
76
76
  arn = "arn123"
77
77
  policy = "{foobar: 123}"
78
- slow_policy = "{foobar: 456}"
79
78
 
80
79
  TopicCreator.stubs(find_or_create: Topic.new(arn))
81
80
  QueueCreator.stubs(find_or_create: Queue.new(Fog::AWS::SQS::Mock::QueueUrl))
82
81
 
83
82
  sqs = mock()
84
- sqs.expects(:set_queue_attributes).with(Fog::AWS::SQS::Mock::QueueUrl, "Policy", policy)
85
- sqs.expects(:set_queue_attributes).with(Fog::AWS::SQS::Mock::QueueUrl, "Policy", slow_policy)
83
+ sqs.expects(:set_queue_attributes).with(Fog::AWS::SQS::Mock::QueueUrl, "Policy", policy).twice
86
84
  subscription = QueueSubscription.new("Some topic")
87
85
  subscription.stubs(sqs: sqs)
88
86
  subscription.stubs(generate_policy: policy)
89
- subscription.stubs(generate_slow_policy: slow_policy)
90
87
  subscription.create
91
88
  end
92
89
 
@@ -102,7 +99,7 @@ module Propono
102
99
  QueueCreator.expects(:find_or_create).with('MyApp-SomeTopic-suf-slow').returns(slow_queue)
103
100
  subscription = QueueSubscription.new("SomeTopic")
104
101
  subscription.create
105
-
102
+
106
103
  assert_equal queue, subscription.queue
107
104
  assert_equal failed_queue, subscription.failed_queue
108
105
  assert_equal corrupt_queue, subscription.corrupt_queue
@@ -116,7 +113,35 @@ module Propono
116
113
  end
117
114
 
118
115
  def test_generate_policy
119
- skip "TODO - Implement this test."
116
+ queue_arn = "queue-arn"
117
+ topic_arn = "topic-arn"
118
+ queue = mock().tap {|m|m.stubs(arn: queue_arn)}
119
+ topic = mock().tap {|m|m.stubs(arn: topic_arn)}
120
+
121
+ policy = <<-EOS
122
+ {
123
+ "Version": "2008-10-17",
124
+ "Id": "#{queue_arn}/SQSDefaultPolicy",
125
+ "Statement": [
126
+ {
127
+ "Sid": "#{queue_arn}-Sid",
128
+ "Effect": "Allow",
129
+ "Principal": {
130
+ "AWS": "*"
131
+ },
132
+ "Action": "SQS:*",
133
+ "Resource": "#{queue_arn}",
134
+ "Condition": {
135
+ "StringEquals": {
136
+ "aws:SourceArn": "#{topic_arn}"
137
+ }
138
+ }
139
+ }
140
+ ]
141
+ }
142
+ EOS
143
+
144
+ assert_equal policy, QueueSubscription.new(nil).send(:generate_policy, queue, topic)
120
145
  end
121
146
  end
122
147
  end
@@ -3,8 +3,8 @@ require File.expand_path('../integration_test', __FILE__)
3
3
  module Propono
4
4
  class SlowQueueTest < IntegrationTest
5
5
  def test_slow_messages_are_received
6
- topic = "slow-test-topic"
7
- slow_topic = "slow-test-topic-slow"
6
+ topic = "propono-tests-slow-queue-topic"
7
+ slow_topic = "propono-tests-slow-queue-topic-slow"
8
8
  text = "This is my message #{DateTime.now} #{rand()}"
9
9
  slow_text = "This is my slow message #{DateTime.now} #{rand()}"
10
10
  flunks = []
@@ -42,6 +42,6 @@ module Propono
42
42
  flunk(flunks.join("\n")) unless flunks.empty?
43
43
  ensure
44
44
  # thread.terminate
45
- end
45
+ end
46
46
  end
47
47
  end
@@ -3,7 +3,7 @@ require File.expand_path('../integration_test', __FILE__)
3
3
  module Propono
4
4
  class SnsToSqsTest < IntegrationTest
5
5
  def test_the_message_gets_there
6
- topic = "test-topic"
6
+ topic = "propono-tests-sns-to-sqs-topic"
7
7
  text = "This is my message #{DateTime.now} #{rand()}"
8
8
  flunks = []
9
9
  message_received = false
@@ -38,18 +38,18 @@ module Propono
38
38
  ensure
39
39
  thread.terminate
40
40
  end
41
-
41
+
42
42
  =begin
43
-
43
+
44
44
 
45
45
  def test_failed_messge_is_transferred_to_failed_channel
46
46
  topic = "test-topic"
47
47
  text = "This is my message #{DateTime.now} #{rand()}"
48
48
  flunks = []
49
49
  message_received = false
50
-
50
+
51
51
  Propono.subscribe_by_queue(topic)
52
-
52
+
53
53
  thread = Thread.new do
54
54
  begin
55
55
  Propono.listen_to_queue(topic) do |message, context|
@@ -61,7 +61,7 @@ module Propono
61
61
  thread.terminate
62
62
  end
63
63
  end
64
-
64
+
65
65
  failure_listener = Thread.new do
66
66
  begin
67
67
  Propono.listen_to_queue(topic, channel: :failed) do |message, context|
@@ -75,16 +75,16 @@ module Propono
75
75
  thread.terminate
76
76
  end
77
77
  end
78
-
78
+
79
79
  Thread.new do
80
80
  sleep(1) while !message_received
81
81
  sleep(5) # Make sure all the message deletion clear up in the thread has happened
82
82
  thread.terminate
83
83
  failure_listener.terminate
84
84
  end
85
-
85
+
86
86
  sleep(1) # Make sure the listener has started
87
-
87
+
88
88
  Propono.publish(topic, text)
89
89
  flunks << "Test Timeout" unless wait_for_thread(thread)
90
90
  flunk(flunks.join("\n")) unless flunks.empty?
@@ -93,6 +93,6 @@ module Propono
93
93
  end
94
94
 
95
95
  =end
96
-
96
+
97
97
  end
98
98
  end
@@ -1,9 +1,9 @@
1
1
  require File.expand_path('../integration_test', __FILE__)
2
2
 
3
3
  module Propono
4
- class UdpToSqsTest < IntegrationTest
4
+ class TcpToSqsTest < IntegrationTest
5
5
  def test_the_message_gets_there
6
- topic = "test-topic"
6
+ topic = "propono-tests-tcp-to-sqs-topic"
7
7
  message = "This is my message #{DateTime.now} #{rand()}"
8
8
  flunks = []
9
9
  message_received = false
@@ -3,7 +3,7 @@ require File.expand_path('../integration_test', __FILE__)
3
3
  module Propono
4
4
  class UdpProxyTest < IntegrationTest
5
5
  def test_the_message_gets_there
6
- topic = "test-topic"
6
+ topic = "propono-tests-udp-proxy-topic"
7
7
  text = "This is my message #{DateTime.now} #{rand()}"
8
8
  flunks = []
9
9
  message_received = false
@@ -3,7 +3,7 @@ require File.expand_path('../integration_test', __FILE__)
3
3
  module Propono
4
4
  class UdpToSqsTest < IntegrationTest
5
5
  def test_the_message_gets_there
6
- topic = "test-topic"
6
+ topic = "propono-tests-udp-to-sqs-topic"
7
7
  message = "This is my message #{DateTime.now} #{rand()}"
8
8
  flunks = []
9
9
  message_received = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propono
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MalcyL
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-14 00:00:00.000000000 Z
12
+ date: 2014-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog