mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
mocks for topic permissions
This commit is contained in:
parent
26d1254d89
commit
ec3eb24d98
5 changed files with 31 additions and 2 deletions
|
@ -14,7 +14,19 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def add_permission(options = {})
|
def add_permission(options = {})
|
||||||
Fog::Mock.not_implemented
|
topic_arn = options.delete('TopicArn')
|
||||||
|
label = options.delete('Label')
|
||||||
|
actions = options.select { |k,v| k.match(/^ActionName/) }.values
|
||||||
|
members = options.select { |k,v| k.match(/^AWSAccountId/) }.values
|
||||||
|
|
||||||
|
self.data[:permissions][topic_arn][label] = {
|
||||||
|
:members => members,
|
||||||
|
:actions => actions,
|
||||||
|
}
|
||||||
|
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.body = {"RequestId" => Fog::AWS::Mock.request_id}
|
||||||
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,7 @@ module Fog
|
||||||
"EffectiveDeliveryPolicy" => %Q|{"http":{"defaultHealthyRetryPolicy":{"minDelayTarget":20,"maxDelayTarget":20,"numRetries":3,"numMaxDelayRetries":0,"numNoDelayRetries":0,"numMinDelayRetries":0,"backoffFunction":"linear"},"disableSubscriptionOverrides":false}}|,
|
"EffectiveDeliveryPolicy" => %Q|{"http":{"defaultHealthyRetryPolicy":{"minDelayTarget":20,"maxDelayTarget":20,"numRetries":3,"numMaxDelayRetries":0,"numNoDelayRetries":0,"numMinDelayRetries":0,"backoffFunction":"linear"},"disableSubscriptionOverrides":false}}|,
|
||||||
"Policy" => %Q|{"Version":"2008-10-17","Id":"__default_policy_ID","Statement":[{"Sid":"__default_statement_ID","Effect":"Allow","Principal":{"AWS":"*"},"Action":["SNS:Publish","SNS:RemovePermission","SNS:SetTopicAttributes","SNS:DeleteTopic","SNS:ListSubscriptionsByTopic","SNS:GetTopicAttributes","SNS:Receive","SNS:AddPermission","SNS:Subscribe"],"Resource":"arn:aws:sns:us-east-1:990279267269:Smithy","Condition":{"StringEquals":{"AWS:SourceOwner":"990279267269"}}}]}|
|
"Policy" => %Q|{"Version":"2008-10-17","Id":"__default_policy_ID","Statement":[{"Sid":"__default_statement_ID","Effect":"Allow","Principal":{"AWS":"*"},"Action":["SNS:Publish","SNS:RemovePermission","SNS:SetTopicAttributes","SNS:DeleteTopic","SNS:ListSubscriptionsByTopic","SNS:GetTopicAttributes","SNS:Receive","SNS:AddPermission","SNS:Subscribe"],"Resource":"arn:aws:sns:us-east-1:990279267269:Smithy","Condition":{"StringEquals":{"AWS:SourceOwner":"990279267269"}}}]}|
|
||||||
}
|
}
|
||||||
|
self.data[:permissions][topic_arn] = {}
|
||||||
response.body = {"TopicArn" => topic_arn, "RequestId" => Fog::AWS::Mock.request_id}
|
response.body = {"TopicArn" => topic_arn, "RequestId" => Fog::AWS::Mock.request_id}
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,14 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def remove_permission(options = {})
|
def remove_permission(options = {})
|
||||||
Fog::Mock.not_implemented
|
topic_arn = options['TopicArn']
|
||||||
|
label = options['Label']
|
||||||
|
|
||||||
|
self.data[:permissions][topic_arn].delete(label)
|
||||||
|
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.body = {"RequestId" => Fog::AWS::Mock.request_id}
|
||||||
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,7 @@ module Fog
|
||||||
region_hash[key] = {
|
region_hash[key] = {
|
||||||
:topics => {},
|
:topics => {},
|
||||||
:subscriptions => {},
|
:subscriptions => {},
|
||||||
|
:permissions => {},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,14 @@ Shindo.tests('AWS::SNS | topic lifecycle tests', ['aws', 'sns']) do
|
||||||
Fog::AWS[:sns].get_topic_attributes(@topic_arn).body
|
Fog::AWS[:sns].get_topic_attributes(@topic_arn).body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("#add_permission('#{@topic_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
||||||
|
Fog::AWS[:sns].add_permission('TopicArn' => @topic_arn, 'Label' => 'Test', 'ActionName.member.1' => 'Subscribe', 'AWSAccountId.member.1' => '1234567890').body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#remove_permission('#{@topic_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
||||||
|
Fog::AWS[:sns].remove_permission('TopicArn' => @topic_arn, 'Label' => 'Test').body
|
||||||
|
end
|
||||||
|
|
||||||
tests("#delete_topic('#{@topic_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
tests("#delete_topic('#{@topic_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
||||||
Fog::AWS[:sns].delete_topic(@topic_arn).body
|
Fog::AWS[:sns].delete_topic(@topic_arn).body
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue