OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[32825] Cache external URLs for at max 604799 seconds (#8268)
Oliver Günther1255aff56a70
diff --git a/lib/api/v3/attachments/attachments_api.rb b/lib/api/v3/attachments/attachments_api.rbindex dcefd835ce5..6cfc1a6667d 100644--- a/lib/api/v3/attachments/attachments_api.rb+++ b/lib/api/v3/attachments/attachments_api.rb@@ -65,7 +65,9 @@ module APIhelpers ::API::Helpers::AttachmentRendererget do- respond_with_attachment @attachment, cache_seconds: 1.year.to_i+ # Cache that value at max 604799 seconds, which is the max+ # allowed expiry time for AWS generated links+ respond_with_attachment @attachment, cache_seconds: 604799endendenddiff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rbindex 2827cb1794c..35f5bb81ecf 100644--- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb+++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb@@ -277,13 +277,13 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :jexpect(subject.headers['Content-Type']).to eql mock_file.content_type- expect(subject.headers["Cache-Control"]).to eq "public, max-age=#{1.year.to_i}"+ expect(subject.headers["Cache-Control"]).to eq "public, max-age=604799"expect(subject.headers["Expires"]).to be_presentexpires_time = Time.parse response.headers["Expires"]- expect(expires_time < Time.now.utc + 1.year.to_i).to be_truthy- expect(expires_time > Time.now.utc + 1.year.to_i - 60).to be_truthy+ expect(expires_time < Time.now.utc + 604799).to be_truthy+ expect(expires_time > Time.now.utc + 604799 - 60).to be_truthyendit 'sends the file in binary' do@@ -332,13 +332,13 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :jexpect(subject.headers['Location']).to eql external_url- expect(subject.headers["Cache-Control"]).to eq "public, max-age=#{1.year.to_i}"+ expect(subject.headers["Cache-Control"]).to eq "public, max-age=604799"expect(subject.headers["Expires"]).to be_presentexpires_time = Time.parse response.headers["Expires"]- expect(expires_time < Time.now.utc + 1.year.to_i).to be_truthy- expect(expires_time > Time.now.utc + 1.year.to_i - 60).to be_truthy+ expect(expires_time < Time.now.utc + 604799).to be_truthy+ expect(expires_time > Time.now.utc + 604799 - 60).to be_truthyendendend