1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #3373 from engineyard/sns-subscriptions-mock

[aws/sns] basic subscription mock
This commit is contained in:
Frederick Cheung 2014-12-30 13:05:41 +00:00
commit 3175695284
4 changed files with 52 additions and 1 deletions

View file

@ -21,6 +21,15 @@ module Fog
}.merge!(options))
end
end
class Mock
def list_subscriptions(options={})
response = Excon::Response.new
response.body = {'Subscriptions' => self.data[:subscriptions].values, 'RequestId' => Fog::AWS::Mock.request_id}
response
end
end
end
end
end

View file

@ -23,6 +23,17 @@ module Fog
}.merge!(options))
end
end
class Mock
def list_subscriptions_by_topic(arn, options={})
response = Excon::Response.new
subscriptions = self.data[:subscriptions].values.select { |s| s["TopicArn"] == arn }
response.body = {'Subscriptions' => subscriptions, 'RequestId' => Fog::AWS::Mock.request_id}
response
end
end
end
end
end

View file

@ -25,6 +25,36 @@ module Fog
})
end
end
class Mock
def subscribe(arn, endpoint, protocol)
response = Excon::Response.new
unless topic = self.data[:topics][arn]
response.status = 400
response.body = {
'Code' => 'InvalidParameterValue',
'Message' => 'Invalid parameter: TopicArn',
'Type' => 'Sender',
}
return response
end
subscription_arn = Fog::AWS::Mock.arn(@module, @account_id, "#{topic["DisplayName"]}:#{Fog::AWS::Mock.request_id}", @region)
self.data[:subscriptions][subscription_arn] = {
"Protocol" => protocol,
"Owner" => @account_id.to_s,
"TopicArn" => arn,
"SubscriptionArn" => subscription_arn,
"Endpoint" => endpoint,
}
response.body = { 'SubscriptionArn' => 'pending confirmation', 'RequestId' => Fog::AWS::Mock.request_id }
response
end
end
end
end
end

View file

@ -32,7 +32,8 @@ module Fog
@data ||= Hash.new do |hash, region|
hash[region] = Hash.new do |region_hash, key|
region_hash[key] = {
:topics => {},
:topics => {},
:subscriptions => {},
}
end
end