mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws/sns] basic subscription mock
This commit is contained in:
parent
59ab9639fe
commit
8e44b369a9
4 changed files with 52 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue