Sha256: 70738387c0bc2cbd7086af301a2f5830bf1b3b1eb0af51a339f97f0d6915aa62
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
module Awspec::Generator module Spec class S3Bucket include Awspec::Helper::Finder def generate_all buckets = select_all_buckets raise 'Not Found Bucket' if buckets.empty? specs = buckets.map do |bucket| content(bucket) end specs.join("\n") end def generate(bucket_name) bucket = find_bucket(bucket_name) content(bucket) end def generate_grant_specs(acl) linespecs = [] acl.grants.each do |grant| linespecs.push(ERB.new(grant_linetemplate, nil, '-').result(binding)) end linespecs end def grant_linetemplate grantee = 'grant.grantee.display_name || grant.grantee.uri || grant.grantee.id' template = <<-EOF it { should have_acl_grant(grantee: '<%= #{grantee} %>', permission: '<%= grant.permission %>') } EOF template end def bucket_spec_template template = <<-'EOF' describe s3_bucket('<%= bucket.name %>') do it { should exist } its(:acl_owner) { should eq '<%= acl.owner.display_name %>' } its(:acl_grants_count) { should eq <%= acl.grants.count %> } <% grant_specs.each do |line| %> <%= line %> <% end %> <%- if bucket_policy -%> it { should have_policy('<%= bucket_policy %>') } <%- end -%> end EOF template end private def content(bucket) acl = find_bucket_acl(bucket.name) grant_specs = generate_grant_specs(acl) bucket_policy = find_bucket_policy(bucket.name).policy.read ERB.new(bucket_spec_template, nil, '-').result(binding).gsub(/^\n/, '') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
awspec-0.62.0 | lib/awspec/generator/spec/s3_bucket.rb |
awspec-0.61.1 | lib/awspec/generator/spec/s3_bucket.rb |
awspec-0.61.0 | lib/awspec/generator/spec/s3_bucket.rb |