diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 809c220..69655f9 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,3 +1,2 @@ class AdminController < ApplicationController - require_ssl end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cd10b5a..fb37d62 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -42,34 +42,6 @@ class ApplicationController < ActionController::Base include AuthenticatedSystem include PermissionCheck - def self.require_ssl(*options) - before_filter :check_ssl, *options - end - def check_ssl - return true if (request.ssl? || ENV['RAILS_ENV'] == 'development') - redirect_to_ssl - end - def redirect_to_ssl - if environment.enable_ssl - redirect_to(params.merge(:protocol => 'https://', :host => ssl_hostname)) - true - else - false - end - end - - def self.refuse_ssl(*options) - before_filter :avoid_ssl, *options - end - def avoid_ssl - if (!request.ssl? || ENV['RAILS_ENV'] == 'development') - true - else - redirect_to(params.merge(:protocol => 'http://')) - false - end - end - before_filter :set_locale def set_locale FastGettext.available_locales = Noosfero.available_locales diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 3d8aeb9..e1bc5e9 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -23,15 +23,6 @@ class CmsController < MyProfileController profile.articles.find(c.params[:id]).allow_post_content?(user) end - alias :check_ssl_orig :check_ssl - # Redefines the SSL checking to avoid requiring SSL when creating the "New - # publication" button on article's public view. - def check_ssl - if ((params[:action] == 'new') && (!request.xhr?)) || (params[:action] != 'new') - check_ssl_orig - end - end - def boxes_holder profile end @@ -341,10 +332,6 @@ class CmsController < MyProfileController end end - def maybe_ssl(url) - [url, url.sub('https:', 'http:')] - end - def valid_article_type?(type) (available_article_types + special_article_types).map {|item| item.name}.include?(type) end diff --git a/app/controllers/my_profile_controller.rb b/app/controllers/my_profile_controller.rb index 371c835..5910e02 100644 --- a/app/controllers/my_profile_controller.rb +++ b/app/controllers/my_profile_controller.rb @@ -2,7 +2,6 @@ class MyProfileController < ApplicationController needs_profile - require_ssl before_filter :login_required diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 75607c4..6f3d8e3 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -4,7 +4,6 @@ class AccountController < ApplicationController inverse_captcha :field => 'e_mail' - require_ssl :except => [ :login_popup, :logout_popup, :profile_details ] before_filter :login_required, :only => [:activation_question, :accept_terms, :activate_enterprise] before_filter :redirect_if_logged_in, :only => [:login, :signup] diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 89041bd..a296f7c 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -33,14 +33,6 @@ class ContentViewerController < ApplicationController end end - if !@page.public? && !request.ssl? - return if redirect_to_ssl - end - - if @page.public? - return unless avoid_ssl - end - if !@page.display_to?(user) if profile.display_info_to?(user) || !profile.visible? message = _('You are not allowed to view this content. You can contact the owner of this profile to request access then.') diff --git a/app/controllers/public/enterprise_registration_controller.rb b/app/controllers/public/enterprise_registration_controller.rb index 4804491..ac048d0 100644 --- a/app/controllers/public/enterprise_registration_controller.rb +++ b/app/controllers/public/enterprise_registration_controller.rb @@ -1,6 +1,5 @@ class EnterpriseRegistrationController < ApplicationController - require_ssl before_filter :login_required diff --git a/app/controllers/public_controller.rb b/app/controllers/public_controller.rb index 2ace734..2857026 100644 --- a/app/controllers/public_controller.rb +++ b/app/controllers/public_controller.rb @@ -1,3 +1,2 @@ class PublicController < ApplicationController - refuse_ssl end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index df6899d..2c701ff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -876,18 +876,11 @@ module ApplicationHelper def login_url options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) - if environment.enable_ssl && (ENV['RAILS_ENV'] != 'development') - options.merge!(:protocol => 'https://', :host => ssl_hostname) - end url_for(options) end - def ssl_hostname - environment.default_hostname - end - def base_url - environment.top_url(request.ssl?) + environment.top_url end def helper_for_article(article) diff --git a/app/models/environment.rb b/app/models/environment.rb index eef1e14..5a0e63c 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -208,7 +208,6 @@ class Environment < ActiveRecord::Base settings_items :layout_template, :type => String, :default => 'default' settings_items :homepage, :type => String settings_items :description, :type => String, :default => '
Noosfero
' - settings_items :enable_ssl settings_items :local_docs, :type => Array, :default => [] settings_items :news_amount_by_folder, :type => Integer, :default => 4 settings_items :help_message_to_add_enterprise, :type => String, :default => '' @@ -526,8 +525,8 @@ class Environment < ActiveRecord::Base end end - def top_url(ssl = false) - protocol = (ssl ? 'https' : 'http') + def top_url + protocol = 'http' result = "#{protocol}://#{default_hostname}" if Noosfero.url_options.has_key?(:port) result << ':' << Noosfero.url_options[:port].to_s diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index a7134d6..db56fe5 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -15,8 +15,6 @@ class AccountControllerTest < Test::Unit::TestCase @controller = AccountController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - - @request.stubs(:ssl?).returns(true) end def test_local_files_reference @@ -593,38 +591,6 @@ class AccountControllerTest < Test::Unit::TestCase assert_equal 1, assigns(:user).person.boxes[0].blocks.size end - should 'force ssl' do - Environment.default.update_attribute(:enable_ssl, true) - @request.expects(:ssl?).returns(false).at_least_once - get :index - assert_redirected_to :protocol => 'https://' - end - - should 'alllow login_popup without SSL' do - @request.expects(:ssl?).returns(false).at_least_once - get :login_popup - assert_response :success - end - - should 'allow logout_popup without SSL' do - @request.expects(:ssl?).returns(false).at_least_once - get :logout_popup - assert_response :success - end - - should 'point to SSL URL in login popup' do - Environment.default.update_attribute(:enable_ssl, true) - get :login_popup - assert_tag :tag => 'form', :attributes => { :action => /^https:\/\// } - end - - should 'not point to SSL URL in login popup when in development mode' do - @request.stubs(:ssl?).returns(false) - ENV.expects(:[]).with('RAILS_ENV').returns('development').at_least_once - get :login_popup - assert_no_tag :tag => 'form', :attributes => { :action => /^https:\/\// } - end - should 'render person partial' do Environment.any_instance.expects(:signup_person_fields).returns(['contact_phone']).at_least_once get :signup diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index 0b9c562..8718122 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -6,28 +6,8 @@ class AdminController; def rescue_action(e) raise e end; end class AdminControllerTest < Test::Unit::TestCase - class AdminTestController < AdminController - def index - render :text => 'ok', :layout => 'application' - end - end - - def setup - @controller = AdminTestController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - should 'require ssl' do - Environment.default.update_attribute(:enable_ssl, true) - get :index - assert_redirected_to :protocol => 'https://' - end - - should 'detect ssl' do - @request.expects(:ssl?).returns(true).at_least_once - get :index - assert_response :success + should 'inherit from ApplicationController' do + assert_kind_of ApplicationController, AdminController.new end end diff --git a/test/functional/admin_panel_controller_test.rb b/test/functional/admin_panel_controller_test.rb index 290b70e..a735ae1 100644 --- a/test/functional/admin_panel_controller_test.rb +++ b/test/functional/admin_panel_controller_test.rb @@ -10,7 +10,6 @@ class AdminPanelControllerTest < Test::Unit::TestCase def setup @controller = AdminPanelController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as(create_admin_user(Environment.default)) end diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index 81af15d..fe30b6a 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -252,99 +252,6 @@ class ApplicationControllerTest < Test::Unit::TestCase get :index end - should 'require ssl when told to' do - Environment.default.update_attribute(:enable_ssl, true) - @request.expects(:ssl?).returns(false).at_least_once - get :sslonly - assert_redirected_to :protocol => 'https://' - end - - should 'not force ssl in development mode' do - ENV.expects(:[]).with('RAILS_ENV').returns('development').at_least_once - @request.expects(:ssl?).returns(false).at_least_once - get :sslonly - assert_response :success - end - - should 'not force ssl when not told to' do - @request.expects(:ssl?).returns(false).at_least_once - get :doesnt_need_ssl - assert_response :success - end - - should 'not force ssl when already in ssl' do - @request.expects(:ssl?).returns(true).at_least_once - get :sslonly - assert_response :success - end - - should 'keep arguments when redirecting to ssl' do - Environment.default.update_attribute(:enable_ssl, true) - @request.expects(:ssl?).returns(false).at_least_once - get :sslonly, :x => '1', :y => '2' - assert_redirected_to :protocol => 'https://', :x => '1', :y => '2' - end - - should 'refuse ssl when told to' do - @request.expects(:ssl?).returns(true).at_least_once - get :nossl - assert_redirected_to :protocol => "http://" - end - - should 'not refuse ssl when not told to' do - @request.expects(:ssl?).returns(true).at_least_once - get :doesnt_refuse_ssl - assert_response :success - end - should 'not refuse ssl while in development mode' do - ENV.expects(:[]).with('RAILS_ENV').returns('development').at_least_once - @request.expects(:ssl?).returns(true).at_least_once - get :nossl - assert_response :success - end - should 'not refuse ssl when not in ssl' do - @request.expects(:ssl?).returns(false).at_least_once - get :nossl - assert_response :success - end - - should 'keep arguments when redirecting to non-ssl' do - @request.expects(:ssl?).returns(true).at_least_once - get :nossl, :x => '1', :y => '2' - assert_redirected_to :protocol => 'http://', :x => '1', :y => '2' - end - - should 'add https protocols on redirect_to_ssl' do - Environment.default.update_attribute(:enable_ssl, true) - get :sslonly, :x => '1', :y => '1' - assert_redirected_to :x => '1', :y => '1', :protocol => 'https://' - end - - should 'return true in redirect_to_ssl' do - env = mock - env.expects(:enable_ssl).returns(true) - env.stubs(:default_hostname).returns('test.mydomain.net') - @controller.stubs(:environment).returns(env) - @controller.expects(:params).returns({}) - @controller.expects(:redirect_to).with({:protocol => 'https://', :host => 'test.mydomain.net'}) - assert_equal true, @controller.redirect_to_ssl - end - should 'return false in redirect_to_ssl when ssl is disabled' do - env = mock - env.expects(:enable_ssl).returns(false) - @controller.expects(:environment).returns(env) - assert_equal false, @controller.redirect_to_ssl - end - - should 'not force ssl when ssl is disabled' do - env = Environment.default - env.expects(:enable_ssl).returns(false) - @controller.stubs(:environment).returns(env) - @request.expects(:ssl?).returns(false).at_least_once - get :sslonly - assert_response :success - end - should 'not display categories menu if categories feature disabled' do Environment.any_instance.stubs(:enabled?).with(anything).returns(true) c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent => nil, :display_in_menu => true ) @@ -403,17 +310,6 @@ class ApplicationControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'div', :attributes => {:id => 'block-' + b.id.to_s} end - should 'return false when not avoid ssl' do - req = mock - req.stubs(:ssl?).returns(true) - - @controller.expects(:request).returns(req) - @controller.stubs(:params).returns({}) - @controller.stubs(:redirect_to) - - assert_equal false, @controller.avoid_ssl - end - should 'diplay name of environment in description' do get :index assert_tag :tag => 'meta', :attributes => { :name => 'description', :content => assigns(:environment).name } diff --git a/test/functional/browse_controller_test.rb b/test/functional/browse_controller_test.rb index 92d1f21..690065f 100644 --- a/test/functional/browse_controller_test.rb +++ b/test/functional/browse_controller_test.rb @@ -9,7 +9,6 @@ class BrowseControllerTest < Test::Unit::TestCase def setup @controller = BrowseController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(false) @response = ActionController::TestResponse.new # By pass user validation on person creation diff --git a/test/functional/categories_controller_test.rb b/test/functional/categories_controller_test.rb index 84f4ff9..8d1444a 100644 --- a/test/functional/categories_controller_test.rb +++ b/test/functional/categories_controller_test.rb @@ -9,7 +9,6 @@ class CategoriesControllerTest < Test::Unit::TestCase def setup @controller = CategoriesController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @env = fast_create(Environment, :name => "My test environment") diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 58006fa..35c1688 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -11,7 +11,6 @@ class CmsControllerTest < Test::Unit::TestCase def setup @controller = CmsController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @profile = create_user_with_permission('testinguser', 'post_content') @@ -759,33 +758,6 @@ class CmsControllerTest < Test::Unit::TestCase end end - should 'require ssl in general' do - Environment.default.update_attribute(:enable_ssl, true) - @request.expects(:ssl?).returns(false).at_least_once - get :index, :profile => 'testinguser' - assert_redirected_to :protocol => 'https://' - end - - should 'accept ajax connections to new action without ssl' do - @request.expects(:ssl?).returns(false).at_least_once - xml_http_request :get, :new, :profile => 'testinguser' - assert_response :success - end - - should 'not loose type argument in new action when redirecting to ssl' do - Environment.default.update_attribute(:enable_ssl, true) - @request.expects(:ssl?).returns(false).at_least_once - get :new, :profile => 'testinguser', :type => 'Folder' - assert_redirected_to :protocol => 'https://', :action => 'new', :type => 'Folder' - end - - should 'not accept non-ajax connections to new action without ssl' do - Environment.default.update_attribute(:enable_ssl, true) - @request.expects(:ssl?).returns(false).at_least_once - get :new, :profile => 'testinguser' - assert_redirected_to :protocol => 'https://' - end - should 'display categories if environment disable_categories disabled' do Environment.any_instance.stubs(:enabled?).with(anything).returns(false) a = profile.articles.create!(:name => 'test') diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 52c6b05..ad00715 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -316,7 +316,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase community.add_member(profile) login_as(profile.identifier) - @request.stubs(:ssl?).returns(true) get :view_page, :profile => community.identifier, :page => [ folder.path ] assert_template 'access_denied.rhtml' @@ -329,7 +328,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase login_as(profile.identifier) - @request.stubs(:ssl?).returns(true) get :view_page, :profile => community.identifier, :page => [ 'test' ] assert_response :success end @@ -341,7 +339,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase login_as(profile.identifier) - @request.stubs(:ssl?).returns(true) get :view_page, :profile => community.identifier, :page => [ 'test' ] assert_response :success end @@ -400,7 +397,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase profile = Profile.create!(:name => 'test profile', :identifier => 'test_profile') intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) - @request.stubs(:ssl?).returns(true) get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] assert_template 'access_denied.rhtml' @@ -411,7 +407,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase profile = Profile.create!(:name => 'test profile', :identifier => 'test_profile') intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) - @request.stubs(:ssl?).returns(true) get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] assert_template 'access_denied.rhtml' @@ -424,7 +419,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase profile.affiliate(person, Profile::Roles.member(profile.environment.id)) login_as('test_user') - @request.stubs(:ssl?).returns(true) get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] assert_template 'access_denied.rhtml' @@ -437,7 +431,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase profile.affiliate(person, Profile::Roles.moderator(profile.environment.id)) login_as('test_user') - @request.stubs(:ssl?).returns(true) get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] assert_template 'view_page' @@ -450,7 +443,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase profile.affiliate(person, Profile::Roles.admin(profile.environment.id)) login_as('test_user') - @request.stubs(:ssl?).returns(true) get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] assert_template 'view_page' @@ -473,28 +465,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_tag :tag => 'a', :attributes => {:href => ('/myprofile/' + profile.identifier + '/cms/publish/' + page.id.to_s)} end - should 'require SSL for viewing non-public articles' do - Environment.default.update_attribute(:enable_ssl, true) - page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :published => false) - get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] - assert_redirected_to :protocol => 'https://', :profile => 'testinguser', :page => [ 'myarticle' ] - end - - should 'avoid SSL for viewing public articles' do - @request.expects(:ssl?).returns(true).at_least_once - page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :published => true) - get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] - assert_redirected_to :protocol => 'http://', :profile => 'testinguser', :page => [ 'myarticle' ] - end - - should 'not redirect to SSL if already on SSL' do - @request.expects(:ssl?).returns(true).at_least_once - page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :published => false) - login_as('testinguser') - get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] - assert_response :success - end - should 'not show link to publication on view if not on person profile' do prof = Community.create!(:name => 'test comm', :identifier => 'test_comm') page = prof.articles.create!(:name => 'myarticle', :body => 'the body of the text') @@ -506,14 +476,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'a', :attributes => {:href => ('/myprofile/' + prof.identifier + '/cms/publish/' + page.id.to_s)} end - should 'deny access before trying SSL when SSL is disabled' do - @controller.expects(:redirect_to_ssl).returns(false) - profile = create_user('testuser', {}, :visible => false).person - - get :view_page, :profile => 'testuser', :page => profile.home_page.explode_path - assert_response 403 - end - should 'redirect to new article path under an old path' do p = create_user('test_user').person a = p.articles.create(:name => 'old-name') diff --git a/test/functional/edit_template_controller_test.rb b/test/functional/edit_template_controller_test.rb index 0ebf0b5..fb096f2 100644 --- a/test/functional/edit_template_controller_test.rb +++ b/test/functional/edit_template_controller_test.rb @@ -11,7 +11,6 @@ class EditTemplateControllerTest < Test::Unit::TestCase def setup @controller = EditTemplateController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as 'ze' end diff --git a/test/functional/enterprise_registration_controller_test.rb b/test/functional/enterprise_registration_controller_test.rb index e78eab9..e7fe298 100644 --- a/test/functional/enterprise_registration_controller_test.rb +++ b/test/functional/enterprise_registration_controller_test.rb @@ -11,7 +11,6 @@ all_fixtures def setup @controller = EnterpriseRegistrationController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as 'ze' end diff --git a/test/functional/enterprise_validation_controller_test.rb b/test/functional/enterprise_validation_controller_test.rb index c804bd5..66f64d8 100644 --- a/test/functional/enterprise_validation_controller_test.rb +++ b/test/functional/enterprise_validation_controller_test.rb @@ -11,7 +11,6 @@ class EnterpriseValidationControllerTest < Test::Unit::TestCase def setup @controller = EnterpriseValidationController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as 'ze' diff --git a/test/functional/favorite_enterprises_controller_test.rb b/test/functional/favorite_enterprises_controller_test.rb index 33482d6..2622e29 100644 --- a/test/functional/favorite_enterprises_controller_test.rb +++ b/test/functional/favorite_enterprises_controller_test.rb @@ -10,7 +10,6 @@ class FavoriteEnterprisesControllerTest < Test::Unit::TestCase def setup @controller = FavoriteEnterprisesController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new self.profile = create_user('testuser').person diff --git a/test/functional/features_controller_test.rb b/test/functional/features_controller_test.rb index 1ce4315..3d9c592 100644 --- a/test/functional/features_controller_test.rb +++ b/test/functional/features_controller_test.rb @@ -10,7 +10,6 @@ class FeaturesControllerTest < Test::Unit::TestCase def setup @controller = FeaturesController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as(create_admin_user(Environment.find(2))) end diff --git a/test/functional/friends_controller_test.rb b/test/functional/friends_controller_test.rb index 8195417..172b450 100644 --- a/test/functional/friends_controller_test.rb +++ b/test/functional/friends_controller_test.rb @@ -10,7 +10,6 @@ class FriendsControllerTest < Test::Unit::TestCase def setup @controller = FriendsController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new self.profile = create_user('testuser').person diff --git a/test/functional/mailconf_controller_test.rb b/test/functional/mailconf_controller_test.rb index 50b53c2..0e4d26c 100644 --- a/test/functional/mailconf_controller_test.rb +++ b/test/functional/mailconf_controller_test.rb @@ -7,7 +7,6 @@ class MailconfControllerTest < Test::Unit::TestCase def setup @controller = MailconfController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new MailConf.stubs(:enabled?).returns(true) diff --git a/test/functional/manage_products_controller_test.rb b/test/functional/manage_products_controller_test.rb index 614c618..5ce301b 100644 --- a/test/functional/manage_products_controller_test.rb +++ b/test/functional/manage_products_controller_test.rb @@ -9,7 +9,6 @@ class ManageProductsControllerTest < Test::Unit::TestCase def setup @controller = ManageProductsController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @enterprise = fast_create(Enterprise, :name => 'teste', :identifier => 'test_ent') @user = create_user_with_permission('test_user', 'manage_products', @enterprise) diff --git a/test/functional/memberships_controller_test.rb b/test/functional/memberships_controller_test.rb index 8f990c2..e9c4439 100644 --- a/test/functional/memberships_controller_test.rb +++ b/test/functional/memberships_controller_test.rb @@ -12,7 +12,6 @@ class MembershipsControllerTest < Test::Unit::TestCase def setup @controller = MembershipsController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @profile = create_user('testuser').person diff --git a/test/functional/my_profile_controller_test.rb b/test/functional/my_profile_controller_test.rb index eb4da9e..309db59 100644 --- a/test/functional/my_profile_controller_test.rb +++ b/test/functional/my_profile_controller_test.rb @@ -17,7 +17,6 @@ class MyProfileControllerTest < Test::Unit::TestCase def setup @controller = MyProfileController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new end diff --git a/test/functional/plugins_controller_test.rb b/test/functional/plugins_controller_test.rb index 40b3d62..1e1576b 100644 --- a/test/functional/plugins_controller_test.rb +++ b/test/functional/plugins_controller_test.rb @@ -10,7 +10,6 @@ class PluginsControllerTest < Test::Unit::TestCase def setup @controller = PluginsController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @environment = Environment.default login_as(create_admin_user(@environment)) diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index 1d607e3..9fae6d6 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -17,7 +17,6 @@ class ProfileDesignControllerTest < Test::Unit::TestCase def setup @controller = ProfileDesignController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @profile = @holder = create_user('designtestuser').person diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 9cbfdf1..e329d12 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -10,7 +10,6 @@ class ProfileEditorControllerTest < Test::Unit::TestCase def setup @controller = ProfileEditorController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @profile = create_user('default_user').person Environment.default.affiliate(@profile, [Environment::Roles.admin(Environment.default.id)] + Profile::Roles.all_roles(Environment.default.id)) diff --git a/test/functional/profile_members_controller_test.rb b/test/functional/profile_members_controller_test.rb index dc85aae..d8a164f 100644 --- a/test/functional/profile_members_controller_test.rb +++ b/test/functional/profile_members_controller_test.rb @@ -8,7 +8,6 @@ class ProfileMembersControllerTest < Test::Unit::TestCase def setup @controller = ProfileMembersController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new end diff --git a/test/functional/public_controller_test.rb b/test/functional/public_controller_test.rb index 0c41fc5..9f53172 100644 --- a/test/functional/public_controller_test.rb +++ b/test/functional/public_controller_test.rb @@ -6,23 +6,8 @@ class PublicController; def rescue_action(e) raise e end; end class PublicControllerTest < Test::Unit::TestCase - class TestingPublicStuffController < PublicController - def index - render :text => 'test', :layout => false - end - end - - def setup - @controller = TestingPublicStuffController.new - @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) - @response = ActionController::TestResponse.new - end - - # Replace this with your real tests. - should 'refuse SSL' do - get :index - assert_redirected_to :protocol => 'http://' + should 'inherit from ApplicationController' do + assert_kind_of ApplicationController, PublicController.new end end diff --git a/test/functional/region_validators_controller_test.rb b/test/functional/region_validators_controller_test.rb index 6df044b..66e0db5 100644 --- a/test/functional/region_validators_controller_test.rb +++ b/test/functional/region_validators_controller_test.rb @@ -9,7 +9,6 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase def setup @controller = RegionValidatorsController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as('ze') end diff --git a/test/functional/role_controller_test.rb b/test/functional/role_controller_test.rb index 9ab2fcd..2452b10 100644 --- a/test/functional/role_controller_test.rb +++ b/test/functional/role_controller_test.rb @@ -10,7 +10,6 @@ class RoleControllerTest < Test::Unit::TestCase def setup @controller = RoleController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @role = Role.find(:first) login_as(:ze) diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 6e882dd..290ca0e 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -10,7 +10,6 @@ class TasksControllerTest < Test::Unit::TestCase def setup @controller = TasksController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new self.profile = create_user('testuser').person diff --git a/test/functional/themes_controller_test.rb b/test/functional/themes_controller_test.rb index 6615e0e..f951cf7 100644 --- a/test/functional/themes_controller_test.rb +++ b/test/functional/themes_controller_test.rb @@ -8,7 +8,6 @@ class ThemesControllerTest < Test::Unit::TestCase def setup @controller = ThemesController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 1680e18..d58e501 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -10,7 +10,6 @@ class UsersControllerTest < Test::Unit::TestCase def setup @controller = UsersController.new @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new end diff --git a/test/integration/login_to_the_application_test.rb b/test/integration/login_to_the_application_test.rb index 3685b9c..86d5cf9 100644 --- a/test/integration/login_to_the_application_test.rb +++ b/test/integration/login_to_the_application_test.rb @@ -4,8 +4,6 @@ class LoginToTheApplicationTest < ActionController::IntegrationTest fixtures :users, :environments, :profiles def test_unauthenticated_user_tries_to_access_his_control_panel - Environment.any_instance.stubs(:enable_ssl).returns(false) # ignore SSL for this test - get '/myprofile/ze' assert_redirected_to '/account/login' diff --git a/test/mocks/test/test_controller.rb b/test/mocks/test/test_controller.rb index 79fcd42..d83dbfb 100644 --- a/test/mocks/test/test_controller.rb +++ b/test/mocks/test/test_controller.rb @@ -39,20 +39,4 @@ class TestController < ApplicationController ' end - require_ssl :only => 'sslonly' - def sslonly - render :text => 'this should be seen only on SSL', :layout => false - end - def doesnt_need_ssl - render :text => 'this should be seen even without SSL', :layout => false - end - - refuse_ssl :only => 'nossl' - def nossl - render :text => 'this should not be seen over SSL', :layout => false - end - def doesnt_refuse_ssl - render :text => 'this should be seen over SSL or not, whatever', :layout => false - end - end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 0c1c052..5434809 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -199,30 +199,6 @@ class ApplicationHelperTest < ActiveSupport::TestCase assert_equal '/designs/templates/mytemplate/stylesheets/style.css', template_stylesheet_path end - should 'use https:// for login_url' do - environment = Environment.default - environment.update_attribute(:enable_ssl, true) - environment.domains << Domain.new(:name => "test.domain.net", :is_default => true) - stubs(:environment).returns(environment) - - stubs(:url_for).with(has_entries(:protocol => 'https://', :host => 'test.domain.net')).returns('LALALA') - - assert_equal 'LALALA', login_url - end - - should 'not force ssl in login_url when environment has ssl disabled' do - environment = mock - environment.expects(:enable_ssl).returns(false).at_least_once - stubs(:environment).returns(environment) - request = mock - request.stubs(:host).returns('localhost') - stubs(:request).returns(request) - - expects(:url_for).with(has_entries(:protocol => 'https://')).never - expects(:url_for).with(has_key(:controller)).returns("LALALA") - assert_equal "LALALA", login_url - end - should 'return nil if disable_categories is enabled' do env = fast_create(Environment, :name => 'env test') stubs(:environment).returns(env) diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index 594c9ba..56b3f47 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -241,12 +241,6 @@ class EnvironmentTest < ActiveSupport::TestCase assert_equal 'http://www.lalala.net:9999', env.top_url end - should 'use https when asked for a ssl url' do - env = Environment.new - env.expects(:default_hostname).returns('www.lalala.net') - assert_equal 'https://www.lalala.net', env.top_url(true) - end - should 'provide an approval_method setting' do env = Environment.new @@ -532,16 +526,6 @@ class EnvironmentTest < ActiveSupport::TestCase assert_equal enterprise, e.enterprise_template end - should 'not enable ssl by default' do - e = Environment.new - assert !e.enable_ssl - end - - should 'be able to enable ssl' do - e = Environment.new(:enable_ssl => true) - assert_equal true, e.enable_ssl - end - should 'have a layout template' do e = Environment.new(:layout_template => 'mytemplate') assert_equal 'mytemplate', e.layout_template -- libgit2 0.21.2