mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[AWS|SNS] flesh out basics
This commit is contained in:
parent
9c78523e5e
commit
dc78e464bc
25 changed files with 315 additions and 187 deletions
|
@ -12,7 +12,7 @@ module Fog
|
|||
def end_element(name)
|
||||
case name
|
||||
when 'SubscriptionArn', 'RequestId'
|
||||
@response[name] = @value
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
def end_element(name)
|
||||
case name
|
||||
when 'TopicArn', 'RequestId'
|
||||
@response[name] = @value
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -11,10 +11,15 @@ module Fog
|
|||
|
||||
def end_element(name)
|
||||
case name
|
||||
when "key"
|
||||
@key = @value
|
||||
when "value"
|
||||
@response['Attributes'][@key] = @value
|
||||
when 'key'
|
||||
@key = @value.rstrip
|
||||
when 'value'
|
||||
case @key
|
||||
when 'SubscriptionsConfirmed', 'SubscriptionsDeleted', 'SubscriptionsPending'
|
||||
@response['Attributes'][@key] = @value.rstrip.to_i
|
||||
else
|
||||
@response['Attributes'][@key] = @value.rstrip
|
||||
end
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
|
|
|
@ -13,12 +13,12 @@ module Fog
|
|||
def end_element(name)
|
||||
case name
|
||||
when "TopicArn", "Protocol", "SubscriptionArn", "Owner", "Endpoint"
|
||||
@subscription[name] = @value
|
||||
@subscription[name] = @value.rstrip
|
||||
when "member"
|
||||
@response['Subscriptions'] << @subscription
|
||||
@subscription = {}
|
||||
when 'RequestId', 'NextToken'
|
||||
@response[name] = @value
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class ListSubscriptionsByTopic < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'Subscriptions' => [] }
|
||||
@subscription = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when "TopicArn", "Protocol", "SubscriptionArn", "Owner", "Endpoint"
|
||||
@subscription[name] = @value
|
||||
when "member"
|
||||
@response['Subscriptions'] << @subscription
|
||||
@subscription = {}
|
||||
when 'RequestId', 'NextToken'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
def end_element(name)
|
||||
case name
|
||||
when 'MessageId', 'RequestId'
|
||||
@response[name] = @value
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
def end_element(name)
|
||||
case name
|
||||
when 'SubscriptionArn', 'RequestId'
|
||||
@response[name] = @value
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,22 +5,29 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/confirm_subscription'
|
||||
|
||||
def confirm_subscription(options = {})
|
||||
# Confirm a subscription
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to confirm subscription to
|
||||
# * token<~String> - Token sent to endpoint during subscribe action
|
||||
# * options<~Hash>:
|
||||
# * AuthenticateOnUnsubscribe<~Boolean> - whether or not unsubscription should be authenticated, defaults to false
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ConfirmSubscription.html
|
||||
#
|
||||
|
||||
def confirm_subscription(arn, token, options = {})
|
||||
request({
|
||||
'Action' => 'ConfirmSubscription',
|
||||
:parser => Fog::Parsers::AWS::SNS::ConfirmSubscription.new
|
||||
'Action' => 'ConfirmSubscription',
|
||||
'Token' => token,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::ConfirmSubscription.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def confirm_subscription(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,25 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/create_topic'
|
||||
|
||||
def create_topic(options = {})
|
||||
# Create a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - Name of topic to create
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_CreateTopic.html
|
||||
#
|
||||
|
||||
def create_topic(name)
|
||||
request({
|
||||
'Action' => 'CreateTopic',
|
||||
'Name' => name,
|
||||
:parser => Fog::Parsers::AWS::SNS::CreateTopic.new
|
||||
}.merge!(options))
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def create_topic(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,25 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/delete_topic'
|
||||
|
||||
def delete_topic(options = {})
|
||||
# Delete a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - The Arn of the topic to delete
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_DeleteTopic.html
|
||||
#
|
||||
|
||||
def delete_topic(arn)
|
||||
request({
|
||||
'Action' => 'DeleteTopic',
|
||||
:parser => Fog::Parsers::AWS::SNS::DeleteTopic.new
|
||||
}.merge!(options))
|
||||
'Action' => 'DeleteTopic',
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::DeleteTopic.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def delete_topic(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,19 +5,21 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/get_topic_attributes'
|
||||
|
||||
def get_topic_attributes(options = {})
|
||||
# Get attributes of a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~Hash>: The Arn of the topic to get attributes for
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_GetTopicAttributes.html
|
||||
#
|
||||
|
||||
def get_topic_attributes(arn)
|
||||
request({
|
||||
'Action' => 'GetTopicAttributes',
|
||||
:parser => Fog::Parsers::AWS::SNS::GetTopicAttributes.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_topic_attributes
|
||||
Fog::Mock.not_implemented
|
||||
'Action' => 'GetTopicAttributes',
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::GetTopicAttributes.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,6 +5,16 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/list_subscriptions'
|
||||
|
||||
# List subscriptions
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * 'NextToken'<~String> - Token returned from previous request, used for pagination
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ListSubscriptions.html
|
||||
#
|
||||
|
||||
def list_subscriptions(options = {})
|
||||
request({
|
||||
'Action' => 'ListSubscriptions',
|
||||
|
@ -14,14 +24,6 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_subscriptions
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,25 +3,29 @@ module Fog
|
|||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/list_subscriptions_by_topic'
|
||||
require 'fog/aws/parsers/sns/list_subscriptions'
|
||||
|
||||
def list_subscriptions_by_topic(options = {})
|
||||
# List subscriptions for a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to list subscriptions for
|
||||
# * options<~Hash>:
|
||||
# * 'NextToken'<~String> - Token returned from previous request, used for pagination
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ListSubscriptionsByTopic.html
|
||||
#
|
||||
|
||||
def list_subscriptions_by_topic(arn, options = {})
|
||||
request({
|
||||
'Action' => 'ListSubscriptionsByTopic',
|
||||
:parser => Fog::Parsers::AWS::SNS::ListSubscriptionsByTopic.new
|
||||
'Action' => 'ListSubscriptionsByTopic',
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::ListSubscriptions.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_subscriptions_by_topic
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,16 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/list_topics'
|
||||
|
||||
# List topics
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * 'NextToken'<~String> - Token returned from previous request, used for pagination
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ListTopics.html
|
||||
#
|
||||
|
||||
def list_topics(options = {})
|
||||
request({
|
||||
'Action' => 'ListTopics',
|
||||
|
@ -14,13 +24,6 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_topics(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,30 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/publish'
|
||||
|
||||
def publish(options = {})
|
||||
# Send a message to a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to send message to
|
||||
# * message<~String> - Message to send to topic
|
||||
# * options<~Hash>:
|
||||
# * MessageStructure<~String> - message structure, in ['json']
|
||||
# * Subject<~String> - value to use for subject when delivering by email
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_Publish.html
|
||||
#
|
||||
|
||||
def publish(arn, message, options = {})
|
||||
request({
|
||||
'Action' => 'Publish',
|
||||
:parser => Fog::Parsers::AWS::SNS::Publish.new
|
||||
'Action' => 'Publish',
|
||||
'Message' => message,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::Publish.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def publish(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,29 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/set_topic_attributes'
|
||||
|
||||
def set_topic_attributes(options = {})
|
||||
# Set attributes of a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~Hash> - The Arn of the topic to get attributes for
|
||||
# * attribute_name<~String> - Name of attribute to set, in ['DisplayName', 'Policy']
|
||||
# * attribute_value<~String> - Value to set attribute to
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_SetTopicAttributes.html
|
||||
#
|
||||
|
||||
def set_topic_attributes(arn, attribute_name, attribute_value)
|
||||
request({
|
||||
'Action' => 'SetTopicAttributes',
|
||||
:parser => Fog::Parsers::AWS::SNS::SetTopicAttributes.new
|
||||
}.merge!(options))
|
||||
'Action' => 'SetTopicAttributes',
|
||||
'AttributeName' => attribute_name,
|
||||
'AttributeValue' => attribute_value,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::SetTopicAttributes.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def set_topic_attributes(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,29 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/subscribe'
|
||||
|
||||
def subscribe(options = {})
|
||||
# Create a subscription
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to subscribe to
|
||||
# * endpoint<~String> - Endpoint to notify
|
||||
# * protocol<~String> - Protocol to notify endpoint with, in ['email', 'email-json', 'http', 'https', 'sqs']
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_Subscribe.html
|
||||
#
|
||||
|
||||
def subscribe(arn, endpoint, protocol)
|
||||
request({
|
||||
'Action' => 'Subscribe',
|
||||
:parser => Fog::Parsers::AWS::SNS::Subscribe.new
|
||||
}.merge!(options))
|
||||
'Action' => 'Subscribe',
|
||||
'Endpoint' => endpoint,
|
||||
'Protocol' => protocol,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::Subscribe.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def subscribe(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,25 @@ module Fog
|
|||
|
||||
require 'fog/aws/parsers/sns/unsubscribe'
|
||||
|
||||
def unsubscribe(options = {})
|
||||
# Delete a subscription
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of subscription to delete
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_Unsubscribe.html
|
||||
#
|
||||
|
||||
def unsubscribe(arn)
|
||||
request({
|
||||
'Action' => 'Unsubscribe',
|
||||
:parser => Fog::Parsers::AWS::SNS::Unsubscribe.new
|
||||
}.merge!(options))
|
||||
'Action' => 'Unsubscribe',
|
||||
'SubscriptionArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::Unsubscribe.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def unsubscribe(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,19 +9,19 @@ module Fog
|
|||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to get attributes for
|
||||
# * attributes<~Array> - List of attributes to return, in ['All', 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp', 'LastModifiedTimestamp', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'QueueArn', 'VisibilityTimeout']
|
||||
# * attribute_name<~Array> - Name of attribute to return, in ['All', 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp', 'LastModifiedTimestamp', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'QueueArn', 'VisibilityTimeout']
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryGetQueueAttributes.html
|
||||
#
|
||||
|
||||
def get_queue_attributes(queue_url, attributes)
|
||||
attributes = Fog::AWS.indexed_param('AttributeName', [*attributes])
|
||||
def get_queue_attributes(queue_url, attribute_name)
|
||||
request({
|
||||
'Action' => 'GetQueueAttributes',
|
||||
'AttributeName' => attribute_name,
|
||||
:path => path_from_queue_url(queue_url),
|
||||
:parser => Fog::Parsers::AWS::SQS::GetQueueAttributes.new
|
||||
}.merge(attributes))
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ module Fog
|
|||
# ==== Returns
|
||||
# * SNS object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'json'
|
||||
require 'multi_json'
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
|
||||
|
|
|
@ -25,7 +25,7 @@ require 'fog/core/errors'
|
|||
require 'fog/core/hmac'
|
||||
require 'fog/core/model'
|
||||
require 'fog/core/mock'
|
||||
# require 'fog/core/parser'
|
||||
require 'fog/core/parser' # FIXME: would be better to only load when nokogiri is required
|
||||
require 'fog/core/provider'
|
||||
require 'fog/core/service'
|
||||
require 'fog/core/ssh'
|
||||
|
|
81
tests/aws/requests/sns/subscription_tests.rb
Normal file
81
tests/aws/requests/sns/subscription_tests.rb
Normal file
|
@ -0,0 +1,81 @@
|
|||
Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
|
||||
|
||||
unless Fog.mocking?
|
||||
@topic_arn = AWS[:sns].create_topic('fog_subscription_tests').body['TopicArn']
|
||||
@queue_url = AWS[:sqs].create_queue('fog_subscription_tests').body['QueueUrl']
|
||||
@queue_arn = AWS[:sqs].get_queue_attributes(@queue_url, 'QueueArn').body['Attributes']['QueueArn']
|
||||
AWS[:sqs].set_queue_attributes(
|
||||
@queue_url,
|
||||
'Policy',
|
||||
::MultiJson.encode({
|
||||
'Id' => @topic_arn,
|
||||
'Statement' => {
|
||||
'Action' => 'sqs:SendMessage',
|
||||
'Condition' => {
|
||||
'StringEquals' => { 'aws:SourceArn' => @topic_arn }
|
||||
},
|
||||
'Effect' => 'Allow',
|
||||
'Principal' => { 'AWS' => '*' },
|
||||
'Resource' => @queue_arn,
|
||||
'Sid' => "#{@topic_arn}+sqs:SendMessage"
|
||||
},
|
||||
'Version' => '2008-10-17'
|
||||
})
|
||||
)
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#subscribe('#{@topic_arn}', '#{@queue_arn}', 'sqs')").formats(AWS::SNS::Formats::BASIC.merge('SubscriptionArn' => String)) do
|
||||
pending if Fog.mocking?
|
||||
body = AWS[:sns].subscribe(@topic_arn, @queue_arn, 'sqs').body
|
||||
@subscription_arn = body['SubscriptionArn']
|
||||
body
|
||||
end
|
||||
|
||||
list_subscriptions_format = AWS::SNS::Formats::BASIC.merge({
|
||||
'Subscriptions' => [{
|
||||
'Endpoint' => String,
|
||||
'Owner' => String,
|
||||
'Protocol' => String,
|
||||
'SubscriptionArn' => String,
|
||||
'TopicArn' => String
|
||||
}]
|
||||
})
|
||||
|
||||
tests("#list_subscriptions").formats(list_subscriptions_format) do
|
||||
AWS[:sns].list_subscriptions.body
|
||||
end
|
||||
|
||||
tests("#list_subscriptions_by_topic('#{@topic_arn}')").formats(list_subscriptions_format) do
|
||||
body = AWS[:sns].list_subscriptions_by_topic(@topic_arn).body
|
||||
end
|
||||
|
||||
tests("#publish('#{@topic_arn}', 'message')").formats(AWS::SNS::Formats::BASIC.merge('MessageId' => String)) do
|
||||
body = AWS[:sns].publish(@topic_arn, 'message').body
|
||||
end
|
||||
|
||||
tests("#receive_message('#{@queue_url}')...").returns('message') do
|
||||
message = nil
|
||||
Fog.wait_for do
|
||||
message = AWS[:sqs].receive_message(@queue_url).body['Message'].first
|
||||
end
|
||||
::MultiJson.decode(message['Body'])['Message']
|
||||
end
|
||||
|
||||
tests("#unsubscribe('#{@subscription_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
||||
AWS[:sns].unsubscribe(@subscription_arn).body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
AWS[:sns].delete_topic(@topic_arn)
|
||||
AWS[:sqs].delete_queue(@queue_url)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#create_topic('TopicArn' => 'example-topic')").formats(AWS::SNS::Formats::BASIC.merge('TopicArn' => String)) do
|
||||
pending if Fog.mocking?
|
||||
body = AWS[:sns].create_topic('Name' => 'example-topic').body
|
||||
@topic_arn = body["TopicArn"]
|
||||
body
|
||||
end
|
||||
|
||||
tests("#list_topics").formats(AWS::SNS::Formats::BASIC.merge('Topics' => [String])) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].list_topics.body
|
||||
end
|
||||
|
||||
tests("#delete_topic('TopicArn' => 'example-topic')").formats(AWS::SNS::Formats::BASIC) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].delete_topic('TopicArn' => @topic_arn).body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
50
tests/aws/requests/sns/topic_tests.rb
Normal file
50
tests/aws/requests/sns/topic_tests.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#create_topic('fog_topic_tests')").formats(AWS::SNS::Formats::BASIC.merge('TopicArn' => String)) do
|
||||
pending if Fog.mocking?
|
||||
body = AWS[:sns].create_topic('fog_topic_tests').body
|
||||
@topic_arn = body["TopicArn"]
|
||||
body
|
||||
end
|
||||
|
||||
tests("#list_topics").formats(AWS::SNS::Formats::BASIC.merge('Topics' => [String])) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].list_topics.body
|
||||
end
|
||||
|
||||
tests("#set_topic_attributes('#{@topic_arn}', 'DisplayName', 'other-fog_topic_tests')").formats(AWS::SNS::Formats::BASIC) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].set_topic_attributes(@topic_arn, 'DisplayName', 'other-fog_topic_tests').body
|
||||
end
|
||||
|
||||
get_topic_attributes_format = AWS::SNS::Formats::BASIC.merge({
|
||||
'Attributes' => {
|
||||
'DisplayName' => String,
|
||||
'Owner' => String,
|
||||
'Policy' => String,
|
||||
'SubscriptionsConfirmed' => Integer,
|
||||
'SubscriptionsDeleted' => Integer,
|
||||
'SubscriptionsPending' => Integer,
|
||||
'TopicArn' => String
|
||||
}
|
||||
})
|
||||
|
||||
tests("#get_topic_attributes('#{@topic_arn})").formats(get_topic_attributes_format) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].get_topic_attributes(@topic_arn).body
|
||||
end
|
||||
|
||||
tests("#delete_topic('#{@topic_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].delete_topic(@topic_arn).body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -40,9 +40,9 @@ Shindo.tests('AWS::SQS | queue requests', ['aws']) do
|
|||
}
|
||||
})
|
||||
|
||||
tests("#get_queue_attributes('#{@queue_url}', ['All'])").formats(get_queue_attributes_format) do
|
||||
tests("#get_queue_attributes('#{@queue_url}', 'All')").formats(get_queue_attributes_format) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sqs].get_queue_attributes(@queue_url, ['All']).body
|
||||
AWS[:sqs].get_queue_attributes(@queue_url, 'All').body
|
||||
end
|
||||
|
||||
tests("#delete_queue('#{@queue_url}')").formats(AWS::SQS::Formats::BASIC) do
|
||||
|
|
Loading…
Add table
Reference in a new issue