Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated X-Amz-Expires is incorrect when it spans a transition to/off Daylight Savings Time #2059

Closed
egh opened this issue Oct 31, 2016 · 0 comments

Comments

@egh
Copy link

egh commented Oct 31, 2016

Hi -

It's not clear to me if this is a fog, rails or a carrierwave issue, but I'm starting here.

Carrierwave allows a user to set a fog_authenticated_url_expiration, which can be used to generate a X-Amz-Expires header when requesting an authenticated URL from S3. For example, fog_authenticated_url_expiration is set to 1.week (an ActiveRecord::Duration)

If this duration spans a transition on or off Daylight Savings Time, the wrong X-Amz-Expires header is generated.

See the patch below for a failing test

index c87068a..10a3071 100644
--- a/spec/storage/fog_helper.rb
+++ b/spec/storage/fog_helper.rb
@@ -85,6 +85,26 @@ end
             end
           end
 
+          it "should generate a proper X-Amz-Expires when expires spans a move to DST" do
+            if @provider == 'AWS'
+              Timecop.freeze(Time.at(1477932000)) do |now|
+                expiration = 7 * 24 * 60 * 60 # 1 week
+                allow(@uploader).to receive(:fog_authenticated_url_expiration).and_return(expiration)
+                expect(@fog_file.authenticated_url).to include("X-Amz-Expires=#{expiration.to_s}")
+              end
+            end
+          end
+
+          pending "should generate a proper X-Amz-Expires when expires spans a move to DST and an ActiveRecord::Duration is provided" do
+            if @provider == 'AWS'
+              Timecop.freeze(Time.at(1477932000)) do |now|
+                expiration = 1.week
+                allow(@uploader).to receive(:fog_authenticated_url_expiration).and_return(expiration)
+                expect(@fog_file.authenticated_url).to include("X-Amz-Expires=#{expiration.to_s}")
+              end
+            end
+          end
+
           it "should use a subdomain URL for AWS if the directory is a valid subdomain" do
             if @provider == 'AWS'
               allow(@uploader).to receive(:fog_directory).and_return('assets.site.com')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant