2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "resources/aws/aws_sns_topics"
|
2018-03-22 16:55:23 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
require "resource_support/aws"
|
|
|
|
require "resources/aws/aws_sns_topics"
|
2019-05-21 00:19:38 +00:00
|
|
|
|
2018-03-22 16:55:23 +00:00
|
|
|
# MSTB = MockSnsTopicsBackend
|
|
|
|
# Abbreviation not used outside this file
|
|
|
|
|
|
|
|
#=============================================================================#
|
|
|
|
# Constructor Tests
|
|
|
|
#=============================================================================#
|
|
|
|
class AwsSnsTopicsConstructor < Minitest::Test
|
|
|
|
def setup
|
|
|
|
AwsSnsTopics::BackendFactory.select(AwsMSTB::Basic)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_constructor_no_args_ok
|
|
|
|
AwsSnsTopics.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_constructor_reject_unknown_resource_params
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_raises(ArgumentError) { AwsSnsTopics.new(bla: "blabla") }
|
2018-03-22 16:55:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#=============================================================================#
|
|
|
|
# Properties
|
|
|
|
#=============================================================================#
|
|
|
|
class AwsSnsTopicsProperties < Minitest::Test
|
|
|
|
def setup
|
|
|
|
AwsSnsTopics::BackendFactory.select(AwsMSTB::Basic)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_property_topics_arns
|
|
|
|
basic = AwsSnsTopics.new
|
|
|
|
assert_kind_of(Array, basic.topic_arns)
|
2019-06-11 22:24:35 +00:00
|
|
|
assert(basic.topic_arns.include?("arn:aws:sns:us-east-1:212312313:test-topic-01"))
|
|
|
|
assert(basic.topic_arns.include?("arn:aws:sns:us-east-1:123123129:test-topic-02"))
|
2018-03-22 16:55:23 +00:00
|
|
|
refute(basic.topic_arns.include?(nil))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#=============================================================================#
|
|
|
|
# Test Fixtures
|
|
|
|
#=============================================================================#
|
|
|
|
module AwsMSTB
|
|
|
|
class Basic < AwsBackendBase
|
|
|
|
def list_topics(query = {})
|
2019-05-31 21:59:06 +00:00
|
|
|
OpenStruct.new({
|
2019-06-11 22:24:35 +00:00
|
|
|
topics: [
|
|
|
|
OpenStruct.new({ topic_arn: "arn:aws:sns:us-east-1:212312313:test-topic-01" }),
|
2019-07-09 00:20:30 +00:00
|
|
|
OpenStruct.new({ topic_arn: "arn:aws:sns:us-east-1:123123129:test-topic-02" }),
|
2019-06-11 22:24:35 +00:00
|
|
|
],
|
2018-03-22 16:55:23 +00:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|