diff options
Diffstat (limited to 'activestorage/test')
3 files changed, 20 insertions, 57 deletions
diff --git a/activestorage/test/controllers/blobs_controller_test.rb b/activestorage/test/controllers/blobs_controller_test.rb index 9bf2641de6..9c811df895 100644 --- a/activestorage/test/controllers/blobs_controller_test.rb +++ b/activestorage/test/controllers/blobs_controller_test.rb @@ -20,28 +20,3 @@ class ActiveStorage::BlobsControllerTest < ActionDispatch::IntegrationTest assert_equal "max-age=300, private", @response.headers["Cache-Control"] end end - -if SERVICE_CONFIGURATIONS[:s3] && SERVICE_CONFIGURATIONS[:s3][:access_key_id].present? - class ActiveStorage::S3BlobsControllerTest < ActionDispatch::IntegrationTest - setup do - @old_service = ActiveStorage::Blob.service - ActiveStorage::Blob.service = ActiveStorage::Service.configure(:s3, SERVICE_CONFIGURATIONS) - end - - teardown do - ActiveStorage::Blob.service = @old_service - end - - test "allow redirection to the different host" do - blob = create_file_blob filename: "racecar.jpg" - - assert_nothing_raised { get rails_blob_url(blob) } - assert_response :redirect - assert_no_match @request.host, @response.headers["Location"] - ensure - blob.purge - end - end -else - puts "Skipping S3 redirection tests because no S3 configuration was supplied" -end diff --git a/activestorage/test/controllers/representations_controller_test.rb b/activestorage/test/controllers/representations_controller_test.rb index 4ae0ff877e..2662cc5283 100644 --- a/activestorage/test/controllers/representations_controller_test.rb +++ b/activestorage/test/controllers/representations_controller_test.rb @@ -59,33 +59,3 @@ class ActiveStorage::RepresentationsControllerWithPreviewsTest < ActionDispatch: assert_response :not_found end end - -if SERVICE_CONFIGURATIONS[:s3] && SERVICE_CONFIGURATIONS[:s3][:access_key_id].present? - class ActiveStorage::S3RepresentationsControllerWithVariantsTest < ActionDispatch::IntegrationTest - setup do - @old_service = ActiveStorage::Blob.service - ActiveStorage::Blob.service = ActiveStorage::Service.configure(:s3, SERVICE_CONFIGURATIONS) - end - - teardown do - ActiveStorage::Blob.service = @old_service - end - - test "allow redirection to the different host" do - blob = create_file_blob filename: "racecar.jpg" - - assert_nothing_raised do - get rails_blob_representation_url( - filename: blob.filename, - signed_blob_id: blob.signed_id, - variation_key: ActiveStorage::Variation.encode(resize: "100x100")) - end - assert_response :redirect - assert_no_match @request.host, @response.headers["Location"] - ensure - blob.purge - end - end -else - puts "Skipping S3 redirection tests because no S3 configuration was supplied" -end diff --git a/activestorage/test/service/s3_service_test.rb b/activestorage/test/service/s3_service_test.rb index 74c0aa0405..b9120770e6 100644 --- a/activestorage/test/service/s3_service_test.rb +++ b/activestorage/test/service/s3_service_test.rb @@ -46,8 +46,7 @@ if SERVICE_CONFIGURATIONS[:s3] end test "uploading with server-side encryption" do - config = SERVICE_CONFIGURATIONS.deep_merge(s3: { upload: { server_side_encryption: "AES256" } }) - service = ActiveStorage::Service.configure(:s3, config) + service = build_service(upload: { server_side_encryption: "AES256" }) begin key = SecureRandom.base58(24) @@ -77,6 +76,25 @@ if SERVICE_CONFIGURATIONS[:s3] ensure @service.delete key end + + test "uploading a large object in multiple parts" do + service = build_service(upload: { multipart_threshold: 5.megabytes }) + + begin + key = SecureRandom.base58(24) + data = SecureRandom.bytes(8.megabytes) + + service.upload key, StringIO.new(data), checksum: Digest::MD5.base64digest(data) + assert data == service.download(key) + ensure + service.delete key + end + end + + private + def build_service(configuration) + ActiveStorage::Service.configure :s3, SERVICE_CONFIGURATIONS.deep_merge(s3: configuration) + end end else puts "Skipping S3 Service tests because no S3 configuration was supplied" |