aws-sig4 requires expires_in to be an int

refs RD-4078
Test Plan
Make sure we can still use crocodoc, and canvadocs

Change-Id: I0fcc8315ca65b96511695facc4a3fa59034256b9
Reviewed-on: https://gerrit.instructure.com/113402
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Caleb Guanzon <cguanzon@instructure.com>
This commit is contained in:
Brad Horrocks 2017-05-26 15:22:46 -06:00 committed by Caleb Guanzon
parent 46b6e8d777
commit dd56eda0de
2 changed files with 18 additions and 0 deletions

View File

@ -247,6 +247,11 @@ module AttachmentFu # :nodoc:
def authenticated_s3_url(*args)
thumbnail = args.first.is_a?(String) ? args.first : nil
options = args.last.is_a?(Hash) ? args.last : {}
unless options[:expires_in].nil?
if options[:expires_in].is_a? ActiveSupport::Duration
options[:expires_in] = options[:expires_in].to_i
end
end
s3object(thumbnail).presigned_url(:get, options)
end

View File

@ -72,6 +72,19 @@ describe Attachment do
end
end
context "authenticated_s3_url s3_storage" do
before :each do
s3_storage!
end
it "should give back a signed s3 url" do
a = attachment_model
s3object = a.s3object
expect(a.authenticated_s3_url(expires_in: 1.day)).to match(/^https:\/\//)
a.destroy_permanently!
end
end
def configure_crocodoc
PluginSetting.create! :name => 'crocodoc',
:settings => { :api_key => "blahblahblahblahblah" }