Merge pull request #48805 from skipkayhil/hm-rack-lint-request-id
Add Rack::Lint to RequestId tests
This commit is contained in:
commit
0a39604161
@ -8,7 +8,7 @@ class RequestIdTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "passing on the request id via a configured header" do
|
test "passing on the request id via a configured header" do
|
||||||
assert_equal "external-uu-rid", stub_request({ "HTTP_TRACER_ID" => "external-uu-rid" }, header: "Tracer-Id").request_id
|
assert_equal "external-uu-rid", stub_request({ "HTTP_TRACER_ID" => "external-uu-rid" }, header: "tracer-id").request_id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "ensure that only alphanumeric uurids are accepted" do
|
test "ensure that only alphanumeric uurids are accepted" do
|
||||||
@ -33,8 +33,17 @@ class RequestIdTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def stub_request(env = {}, header: "X-Request-Id")
|
def stub_request(env = {}, header: "x-request-id")
|
||||||
ActionDispatch::RequestId.new(lambda { |environment| [ 200, environment, [] ] }, header: header).call(env)
|
app = lambda { |_env| [ 200, {}, [] ] }
|
||||||
|
env = Rack::MockRequest.env_for("", env)
|
||||||
|
|
||||||
|
Rack::Lint.new(
|
||||||
|
ActionDispatch::RequestId.new(
|
||||||
|
Rack::Lint.new(app),
|
||||||
|
header: header,
|
||||||
|
)
|
||||||
|
).call(env)
|
||||||
|
|
||||||
ActionDispatch::Request.new(env)
|
ActionDispatch::Request.new(env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -75,7 +84,9 @@ def with_test_route_set(header: "X-Request-Id")
|
|||||||
end
|
end
|
||||||
|
|
||||||
@app = self.class.build_app(set) do |middleware|
|
@app = self.class.build_app(set) do |middleware|
|
||||||
|
middleware.use Rack::Lint
|
||||||
middleware.use ActionDispatch::RequestId, header: header
|
middleware.use ActionDispatch::RequestId, header: header
|
||||||
|
middleware.use Rack::Lint
|
||||||
end
|
end
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
Loading…
Reference in New Issue
Block a user