Sha256: 8884a9f0cf7a9a58946ab2683bb4495cd0a820e709feeafd0fb1b2497b86dabc

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

base = File.dirname(__FILE__)
require base + '/../test_setup'

context 'S33r logging' do
  setup do
    # Tests for BucketLoggingStatus generator
    @logging_enabled_xml = load_test_xml('logging_status_enabled.xml')
    @logging_disabled_xml = load_test_xml('logging_status_disabled.xml')
    @logging_resource_to_enable = LoggingResource.new('mylogs', 'mybucket-access_log-')
    @logging_resource_to_disable = LoggingResource.new
    
    # Tests for logging ACLs
    @logging_acl_xml = load_test_xml('logging_acl.xml')
    @logging_acl_doc = Policy.from_xml(@logging_acl_xml)
    @log_delivery_write = Grant.for_group(:log_delivery, :write)
    @log_delivery_read_acl = Grant.for_group(:log_delivery, :read_acl)
    
    # clone without the logging grants
    @logging_acl_doc_no_grants = Policy.from_xml(@logging_acl_xml)
    @logging_acl_doc_no_grants.grants.delete_if { |g| @log_delivery_write == g or @log_delivery_read_acl == g }
  end
  
  specify 'should generate BucketLoggingStatus XML document to enable logging' do
    clean_xml(@logging_resource_to_enable.to_xml).should == @logging_enabled_xml
  end
  
  specify 'should generate BucketLoggingStatus XML document to disable logging' do
    clean_xml(@logging_resource_to_disable.to_xml).should == @logging_disabled_xml
  end
  
  specify 'should represent LogDelivery grants so buckets can act as logging targets' do
    @logging_acl_doc.grants.should.include @log_delivery_write
    @logging_acl_doc.grants.should.include @log_delivery_read_acl
  end
  
  specify 'should be able to report whether an ACL indicates bucket is a logging target' do
    @logging_acl_doc.log_targetable?.should.be true
    
    # check the variant where the grants have been removed
    @logging_acl_doc_no_grants.log_targetable?.should.be false
  end
  
  specify 'should be able to simply add logging target grants to an ACL' do
    @logging_acl_doc_no_grants.add_log_target_grants
    clean_xml(@logging_acl_doc_no_grants.to_xml).should == @logging_acl_xml
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
s33r-0.5.3 test/cases/spec_logging.rb