Add Rack::Lint to DebugLocks tests

This adds additional test coverage to HostAuthorization to validate that
its behavior conforms to Rack SPEC.

This fixes the following two issues in the reponse returned by
DebugLocks:
- Rack::Lint::Error: uppercase character in header name
  Content-{Type/Length}
- Rack::Lint::Error: a header value must be a String or Array of
  Strings, but the value of 'content-length' is an Integer
This commit is contained in:
Hartley McGuire 2023-07-27 16:28:19 -04:00
parent 546dad9904
commit fe5eb3d0fb
No known key found for this signature in database
GPG Key ID: E823FC1403858A82
2 changed files with 4 additions and 2 deletions

@ -99,8 +99,8 @@ def render_details(req)
msg << "\n#{info[:backtrace].join("\n")}\n" if info[:backtrace]
end.join("\n\n---\n\n\n")
[200, { "Content-Type" => "text/plain; charset=#{ActionDispatch::Response.default_charset}",
"Content-Length" => str.size }, [str]]
[200, { Rack::CONTENT_TYPE => "text/plain; charset=#{ActionDispatch::Response.default_charset}",
Rack::CONTENT_LENGTH => str.size.to_s }, [str]]
end
def blocked_by?(victim, blocker, all_threads)

@ -32,7 +32,9 @@ def test_render_threads_status
private
def build_app
@app = self.class.build_app do |middleware|
middleware.use Rack::Lint
middleware.use ActionDispatch::DebugLocks
middleware.use Rack::Lint
end
end
end