spec/outputs/s3_spec.rb in logstash-output-s3-4.0.13 vs spec/outputs/s3_spec.rb in logstash-output-s3-4.1.0
- old
+ new
@@ -22,12 +22,11 @@
let(:events_and_encoded) { { event => event_encoded } }
subject { described_class.new(options) }
before do
- allow(subject).to receive(:bucket_resource).and_return(mock_bucket)
- allow_any_instance_of(LogStash::Outputs::S3::WriteBucketPermissionValidator).to receive(:valid?).with(mock_bucket, subject.upload_options).and_return(true)
+ allow_any_instance_of(LogStash::Outputs::S3::WriteBucketPermissionValidator).to receive(:valid?).and_return(true)
end
context "#register configuration validation" do
describe "signature version" do
it "should set the signature version if specified" do
@@ -43,11 +42,11 @@
end
end
describe "Access control list" do
context "when configured" do
- ["private", "public-read", "public-read-write", "authenticated-read"].each do |permission|
+ ["private", "public-read", "public-read-write", "authenticated-read", "aws-exec-read", "bucket-owner-read", "bucket-owner-full-control", "log-delivery-write"].each do |permission|
it "should return the configured ACL permissions: #{permission}" do
s3 = described_class.new(options.merge({ "canned_acl" => permission }))
expect(s3.upload_options).to include(:acl => permission)
end
end
@@ -141,18 +140,42 @@
it "validates the prefix" do
s3 = described_class.new(options.merge({ "prefix" => "`no\><^" }))
expect { s3.register }.to raise_error(LogStash::ConfigurationError)
end
+ describe "additional_settings" do
+ context "when enabling force_path_style" do
+ let(:additional_settings) do
+ { "additional_settings" => { "force_path_style" => true } }
+ end
+
+ it "validates the prefix" do
+ expect(Aws::S3::Bucket).to receive(:new).twice.with(anything, hash_including("force_path_style" => true)).and_call_original
+ described_class.new(options.merge(additional_settings)).register
+ end
+ end
+ context "when using a non existing setting" do
+ let(:additional_settings) do
+ { "additional_settings" => { "doesnt_exist" => true } }
+ end
+
+ it "raises an error" do
+ plugin = described_class.new(options.merge(additional_settings))
+ expect { plugin.register }.to raise_error(ArgumentError)
+ end
+ end
+ end
+
it "allow to not validate credentials" do
s3 = described_class.new(options.merge({"validate_credentials_on_root_bucket" => false}))
expect_any_instance_of(LogStash::Outputs::S3::WriteBucketPermissionValidator).not_to receive(:valid?).with(any_args)
s3.register
end
end
context "receiving events" do
before do
+ allow(subject).to receive(:bucket_resource).and_return(mock_bucket)
subject.register
end
after do
subject.close