Changeset 8780
- Timestamp:
- 02/02/08 05:16:53 (6 months ago)
- Files:
-
- plugins/ssl_requirement/lib/ssl_requirement.rb (modified) (1 diff)
- plugins/ssl_requirement/test/ssl_requirement_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/ssl_requirement/lib/ssl_requirement.rb
r3048 r8780 52 52 if ssl_required? && !request.ssl? 53 53 redirect_to "https://" + request.host + request.request_uri 54 flash.keep 54 55 return false 55 56 elsif request.ssl? && !ssl_required? 56 57 redirect_to "http://" + request.host + request.request_uri 58 flash.keep 57 59 return false 58 60 end plugins/ssl_requirement/test/ssl_requirement_test.rb
r3048 r8780 45 45 render :nothing => true 46 46 end 47 48 def set_flash 49 flash[:foo] = "bar" 50 end 47 51 end 48 52 … … 54 58 end 55 59 60 def test_redirect_to_https_preserves_flash 61 get :set_flash 62 get :b 63 assert_response :redirect 64 assert_equal "bar", flash[:foo] 65 end 66 67 def test_not_redirecting_to_https_does_not_preserve_the_flash 68 get :set_flash 69 get :d 70 assert_response :success 71 assert_nil flash[:foo] 72 end 73 74 def test_redirect_to_http_preserves_flash 75 get :set_flash 76 @request.env['HTTPS'] = "on" 77 get :d 78 assert_response :redirect 79 assert_equal "bar", flash[:foo] 80 end 81 82 def test_not_redirecting_to_http_does_not_preserve_the_flash 83 get :set_flash 84 @request.env['HTTPS'] = "on" 85 get :a 86 assert_response :success 87 assert_nil flash[:foo] 88 end 89 56 90 def test_required_without_ssl 57 91 assert_not_equal "on", @request.env["HTTPS"] 58 92 get :a 59 93 assert_response :redirect 60 assert_match %r{^https://}, @response.headers[' location']94 assert_match %r{^https://}, @response.headers['Location'] 61 95 get :b 62 96 assert_response :redirect 63 assert_match %r{^https://}, @response.headers[' location']97 assert_match %r{^https://}, @response.headers['Location'] 64 98 end 65 99 … … 82 116 get :d 83 117 assert_response :redirect 84 assert_match %r{^http://}, @response.headers[' location']118 assert_match %r{^http://}, @response.headers['Location'] 85 119 end 86 120