Commit e7e9def1ff220b627226363265a4819655e83d6d
1 parent
dc356d38
Exists in
master
and in
22 other branches
ActionItem438: requiring SSL in admin stuff
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2471 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
25 additions
and
6 deletions
Show diff stats
app/controllers/admin/environment_role_manager_controller.rb
app/controllers/admin/region_validators_controller.rb
app/controllers/admin_controller.rb
test/functional/admin_controller_test.rb
@@ -5,15 +5,28 @@ require 'admin_controller' | @@ -5,15 +5,28 @@ require 'admin_controller' | ||
5 | class AdminController; def rescue_action(e) raise e end; end | 5 | class AdminController; def rescue_action(e) raise e end; end |
6 | 6 | ||
7 | class AdminControllerTest < Test::Unit::TestCase | 7 | class AdminControllerTest < Test::Unit::TestCase |
8 | + | ||
9 | + class AdminTestController < AdminController | ||
10 | + def index | ||
11 | + render :text => 'ok', :layout => false | ||
12 | + end | ||
13 | + end | ||
14 | + | ||
8 | def setup | 15 | def setup |
9 | - @controller = AdminController.new | 16 | + @controller = AdminTestController.new |
10 | @request = ActionController::TestRequest.new | 17 | @request = ActionController::TestRequest.new |
11 | @response = ActionController::TestResponse.new | 18 | @response = ActionController::TestResponse.new |
12 | end | 19 | end |
13 | 20 | ||
14 | - # Replace this with your real tests. | ||
15 | - def test_truth | ||
16 | - assert true | 21 | + should 'require ssl' do |
22 | + get :index | ||
23 | + assert_redirected_to :protocol => 'https://' | ||
24 | + end | ||
25 | + | ||
26 | + should 'detect ssl' do | ||
27 | + @request.expects(:ssl?).returns(true).at_least_once | ||
28 | + get :index | ||
29 | + assert_response :success | ||
17 | end | 30 | end |
18 | 31 | ||
19 | end | 32 | end |
test/functional/admin_panel_controller_test.rb
@@ -10,6 +10,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase | @@ -10,6 +10,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase | ||
10 | def setup | 10 | def setup |
11 | @controller = AdminPanelController.new | 11 | @controller = AdminPanelController.new |
12 | @request = ActionController::TestRequest.new | 12 | @request = ActionController::TestRequest.new |
13 | + @request.stubs(:ssl?).returns(true) | ||
13 | @response = ActionController::TestResponse.new | 14 | @response = ActionController::TestResponse.new |
14 | login_as(create_admin_user(Environment.default)) | 15 | login_as(create_admin_user(Environment.default)) |
15 | end | 16 | end |
test/functional/categories_controller_test.rb
@@ -9,6 +9,7 @@ class CategoriesControllerTest < Test::Unit::TestCase | @@ -9,6 +9,7 @@ class CategoriesControllerTest < Test::Unit::TestCase | ||
9 | def setup | 9 | def setup |
10 | @controller = CategoriesController.new | 10 | @controller = CategoriesController.new |
11 | @request = ActionController::TestRequest.new | 11 | @request = ActionController::TestRequest.new |
12 | + @request.stubs(:ssl?).returns(true) | ||
12 | @response = ActionController::TestResponse.new | 13 | @response = ActionController::TestResponse.new |
13 | 14 | ||
14 | @env = Environment.create!(:name => "My test environment") | 15 | @env = Environment.create!(:name => "My test environment") |
test/functional/features_controller_test.rb
@@ -10,6 +10,7 @@ class FeaturesControllerTest < Test::Unit::TestCase | @@ -10,6 +10,7 @@ class FeaturesControllerTest < Test::Unit::TestCase | ||
10 | def setup | 10 | def setup |
11 | @controller = FeaturesController.new | 11 | @controller = FeaturesController.new |
12 | @request = ActionController::TestRequest.new | 12 | @request = ActionController::TestRequest.new |
13 | + @request.stubs(:ssl?).returns(true) | ||
13 | @response = ActionController::TestResponse.new | 14 | @response = ActionController::TestResponse.new |
14 | login_as(create_admin_user(Environment.find(2))) | 15 | login_as(create_admin_user(Environment.find(2))) |
15 | end | 16 | end |
test/functional/region_validators_controller_test.rb
@@ -9,6 +9,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase | @@ -9,6 +9,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase | ||
9 | def setup | 9 | def setup |
10 | @controller = RegionValidatorsController.new | 10 | @controller = RegionValidatorsController.new |
11 | @request = ActionController::TestRequest.new | 11 | @request = ActionController::TestRequest.new |
12 | + @request.stubs(:ssl?).returns(true) | ||
12 | @response = ActionController::TestResponse.new | 13 | @response = ActionController::TestResponse.new |
13 | login_as('ze') | 14 | login_as('ze') |
14 | end | 15 | end |
test/functional/role_controller_test.rb
@@ -10,6 +10,7 @@ class RoleControllerTest < Test::Unit::TestCase | @@ -10,6 +10,7 @@ class RoleControllerTest < Test::Unit::TestCase | ||
10 | def setup | 10 | def setup |
11 | @controller = RoleController.new | 11 | @controller = RoleController.new |
12 | @request = ActionController::TestRequest.new | 12 | @request = ActionController::TestRequest.new |
13 | + @request.stubs(:ssl?).returns(true) | ||
13 | @response = ActionController::TestResponse.new | 14 | @response = ActionController::TestResponse.new |
14 | @role = Role.find(:first) | 15 | @role = Role.find(:first) |
15 | login_as(:ze) | 16 | login_as(:ze) |