2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "resources/aws/aws_route_tables"
|
2018-04-05 16:51:22 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
require "resource_support/aws"
|
|
|
|
require "resources/aws/aws_route_tables"
|
2019-05-21 00:19:38 +00:00
|
|
|
|
2018-04-05 16:51:22 +00:00
|
|
|
class EmptyAwsRouteTablesTest < Minitest::Test
|
|
|
|
def setup
|
2018-09-18 04:00:54 +00:00
|
|
|
AwsRouteTables::BackendFactory.select(AwsMRtbsB::Empty)
|
2018-04-05 16:51:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_constructor_no_args_ok
|
|
|
|
AwsRouteTables.new
|
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
|
2018-04-05 16:51:22 +00:00
|
|
|
def test_search_miss
|
|
|
|
refute AwsRouteTables.new.exists?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_constructor_reject_unknown_resource_params
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_raises(ArgumentError) { AwsRouteTables.new(bla: "blabla") }
|
2018-04-05 16:51:22 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BasicAwsRouteTablesTest2 < Minitest::Test
|
|
|
|
def setup
|
2018-09-18 04:00:54 +00:00
|
|
|
AwsRouteTables::BackendFactory.select(AwsMRtbsB::Basic)
|
2018-04-05 16:51:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_search_hit
|
|
|
|
assert AwsRouteTables.new.exists?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_property_vpc_ids
|
|
|
|
basic = AwsRouteTables.new
|
|
|
|
assert_kind_of(Array, basic.vpc_ids)
|
2019-06-11 22:24:35 +00:00
|
|
|
assert(basic.vpc_ids.include?("vpc-169f777e"))
|
|
|
|
assert(basic.vpc_ids.include?("vpc-169f777d"))
|
2018-04-05 16:51:22 +00:00
|
|
|
refute(basic.vpc_ids.include?(nil))
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_property_route_table_ids
|
|
|
|
basic = AwsRouteTables.new
|
|
|
|
assert_kind_of(Array, basic.route_table_ids)
|
2019-06-11 22:24:35 +00:00
|
|
|
assert(basic.route_table_ids.include?("rtb-05462d2278326a79c"))
|
|
|
|
assert(basic.route_table_ids.include?("rtb-58508630"))
|
2018-04-05 16:51:22 +00:00
|
|
|
refute(basic.route_table_ids.include?(nil))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# MRtbB = Mock Routetable Backend
|
2018-09-18 04:00:54 +00:00
|
|
|
module AwsMRtbsB
|
2018-04-05 16:51:22 +00:00
|
|
|
class Empty < AwsBackendBase
|
|
|
|
def describe_route_tables(query)
|
|
|
|
OpenStruct.new(route_tables: [])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Basic < AwsBackendBase
|
|
|
|
def describe_route_tables(query)
|
|
|
|
fixtures = [
|
|
|
|
OpenStruct.new({
|
2019-06-11 22:24:35 +00:00
|
|
|
route_table_id: "rtb-05462d2278326a79c",
|
|
|
|
vpc_id: "vpc-169f777e",
|
2018-04-05 16:51:22 +00:00
|
|
|
}),
|
|
|
|
OpenStruct.new({
|
2019-06-11 22:24:35 +00:00
|
|
|
route_table_id: "rtb-58508630",
|
|
|
|
vpc_id: "vpc-169f777d",
|
2018-04-05 16:51:22 +00:00
|
|
|
})
|
|
|
|
]
|
|
|
|
OpenStruct.new({ route_tables: fixtures })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|