aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/request/session_test.rb10
-rw-r--r--actionpack/test/dispatch/response_test.rb8
-rw-r--r--actionpack/test/dispatch/session/abstract_store_test.rb16
-rw-r--r--actionpack/test/dispatch/session/cache_store_test.rb29
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb34
-rw-r--r--actionpack/test/dispatch/session/mem_cache_store_test.rb31
-rw-r--r--actionpack/test/dispatch/session/test_session_test.rb7
-rw-r--r--actionpack/test/dispatch/ssl_test.rb23
8 files changed, 24 insertions, 134 deletions
diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb
index 3433d82791..7dcbcc5c21 100644
--- a/actionpack/test/dispatch/request/session_test.rb
+++ b/actionpack/test/dispatch/request/session_test.rb
@@ -105,16 +105,6 @@ module ActionDispatch
end
end
- def test_indifferent_access
- s = Session.create(store, req, {})
-
- s[:one] = { test: "deep" }
- s[:two] = { "test" => "deep" }
-
- assert_equal 'deep', s[:one]["test"]
- assert_equal 'deep', s[:two][:test]
- end
-
private
def store
Class.new {
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb
index 8b3849cb7a..cd385982d9 100644
--- a/actionpack/test/dispatch/response_test.rb
+++ b/actionpack/test/dispatch/response_test.rb
@@ -445,4 +445,12 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest
assert_equal('application/xml; charset=utf-16', @response.headers['Content-Type'])
end
+
+ test "we can set strong ETag by directly adding it as header" do
+ @response = ActionDispatch::Response.create
+ @response.add_header "ETag", '"202cb962ac59075b964b07152d234b70"'
+
+ assert_equal('"202cb962ac59075b964b07152d234b70"', @response.etag)
+ assert_equal('"202cb962ac59075b964b07152d234b70"', @response.headers['ETag'])
+ end
end
diff --git a/actionpack/test/dispatch/session/abstract_store_test.rb b/actionpack/test/dispatch/session/abstract_store_test.rb
index c9ce5cad42..d38d1bbce6 100644
--- a/actionpack/test/dispatch/session/abstract_store_test.rb
+++ b/actionpack/test/dispatch/session/abstract_store_test.rb
@@ -46,22 +46,6 @@ module ActionDispatch
assert_equal session.to_hash, session1.to_hash
end
- def test_previous_session_has_indifferent_access
- env = {}
- as = MemoryStore.new app
- as.call(env)
-
- assert @env
- session = Request::Session.find ActionDispatch::Request.new @env
- session[:foo] = { bar: "baz" }
-
- as.call(@env)
- session = Request::Session.find ActionDispatch::Request.new @env
-
- assert_equal session[:foo][:bar], "baz"
- assert_equal session[:foo]["bar"], "baz"
- end
-
private
def app(&block)
@env = nil
diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb
index b911392cf1..dbb996973d 100644
--- a/actionpack/test/dispatch/session/cache_store_test.rb
+++ b/actionpack/test/dispatch/session/cache_store_test.rb
@@ -12,11 +12,6 @@ class CacheStoreTest < ActionDispatch::IntegrationTest
head :ok
end
- def set_deep_session_value
- session[:foo] = { bar: "baz" }
- head :ok
- end
-
def set_serialized_session_value
session[:foo] = SessionAutoloadTest::Foo.new
head :ok
@@ -26,14 +21,6 @@ class CacheStoreTest < ActionDispatch::IntegrationTest
render plain: "foo: #{session[:foo].inspect}"
end
- def get_deep_session_value_with_symbol
- render plain: "foo: { bar: #{session[:foo][:bar].inspect} }"
- end
-
- def get_deep_session_value_with_string
- render plain: "foo: { \"bar\" => #{session[:foo]["bar"].inspect} }"
- end
-
def get_session_id
render plain: "#{request.session.id}"
end
@@ -173,22 +160,6 @@ class CacheStoreTest < ActionDispatch::IntegrationTest
end
end
- def test_previous_session_has_indifferent_access
- with_test_route_set do
- get '/set_deep_session_value'
- assert_response :success
- assert cookies['_session_id']
-
- get '/get_deep_session_value_with_symbol'
- assert_response :success
- assert_equal 'foo: { bar: "baz" }', response.body
-
- get '/get_deep_session_value_with_string'
- assert_response :success
- assert_equal 'foo: { "bar" => "baz" }', response.body
- end
- end
-
private
def with_test_route_set
with_routing do |set|
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index 71402b021a..f07e215e3a 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -24,23 +24,10 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
render plain: Rack::Utils.escape(Verifier.generate(session.to_hash))
end
- def set_deep_session_value
- session[:foo] = { bar: "baz" }
- render plain: Rack::Utils.escape(Verifier.generate(session.to_hash))
- end
-
def get_session_value
render plain: "foo: #{session[:foo].inspect}"
end
- def get_deep_session_value_with_symbol
- render plain: "foo: { bar: #{session[:foo][:bar].inspect} }"
- end
-
- def get_deep_session_value_with_string
- render plain: "foo: { \"bar\" => #{session[:foo]["bar"].inspect} }"
- end
-
def get_session_id
render plain: "id: #{request.session.id}"
end
@@ -94,15 +81,6 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
end
- def test_session_indifferent_access
- with_test_route_set do
- cookies[SessionKey] = SignedBar
- get '/get_session_value'
- assert_response :success
- assert_equal 'foo: "bar"', response.body
- end
- end
-
def test_getting_session_id
with_test_route_set do
cookies[SessionKey] = SignedBar
@@ -354,18 +332,6 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
end
end
- def test_previous_session_has_indifferent_access
- with_test_route_set do
- get '/set_deep_session_value'
-
- get '/get_deep_session_value_with_symbol'
- assert_equal 'foo: { bar: "baz" }', response.body
-
- get '/get_deep_session_value_with_string'
- assert_equal 'foo: { "bar" => "baz" }', response.body
- end
- end
-
private
# Overwrite get to send SessionSecret in env hash
diff --git a/actionpack/test/dispatch/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb
index 2e6b42856f..3fed9bad4f 100644
--- a/actionpack/test/dispatch/session/mem_cache_store_test.rb
+++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb
@@ -13,11 +13,6 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest
head :ok
end
- def set_deep_session_value
- session[:foo] = { bar: "baz" }
- head :ok
- end
-
def set_serialized_session_value
session[:foo] = SessionAutoloadTest::Foo.new
head :ok
@@ -27,14 +22,6 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest
render plain: "foo: #{session[:foo].inspect}"
end
- def get_deep_session_value_with_symbol
- render plain: "foo: { bar: #{session[:foo][:bar].inspect} }"
- end
-
- def get_deep_session_value_with_string
- render plain: "foo: { \"bar\" => #{session[:foo]["bar"].inspect} }"
- end
-
def get_session_id
render plain: "#{request.session.id}"
end
@@ -192,24 +179,6 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end
-
- def test_previous_session_has_indifferent_access
- with_test_route_set do
- get '/set_deep_session_value'
- assert_response :success
- assert cookies['_session_id']
-
- get '/get_deep_session_value_with_symbol'
- assert_response :success
- assert_equal 'foo: { bar: "baz" }', response.body
-
- get '/get_deep_session_value_with_string'
- assert_response :success
- assert_equal 'foo: { "bar" => "baz" }', response.body
- end
- rescue Dalli::RingError => ex
- skip ex.message, ex.backtrace
- end
rescue LoadError, RuntimeError, Dalli::DalliError
$stderr.puts "Skipping MemCacheStoreTest tests. Start memcached and try again."
end
diff --git a/actionpack/test/dispatch/session/test_session_test.rb b/actionpack/test/dispatch/session/test_session_test.rb
index 332c2ae3c8..3e61d123e3 100644
--- a/actionpack/test/dispatch/session/test_session_test.rb
+++ b/actionpack/test/dispatch/session/test_session_test.rb
@@ -60,11 +60,4 @@ class ActionController::TestSessionTest < ActiveSupport::TestCase
session = ActionController::TestSession.new(one: '1')
assert_equal(2, session.fetch('2') { |key| key.to_i })
end
-
- def test_fetch_returns_indifferent_access
- session = ActionController::TestSession.new(three: { two: '1' })
- three = session.fetch(:three)
- assert_equal('1', three[:two])
- assert_equal('1', three["two"])
- end
end
diff --git a/actionpack/test/dispatch/ssl_test.rb b/actionpack/test/dispatch/ssl_test.rb
index c66a0e6a7a..18ff894b31 100644
--- a/actionpack/test/dispatch/ssl_test.rb
+++ b/actionpack/test/dispatch/ssl_test.rb
@@ -7,7 +7,7 @@ class SSLTest < ActionDispatch::IntegrationTest
def build_app(headers: {}, ssl_options: {})
headers = HEADERS.merge(headers)
- ActionDispatch::SSL.new lambda { |env| [200, headers, []] }, ssl_options
+ ActionDispatch::SSL.new lambda { |env| [200, headers, []] }, ssl_options.reverse_merge(hsts: { subdomains: true })
end
end
@@ -98,15 +98,16 @@ end
class StrictTransportSecurityTest < SSLTest
EXPECTED = 'max-age=15552000'
+ EXPECTED_WITH_SUBDOMAINS = 'max-age=15552000; includeSubDomains'
- def assert_hsts(expected, url: 'https://example.org', hsts: {}, headers: {})
+ def assert_hsts(expected, url: 'https://example.org', hsts: { subdomains: true }, headers: {})
self.app = build_app ssl_options: { hsts: hsts }, headers: headers
get url
assert_equal expected, response.headers['Strict-Transport-Security']
end
test 'enabled by default' do
- assert_hsts EXPECTED
+ assert_hsts EXPECTED_WITH_SUBDOMAINS
end
test 'not sent with http:// responses' do
@@ -126,11 +127,15 @@ class StrictTransportSecurityTest < SSLTest
end
test ':expires sets max-age' do
- assert_hsts 'max-age=500', hsts: { expires: 500 }
+ assert_deprecated do
+ assert_hsts 'max-age=500', hsts: { expires: 500 }
+ end
end
test ':expires supports AS::Duration arguments' do
- assert_hsts 'max-age=31557600', hsts: { expires: 1.year }
+ assert_deprecated do
+ assert_hsts 'max-age=31557600', hsts: { expires: 1.year }
+ end
end
test 'include subdomains' do
@@ -142,11 +147,15 @@ class StrictTransportSecurityTest < SSLTest
end
test 'opt in to browser preload lists' do
- assert_hsts "#{EXPECTED}; preload", hsts: { preload: true }
+ assert_deprecated do
+ assert_hsts "#{EXPECTED}; preload", hsts: { preload: true }
+ end
end
test 'opt out of browser preload lists' do
- assert_hsts EXPECTED, hsts: { preload: false }
+ assert_deprecated do
+ assert_hsts EXPECTED, hsts: { preload: false }
+ end
end
end