diff --git a/lib/rack/test.rb b/lib/rack/test.rb index bd248378..c5be79b1 100644 --- a/lib/rack/test.rb +++ b/lib/rack/test.rb @@ -242,6 +242,7 @@ def env_for(path, env) def process_request(uri, env) uri = URI.parse(uri) uri.host ||= @default_host + uri.scheme ||= "https" if env["HTTPS"] == "on" @rack_mock_session.request(uri, env) diff --git a/spec/rack/test/cookie_spec.rb b/spec/rack/test/cookie_spec.rb index ba69b0ac..0b8a623f 100644 --- a/spec/rack/test/cookie_spec.rb +++ b/spec/rack/test/cookie_spec.rb @@ -138,6 +138,16 @@ expect(rack_mock_session.cookie_jar['secure-cookie']).to eq('set') end + it "supports secure cookies when enabling SSL via env" do + get "//example.com/cookies/set-secure", { "value" => "set" }, "HTTPS" => "on" + get "//example.com/cookies/show", nil, "HTTPS" => "off" + check expect(last_request.cookies).to eq({}) + + get "//example.com/cookies/show", nil, "HTTPS" => "on" + expect(last_request.cookies).to eq({ "secure-cookie" => "set" }) + expect(rack_mock_session.cookie_jar['secure-cookie']).to eq('set') + end + it "keeps separate cookie jars for different domains" do get "http://example.com/cookies/set", "value" => "example" get "http://example.com/cookies/show"