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

Merge branch 'master' into fog_2_development

* master:
  Fix indentation
  Fixed the issue according pool request #3356
  Fix build in ruby 1.8.7
  rds event subscriptions
  Fix misbehavior around connection to slave node in pool
  [aws] mocks and models for SNS

Conflicts:
	gemfiles/Gemfile-ruby-1.8.7
This commit is contained in:
Paulo Henrique Lopes Ribeiro 2014-12-22 11:53:00 -02:00
commit 0e37275e9d
29 changed files with 702 additions and 29 deletions

View file

@ -0,0 +1,41 @@
require 'fog/core/model'
module Fog
module AWS
class RDS
class EventSubscription < Fog::Model
identity :id, :aliases => 'CustSubscriptionId'
attribute :event_categories, :aliases => 'EventCategories', :type => :array
attribute :source_type, :aliases => 'SourceType'
attribute :enabled, :aliases => 'Enabled'
attribute :status, :aliases => 'Status'
attribute :creation_time, :aliases => 'SubscriptionCreationTime'
attribute :sns_topic_arn, :aliases => 'SnsTopicArn'
def ready?
! ['deleting', 'creating'].include?(status)
end
def destroy
service.delete_event_subscription(id)
reload
end
def save
requires :id, :sns_topic_arn
data = service.create_event_subscription(
'EventCategories' => event_categories,
'SourceType' => source_type,
'Enabled' => enabled || true,
'SubscriptionName' => id,
'SnsTopicArn' => sns_topic_arn
).body["CreateEventSubscriptionResult"]["EventSubscription"]
merge_attributes(data)
self
end
end
end
end
end

View file

@ -0,0 +1,24 @@
require 'fog/core/collection'
require 'fog/aws/models/rds/event_subscription'
module Fog
module AWS
class RDS
class EventSubscriptions < Fog::Collection
model Fog::AWS::RDS::EventSubscription
def all
data = service.describe_event_subscriptions.body['DescribeEventSubscriptionsResult']['EventSubscriptionsList']
load(data)
end
def get(identity)
data = service.describe_event_subscriptions('SubscriptionName' => identity).body['DescribeEventSubscriptionsResult']['EventSubscriptionsList']
new(data.first)
rescue Fog::AWS::RDS::NotFound
nil
end
end
end
end
end

View file

View file

@ -0,0 +1,17 @@
require 'fog/core/collection'
require 'fog/aws/models/sns/subscription'
module Fog
module AWS
class SNS
class Subscriptions < Fog::Collection
model Fgo::AWS::SNS::Subscription
def all
data = service.list_subscriptions.body["Subscriptions"]
load(data)
end
end
end
end
end

View file

@ -0,0 +1,48 @@
require 'fog/core/model'
module Fog
module AWS
class SNS
class Topic < Fog::Model
identity :id, :aliases => "TopicArn"
attribute :owner, :aliases => "Owner"
attribute :policy, :aliases => "Policy"
attribute :display_name, :aliases => "DisplayName"
attribute :subscriptions_pending, :aliases => "SubscriptionsPending"
attribute :subscriptions_confirmed, :aliases => "SubscriptionsConfirmed"
attribute :subscriptions_deleted, :aliases => "SubscriptionsDeleted"
attribute :delivery_policy, :aliases => "DeliveryPolicy"
attribute :effective_delivery_policy, :aliases => "EffectiveDeliveryPolicy"
def ready?
display_name
end
def update_topic_attribute(attribute, new_value)
requires :id
service.set_topic_attributes(id, attribute, new_value).body
reload
end
def destroy
requires :id
service.delete_topic(id)
true
end
def save
requires :id
data = service.create_topic(id).body["TopicArn"]
if data
data = {"id" => data}
merge_attributes(data)
true
else false
end
end
end
end
end
end

View file

@ -0,0 +1,24 @@
require 'fog/core/collection'
require 'fog/aws/models/sns/topic'
module Fog
module AWS
class SNS
class Topics < Fog::Collection
model Fog::AWS::SNS::Topic
def all
data = service.list_topics.body["Topics"].map { |t| {"id" => t} } #This is an array, but it needs to be an array of hashes for #load
load(data)
end
def get(id)
if data = service.get_topic_attributes(id).body["Attributes"]
new(data)
end
end
end
end
end
end

View file

@ -0,0 +1,32 @@
module Fog
module Parsers
module AWS
module RDS
require 'fog/aws/parsers/rds/event_subscription_parser'
class CreateEventSubscription < Fog::Parsers::AWS::RDS::EventSubscriptionParser
def reset
@response = { 'CreateEventSubscriptionResult' => {}, 'ResponseMetadata' => {} }
@event_subscription = {}
super
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'EventSubscription'
@response['CreateEventSubscriptionResult']['EventSubscription'] = @event_subscription
when 'RequestId'
@response['ResponseMetadata'][name] = value
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,29 @@
module Fog
module Parsers
module AWS
module RDS
require 'fog/aws/parsers/rds/snapshot_parser'
class DeleteEventSubscription < Fog::Parsers::AWS::RDS::SnapshotParser
def reset
@response = { 'ResponseMetadata' => {} }
super
end
def start_element(name, attrs=[])
super
end
def end_element(name)
case name
when 'RequestId'
@response['ResponseMetadata'][name] = value
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,34 @@
module Fog
module Parsers
module AWS
module RDS
require 'fog/aws/parsers/rds/event_subscription_parser'
class DescribeEventSubscriptions < Fog::Parsers::AWS::RDS::EventSubscriptionParser
def reset
@response = { 'DescribeEventSubscriptionsResult' => { 'EventSubscriptionsList' => []}, 'ResponseMetadata' => {} }
super
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'EventSubscription'
@response['DescribeEventSubscriptionsResult']['EventSubscriptionsList'] << @event_subscription
@event_subscription = fresh_event_subscription
when 'Marker'
@response['DescribeEventSubscriptionsResult']['Marker'] = value
when 'RequestId'
@response['ResponseMetadata'][name] = value
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,37 @@
module Fog
module Parsers
module AWS
module RDS
class EventSubscriptionParser < Fog::Parsers::Base
def reset
@event_subscription = fresh_event_subscription
end
def fresh_event_subscription
{'EventCategories'=> []}
end
def start_element(name, attrs = [])
super
case name
when 'EventCategoriesList'
@in_event_categories_list = true
end
end
def end_element(name)
case name
when 'EventCategory'
@event_subscription['EventCategories'] << value
@in_event_categories_list = false
when 'SubscriptionCreationTime'
@event_subscription[name] = Time.parse(value)
when 'Enabled', 'CustomerAwsId', 'SourceType', 'Status', 'CustSubscriptionId', 'SnsTopicArn'
@event_subscription[name] = value
end
end
end
end
end
end
end

View file

@ -59,6 +59,10 @@ module Fog
request :promote_read_replica
request :describe_event_subscriptions
request :create_event_subscription
request :delete_event_subscription
model_path 'fog/aws/models/rds'
model :server
collection :servers
@ -84,25 +88,32 @@ module Fog
model :log_file
collection :log_files
model :event_subscription
collection :event_subscriptions
class Mock
def self.data
@data ||= Hash.new do |hash, region|
hash[region] = Hash.new do |region_hash, key|
region_hash[key] = {
:servers => {},
:security_groups => {},
:subnet_groups => {},
:snapshots => {},
:parameter_groups => {"default.mysql5.1" => { "DBParameterGroupFamily"=>"mysql5.1",
"Description"=>"Default parameter group for mysql5.1",
"DBParameterGroupName"=>"default.mysql5.1"
},
"default.mysql5.5" => {"DBParameterGroupFamily"=>"mysql5.5",
"Description"=>"Default parameter group for mysql5.5",
"DBParameterGroupName"=>"default.mysql5.5"
}
}
}
:servers => {},
:security_groups => {},
:subnet_groups => {},
:snapshots => {},
:event_subscriptions => {},
:parameter_groups => {
"default.mysql5.1" => {
"DBParameterGroupFamily" => "mysql5.1",
"Description" => "Default parameter group for mysql5.1",
"DBParameterGroupName" => "default.mysql5.1"
},
"default.mysql5.5" => {
"DBParameterGroupFamily" => "mysql5.5",
"Description" => "Default parameter group for mysql5.5",
"DBParameterGroupName" => "default.mysql5.5"
}
}
}
end
end
end
@ -241,7 +252,7 @@ module Fog
end
else
raise case match[:code]
when 'DBInstanceNotFound', 'DBParameterGroupNotFound', 'DBSnapshotNotFound', 'DBSecurityGroupNotFound'
when 'DBInstanceNotFound', 'DBParameterGroupNotFound', 'DBSnapshotNotFound', 'DBSecurityGroupNotFound', 'SubscriptionNotFound'
Fog::AWS::RDS::NotFound.slurp(error, match[:message])
when 'DBParameterGroupAlreadyExists'
Fog::AWS::RDS::IdentifierTaken.slurp(error, match[:message])

View file

@ -0,0 +1,67 @@
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/create_event_subscription'
# Subscribes a db instance to an SNS queue
#
# @see http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateEventSubscription.html
# === Parameters
# * Enabled <~Boolean> - set to true to activate the subscription, set to false to create the subscription but not active it
# * EventCategories <~Array> - A list of event categories for a SourceType that you want to subscribe to
# * SnsTopicArn <~String> - The Amazon Resource Name of the SNS topic created for event notification
# * SourceIds <~Array> - The list of identifiers of the event sources for which events will be returned
# * SourceType <~String> - The type of source that will be generating the events. For example, if you want to be notified of events generated by a DB instance, you would set this parameter to db-instance. if this value is not specified, all events are returned
# * SubscriptionName <~String> - The name of the subscription
# * Tags <~Array> - A list of tags
def create_event_subscription(options={})
if event_categories = options.delete("EventCategories")
options.merge!(Fog::AWS.indexed_param('EventCategories.member.%d', [*event_categories]))
end
if source_ids = options.delete("SourceIds")
options.merge!(Fog::AWS.indexed_param('SourceIds.member.%d', [*source_ids]))
end
if tags = options.delete("tags")
options.merge!(Fog::AWS.indexed_param('Tags.member.%d', [*tags]))
end
request({
"Action" => "CreateEventSubscription",
:parser => Fog::Parsers::AWS::RDS::CreateEventSubscription.new,
}.merge(options))
end
end
class Mock
def create_event_subscription(options={})
response = Excon::Response.new
name = options.delete('SubscriptionName')
arn = options.delete('SnsTopicArn')
if self.data[:event_subscriptions][name]
raise Fog::AWS::RDS::IdentifierTaken.new("SubscriptionAlreadyExist => Subscription already exists")
end
subscription = {
'CustSubscriptionId' => name,
'EventCategories' => options['EventCategories'] || [],
'SourceType' => options['SourceType'],
'Enabled' => options.fetch(:enabled, "true"),
'Status' => 'creating',
'CreationTime' => Time.now,
'SnsTopicArn' => arn,
}
self.data[:event_subscriptions][name] = subscription
response.body = {
"ResponseMetaData" => {"RequestId" => Fog::AWS::Mock.request_id},
"CreateEventSubscriptionResult" => { "EventSubscription" => subscription }
}
response
end
end
end
end
end

View file

@ -0,0 +1,44 @@
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/delete_event_subscription'
# deletes an event subscription
# http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DeleteEventSubscription.html
# === Parameters
# * SubscriptionName <~String> - The name of the subscription to delete
# === Returns
# * response<~Excon::Response>:
# * body<~Hash>
def delete_event_subscription(name)
request({
'Action' => 'DeleteEventSubscription',
'SubscriptionName' => name,
:parser => Fog::Parsers::AWS::RDS::DeleteEventSubscription.new
})
end
end
class Mock
def delete_event_subscription(name)
response = Excon::Response.new
if data = self.data[:event_subscriptions][name]
data['Status'] = 'deleting'
self.data[:event_subscriptions][name] = data
response.status = 200
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
}
response
else
raise Fog::AWS::RDS::NotFound.new("EventSubscriptionNotFound => #{name} not found")
end
end
end
end
end
end

View file

@ -0,0 +1,61 @@
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/describe_event_subscriptions'
# Describe all or specified event notifications
# http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeEventSubscriptions.html
# === Parameters
# * Marker <~String> - An optional pagination token provided by a previous DescribeOrderableDBInstanceOptions request
# * MaxRecords <~String> - The maximum number of records to include in the response (20-100)
# * SubscriptionName <~String> - The name of the RDS event notification subscription you want to describe
# === Returns
# * response<~Excon::Response>:
# * body<~Hash>
def describe_event_subscriptions(options={})
if options[:max_records]
params['MaxRecords'] = options[:max_records]
end
request({
'Action' => 'DescribeEventSubscriptions',
:parser => Fog::Parsers::AWS::RDS::DescribeEventSubscriptions.new
}.merge(options))
end
end
class Mock
def describe_event_subscriptions(options={})
response = Excon::Response.new
name = options['SubscriptionName']
subscriptions = self.data[:event_subscriptions].values
subscriptions = subscriptions.select { |s| s['CustSubscriptionId'] == name } if name
non_active = self.data[:event_subscriptions].values.select { |s| s['Status'] != 'active' }
non_active.each do |s|
name = s['CustSubscriptionId']
if s['Status'] == 'creating'
s['Status'] = 'active'
self.data[:event_subscriptions][name] = s
elsif s['Status'] == 'deleting'
self.data[:event_subscriptions].delete(name)
end
end
if options['SubscriptionName'] && subscriptions.empty?
raise Fog::AWS::RDS::NotFound.new("Event Subscription #{options['SubscriptionName']} not found.")
end
response.body = {
"ResponseMetadata" => {"RequestId" => Fog::AWS::Mock.request_id},
"DescribeEventSubscriptionsResult" => {"EventSubscriptionsList" => subscriptions}
}
response
end
end
end
end
end

View file

@ -21,6 +21,27 @@ module Fog
})
end
end
class Mock
def create_topic(name)
response = Excon::Response.new
topic_arn = Fog::AWS::Mock.arn(@module, @account_id, name, @region)
self.data[:topics][topic_arn] = {
"Owner" => Fog::AWS::Mock.owner_id,
"SubscriptionsPending" => 0,
"SubscriptionsConfirmed" => 0,
"SubscriptionsDeleted" => 0,
"DisplayName" => name,
"TopicArn" => topic_arn,
"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"}}}]}|
}
response.body = {"TopicArn" => topic_arn, "RequestId" => Fog::AWS::Mock.request_id}
response
end
end
end
end
end

View file

@ -21,6 +21,16 @@ module Fog
})
end
end
class Mock
def delete_topic(arn)
self.data[:topics].delete(arn)
response = Excon::Response.new
response.body = {"RequestId" => Fog::AWS::Mock.request_id}
response
end
end
end
end
end

View file

@ -21,6 +21,16 @@ module Fog
})
end
end
class Mock
def get_topic_attributes(arn)
response = Excon::Response.new
attributes = self.data[:topics][arn]
response.body = {"Attributes" => attributes, "RequestId" => Fog::AWS::Mock.request_id}
response
end
end
end
end
end

View file

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

View file

@ -25,6 +25,21 @@ module Fog
})
end
end
class Mock
def set_topic_attributes(arn, attribute_name, attribute_value)
attributes = self.data[:topics][arn]
if %w(Policy DisplayName DeliveryPolicy).include?(attribute_name)
attributes[attribute_name] = attribute_value
self.data[:topics][arn] = attributes
end
response = Excon::Response.new
response.body = {"RequestId" => Fog::AWS::Mock.request_id}
response
end
end
end
end
end

View file

@ -23,8 +23,38 @@ module Fog
request :subscribe
request :unsubscribe
model_path 'fog/aws/models/sns'
model :topic
collection :topics
class Mock
def self.data
@data ||= Hash.new do |hash, region|
hash[region] = Hash.new do |region_hash, key|
region_hash[key] = {
:topics => {},
}
end
end
end
def initialize(options={})
@region = options[:region] || 'us-east-1'
@aws_access_key_id = options[:aws_access_key_id]
@account_id = "12345678910"
@module = "sns"
unless ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-central-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
raise ArgumentError, "Unknown region: #{@region.inspect}"
end
end
def data
self.class.data[@region][@aws_access_key_id]
end
def reset_data
self.class.data[@region].delete(@aws_access_key_id)
end
end

View file

@ -11,6 +11,7 @@ module Fog
requires :xenserver_url
recognizes :xenserver_defaults
recognizes :xenserver_timeout
recognizes :xenserver_redirect_to_master
model_path 'fog/xenserver/models/compute'
model :blob
@ -113,16 +114,27 @@ module Fog
request :snapshot_revert
class Real
attr_reader :connection
def initialize(options={})
@host = options[:xenserver_url]
@username = options[:xenserver_username]
@password = options[:xenserver_password]
@defaults = options[:xenserver_defaults] || {}
@timeout = options[:xenserver_timeout] || 30
@connection = Fog::XenServer::Connection.new(@host, @timeout)
@host = options[:xenserver_url]
@username = options[:xenserver_username]
@password = options[:xenserver_password]
@defaults = options[:xenserver_defaults] || {}
@timeout = options[:xenserver_timeout] || 30
@redirect_to_master = options[:xenserver_redirect_to_master] || false
@connection = Fog::XenServer::Connection.new(@host, @timeout)
if @redirect_to_master == false
@connection = Fog::XenServer::Connection.new(@host, @timeout)
elsif @redirect_to_master == true
host_master = @connection.find_pool_master(@username, @password)
if host_master && host_master!= @host
@host = host_master
@connection = Fog::XenServer::Connection.new(@host, @timeout)
end
end
@connection.authenticate(@username, @password)
end

View file

@ -13,7 +13,6 @@ module Fog
class Connection
require 'xmlrpc/client'
attr_reader :credentials
def initialize(host, timeout)
@ -22,6 +21,21 @@ module Fog
@factory.timeout = timeout
end
def find_pool_master( username, password )
@credentials = authenticate( username, password )
response = @factory.call('host.get_all_records', @credentials)
if response['Status'] == "Failure"
if response['ErrorDescription'][0] == "HOST_IS_SLAVE"
ip_address = response['ErrorDescription'][1]
ip_address = ip_address.chomp
valid = !(IPAddr.new(ip_address) rescue nil).nil?
if valid
response['ErrorDescription'][1]
end
end
end
end
def authenticate( username, password )
response = @factory.call('session.login_with_password', username.to_s, password.to_s)
raise Fog::XenServer::InvalidLogin.new unless response["Status"] =~ /Success/

View file

@ -0,0 +1,9 @@
Shindo.tests("AWS::RDS | event_subscription", ['aws', 'rds']) do
pending unless Fog.mocking?
name = 'fog'
params = {:id => name, :sns_topic_arn => 'arn:aws:sns:us-east-1:12345678910:fog'}
model_tests(Fog::AWS[:rds].event_subscriptions, params) do
end
end

View file

@ -0,0 +1,6 @@
Shindo.tests("AWS::RDS | event subscriptions", ['aws', 'rds']) do
pending unless Fog.mocking?
params = {:id => "fog", :sns_topic_arn => 'arn:aws:sns:us-east-1:12345678910:fog'}
collection_tests(Fog::AWS[:rds].event_subscriptions, params)
end

View file

@ -0,0 +1,15 @@
Shindo.tests("AWS::SNS | topic", ['aws', 'sns']) do
params = {:id => 'fog'}
model_tests(Fog::AWS[:sns].topics, params) do
@instance.wait_for { ready? }
tests("#display_name").returns('fog') { @instance.display_name }
tests("#update_topic_attribute") do
@instance.update_topic_attribute("DisplayName", "new-fog")
tests("#display_name").returns('new-fog') { @instance.display_name }
end
end
end

View file

@ -0,0 +1,6 @@
Shindo.tests("AWS::SNS | topics", ['aws', 'sns']) do
pending unless Fog.mocking?
params = {:id => 'arn:aws:sns:us-east-1:12345678910:fog'}
collection_tests(Fog::AWS[:sns].topics, params)
end

View file

@ -0,0 +1,30 @@
Shindo.tests('AWS::RDS | event subscription requests', ['aws', 'rds']) do
pending unless Fog.mocking?
@name = 'fog'
@arn = 'arn:aws:sns:us-east-1:12345678910:fog'
tests('success') do
tests('#create_event_subscription').formats(AWS::RDS::Formats::CREATE_EVENT_SUBSCRIPTION) do
body = Fog::AWS[:rds].create_event_subscription('SubscriptionName' => @name, 'SnsTopicArn' => @arn).body
returns(@name) { body['CreateEventSubscriptionResult']['EventSubscription']['CustSubscriptionId'] }
returns('creating') { body['CreateEventSubscriptionResult']['EventSubscription']['Status'] }
body
end
tests("#describe_event_subscriptions").formats(AWS::RDS::Formats::DESCRIBE_EVENT_SUBSCRIPTIONS) do
returns('active') { Fog::AWS[:rds].describe_event_subscriptions.body['DescribeEventSubscriptionsResult']['EventSubscriptionsList'].first['Status'] }
Fog::AWS[:rds].describe_event_subscriptions.body
end
tests("#delete_event_subscription").formats(AWS::RDS::Formats::BASIC) do
body = Fog::AWS[:rds].delete_event_subscription(@name).body
returns('deleting') { Fog::AWS[:rds].describe_event_subscriptions('SubscriptionName' => @name).body['DescribeEventSubscriptionsResult']['EventSubscriptionsList'].first['Status'] }
raises(Fog::AWS::RDS::NotFound) { Fog::AWS[:rds].describe_event_subscriptions('SubscriptionName' => @name) }
body
end
end
end

View file

@ -269,6 +269,28 @@ class AWS
'TagList' => Fog::Nullable::Hash
}
}
EVENT_SUBSCRIPTION = {
'CustSubscriptionId' => String,
'EventCategories' => Array,
'SourceType' => Fog::Nullable::String,
'Enabled' => String,
'Status' => String,
'CreationTime' => Time,
'SnsTopicArn' => String
}
CREATE_EVENT_SUBSCRIPTION = {
'CreateEventSubscriptionResult' => {
'EventSubscription' => EVENT_SUBSCRIPTION
}
}
DESCRIBE_EVENT_SUBSCRIPTIONS = {
'DescribeEventSubscriptionsResult' => {
'EventSubscriptionsList' => [EVENT_SUBSCRIPTION]
}
}
end
end
end

View file

@ -1,21 +1,18 @@
Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
Shindo.tests('AWS::SNS | 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 = Fog::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?
Fog::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?
Fog::AWS[:sns].set_topic_attributes(@topic_arn, 'DisplayName', 'other-fog_topic_tests').body
end
@ -32,12 +29,10 @@ Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
})
tests("#get_topic_attributes('#{@topic_arn})").formats(get_topic_attributes_format) do
pending if Fog.mocking?
Fog::AWS[:sns].get_topic_attributes(@topic_arn).body
end
tests("#delete_topic('#{@topic_arn}')").formats(AWS::SNS::Formats::BASIC) do
pending if Fog.mocking?
Fog::AWS[:sns].delete_topic(@topic_arn).body
end