From af0caadb8d9781770399c1804976af4a71d1313b Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Fri, 15 Dec 2017 19:26:53 -0500 Subject: Handle invalid signed blob IDs gracefully --- activestorage/test/controllers/blobs_controller_test.rb | 5 +++++ activestorage/test/controllers/previews_controller_test.rb | 9 +++++++++ activestorage/test/controllers/variants_controller_test.rb | 9 +++++++++ 3 files changed, 23 insertions(+) (limited to 'activestorage/test') diff --git a/activestorage/test/controllers/blobs_controller_test.rb b/activestorage/test/controllers/blobs_controller_test.rb index 97177e64c2..9c811df895 100644 --- a/activestorage/test/controllers/blobs_controller_test.rb +++ b/activestorage/test/controllers/blobs_controller_test.rb @@ -8,6 +8,11 @@ class ActiveStorage::BlobsControllerTest < ActionDispatch::IntegrationTest @blob = create_file_blob filename: "racecar.jpg" end + test "showing blob with invalid signed ID" do + get rails_service_blob_url("invalid", "racecar.jpg") + assert_response :not_found + end + test "showing blob utilizes browser caching" do get rails_blob_url(@blob) diff --git a/activestorage/test/controllers/previews_controller_test.rb b/activestorage/test/controllers/previews_controller_test.rb index c3151a710e..704a466160 100644 --- a/activestorage/test/controllers/previews_controller_test.rb +++ b/activestorage/test/controllers/previews_controller_test.rb @@ -21,4 +21,13 @@ class ActiveStorage::PreviewsControllerTest < ActionDispatch::IntegrationTest assert_equal 77, image.width assert_equal 100, image.height end + + test "showing preview with invalid signed blob ID" do + get rails_blob_preview_url( + filename: @blob.filename, + signed_blob_id: "invalid", + variation_key: ActiveStorage::Variation.encode(resize: "100x100")) + + assert_response :not_found + end end diff --git a/activestorage/test/controllers/variants_controller_test.rb b/activestorage/test/controllers/variants_controller_test.rb index 6c70d73786..a0642f9bed 100644 --- a/activestorage/test/controllers/variants_controller_test.rb +++ b/activestorage/test/controllers/variants_controller_test.rb @@ -20,4 +20,13 @@ class ActiveStorage::VariantsControllerTest < ActionDispatch::IntegrationTest assert_equal 100, image.width assert_equal 67, image.height end + + test "showing variant with invalid signed blob ID" do + get rails_blob_variation_url( + filename: @blob.filename, + signed_blob_id: "invalid", + variation_key: ActiveStorage::Variation.encode(resize: "100x100")) + + assert_response :not_found + end end -- cgit v1.2.3