class MartenRailsBridge::ActiveStorage::Blobs::ProxyHandlerGuardTest

Overview

The gate a consumer puts in front of the mounted handler.

Marten::Handlers::Base#process_dispatch assigns the response a before_dispatch callback returns and never calls #dispatch, so the gate runs before ActiveStorage::Blob.find_signed!: a refused request reads neither the database nor the storage, and no byte of the blob is written. :nodoc:

Defined in:

active_storage/blobs/proxy_handler_test.cr

Constant Summary

PAYLOAD = "0123456789"

Body stored for the blob created by #create_blob.

Instance Method Summary

Instance Method Detail

def setup #

def teardown #

def test_a_bad_signed_id_is_a_404_with_a_credential_and_a_401_without #

The ordering proof: the same bad signed ID answers 404 once the gate passed and 401 before it, which only holds if the gate runs first.


def test_a_range_request_without_a_credential_writes_no_partial_body #

A Range request is the one that could leak a slice of the blob, so it is refused before the range is even parsed: no 206, no Content-Range and no body.


def test_a_revoked_credential_is_refused #

def test_a_subclass_that_forgets_http_method_names_widens_the_allowed_verbs #

def test_a_valid_credential_is_served #

def test_a_wrong_credential_is_refused #

def test_an_anonymous_request_is_refused_without_touching_the_service #

def test_the_refusal_carries_an_empty_content_type #

#head leaves an empty content type where Rails sends none. The 404 path of the handler deviates the same way, and neither is fixed here.


def test_the_widened_verbs_leak_through_the_allow_header_only #

The widened verbs answer 405 all the same, because the Marten::Handlers::Base method of each of them does. What leaks is the Allow header of an OPTIONS response.