Skip to content

Commit

Permalink
Fix bucket permission validation upload options
Browse files Browse the repository at this point in the history
Pass 'upload_options' hash through to the bucket upload_test_file method to
fix issues where permission errors were happening when trying to validate
permissions on buckets with an 'encryption required' policy.

Fixes logstash-plugins#188, logstash-plugins#146, logstash-plugins#132

Fixes logstash-plugins#191
  • Loading branch information
robbavey committed Aug 28, 2018
1 parent 4921d0e commit 1bf83e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
10 changes: 10 additions & 0 deletions spec/outputs/s3/write_bucket_permission_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1bf83e2

Please sign in to comment.