diff --git a/lib/logstash/outputs/s3/write_bucket_permission_validator.rb b/lib/logstash/outputs/s3/write_bucket_permission_validator.rb index e6b6b259..0e5bc847 100644 --- a/lib/logstash/outputs/s3/write_bucket_permission_validator.rb +++ b/lib/logstash/outputs/s3/write_bucket_permission_validator.rb @@ -15,7 +15,7 @@ def initialize(logger) def valid?(bucket_resource, upload_options = {}) begin - upload_test_file(bucket_resource) + upload_test_file(bucket_resource, upload_options) true rescue StandardError => e logger.error("Error validating bucket write permissions!", diff --git a/spec/outputs/s3/write_bucket_permission_validator_spec.rb b/spec/outputs/s3/write_bucket_permission_validator_spec.rb index cb619008..aa58385e 100644 --- a/spec/outputs/s3/write_bucket_permission_validator_spec.rb +++ b/spec/outputs/s3/write_bucket_permission_validator_spec.rb @@ -17,6 +17,16 @@ expect(bucket).to receive(:object).with(any_args).and_return(obj) end + context 'when using upload_options' do + let(:upload_options) {{ :server_side_encryption => true }} + it 'they are passed through to upload_file' do + expect(obj).to receive(:upload_file).with(anything, upload_options) + expect(obj).to receive(:delete).and_return(true) + expect(subject.valid?(bucket, upload_options)).to be_truthy + end + + end + context "when permissions are sufficient" do it "returns true" do expect(obj).to receive(:upload_file).with(any_args).and_return(true)