mirror of
https://github.com/inspec/inspec
synced 2024-12-30 06:53:22 +00:00
0df67fc7d0
* Initial commit of skeletal resource aws_s3_buckets * Add fixes to documents * Removes property 'creation_date' for there is no use case as of right now * Rebases on master and moves aws_s3_buckets integration test to the correct location * Adds test on unit test for false exists Signed-off-by: Matthew Dromazos <dromazmj@dukes.jmu.edu>
88 lines
2.4 KiB
Ruby
88 lines
2.4 KiB
Ruby
require 'helper'
|
|
|
|
# MSBB = MockS3BucketsBackend
|
|
# Abbreviation not used outside this file
|
|
|
|
#=============================================================================#
|
|
# Constructor Tests
|
|
#=============================================================================#
|
|
class AwsS3BucketsConstructor < Minitest::Test
|
|
def setup
|
|
AwsS3Buckets::BackendFactory.select(AwsMSBB::Basic)
|
|
end
|
|
|
|
def test_constructor_no_args_ok
|
|
AwsS3Buckets.new
|
|
end
|
|
|
|
def test_constructor_reject_unknown_resource_params
|
|
assert_raises(ArgumentError) { AwsS3Buckets.new(bla: 'blabla') }
|
|
end
|
|
end
|
|
|
|
#=============================================================================#
|
|
# Search / Recall
|
|
#=============================================================================#
|
|
class AwsS3BucketsRecallEmptyTest < Minitest::Test
|
|
|
|
def setup
|
|
AwsS3Buckets::BackendFactory.select(AwsMSBB::Empty)
|
|
end
|
|
|
|
def test_search_miss_via_empty_vpcs
|
|
refute AwsS3Buckets.new.exists?
|
|
end
|
|
end
|
|
|
|
class AwsS3BucketsRecallBasicTest < Minitest::Test
|
|
|
|
def setup
|
|
AwsS3Buckets::BackendFactory.select(AwsMSBB::Basic)
|
|
end
|
|
|
|
def test_search_hit_via_empty_filter
|
|
assert AwsS3Buckets.new.exists?
|
|
end
|
|
end
|
|
|
|
#=============================================================================#
|
|
# Properties
|
|
#=============================================================================#
|
|
class AwsS3bucketsProperties < Minitest::Test
|
|
def setup
|
|
AwsS3Buckets::BackendFactory.select(AwsMSBB::Basic)
|
|
end
|
|
|
|
def test_property_bucket_names
|
|
basic = AwsS3Buckets.new
|
|
assert_kind_of(Array, basic.bucket_names)
|
|
assert(basic.bucket_names.include?('bucket-01'))
|
|
assert(!basic.bucket_names.include?('NonExistentBucket'))
|
|
refute(basic.bucket_names.include?(nil))
|
|
end
|
|
end
|
|
|
|
#=============================================================================#
|
|
# Test Fixtures
|
|
#=============================================================================#
|
|
module AwsMSBB
|
|
class Empty < AwsBackendBase
|
|
def list_buckets
|
|
OpenStruct.new({ buckets: [] })
|
|
end
|
|
end
|
|
|
|
class Basic < AwsBackendBase
|
|
def list_buckets
|
|
fixtures = [
|
|
OpenStruct.new({
|
|
name: "bucket-01",
|
|
}),
|
|
OpenStruct.new({
|
|
name: "bucket-02",
|
|
}),
|
|
]
|
|
OpenStruct.new({ buckets: fixtures })
|
|
end
|
|
end
|
|
end
|