class MartenRailsBridge::ActiveStorage::Representations::RedirectHandlerGuardTest

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. :nodoc:

Defined in:

active_storage/representations/redirect_handler_test.cr

Constant Summary

BLOB_KEY = "gz0zdzhk0yn6zjhxfzl6qt1ys5rj"
MEDIUM_DIGEST = "1349c67feef77f80b95ba12d5ee190149ed47e212ff4fffb0a237b33a3c313a5"

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_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.