FIX: Handle storage providers not implementing ACLs (#13675)

When secure media is enabled or when upload secure status
is updated, we also try and update the upload ACL. However
if the object storage provider does not implement this we
get an Aws::S3::Errors::NotImplemented error. This PR handles
this error so the update_secure_status method does not error
out and still returns whether the secure status changed.
This commit is contained in:
Martin Brennan
2021-07-09 11:31:44 +10:00
committed by GitHub
parent ec537e5ea2
commit 9f275c12ab
2 changed files with 15 additions and 1 deletions

View File

@ -478,6 +478,14 @@ describe Upload do
upload.update_secure_status
expect(upload.reload.secure).to eq(false)
end
it "does not throw an error if the object storage provider does not support ACLs" do
FileStore::S3Store.any_instance.stubs(:update_upload_ACL).raises(
Aws::S3::Errors::NotImplemented.new("A header you provided implies functionality that is not implemented", "")
)
upload.update!(secure: true, access_control_post: Fabricate(:private_message_post))
expect { upload.update_secure_status }.not_to raise_error
end
end
end