From a9a9fa1fbf971f19329a42f2520c70e919e8b903 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 23 Apr 2013 12:00:40 -0300 Subject: [PATCH] Removing trailing whitespaces from ldap plugin --- plugins/ldap/lib/ext/environment.rb | 32 ++++++++++++++++---------------- plugins/ldap/lib/ldap_plugin.rb | 10 +++++----- plugins/ldap/test/functional/account_controller_plugin_test.rb | 10 +++++----- plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb | 2 +- plugins/ldap/test/test_helper.rb | 4 ++-- plugins/ldap/test/unit/ext/environment_test.rb | 2 +- plugins/ldap/test/unit/ldap_authentication_test.rb | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/plugins/ldap/lib/ext/environment.rb b/plugins/ldap/lib/ext/environment.rb index 7ebf778..5d02849 100644 --- a/plugins/ldap/lib/ext/environment.rb +++ b/plugins/ldap/lib/ext/environment.rb @@ -18,7 +18,7 @@ class Environment def ldap_plugin_host self.ldap_plugin['host'] end - + def ldap_plugin_port= port self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['port'] = port @@ -29,7 +29,7 @@ class Environment self.ldap_plugin['port'] ||= 389 self.ldap_plugin['port'] end - + def ldap_plugin_account self.ldap_plugin['account'] end @@ -38,7 +38,7 @@ class Environment self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['account'] = account end - + def ldap_plugin_account_password self.ldap_plugin['account_password'] end @@ -47,16 +47,16 @@ class Environment self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['account_password'] = password end - + def ldap_plugin_base_dn self.ldap_plugin['base_dn'] end - + def ldap_plugin_base_dn= base_dn self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['base_dn'] = base_dn end - + def ldap_plugin_attr_login self.ldap_plugin['attr_login'] end @@ -65,47 +65,47 @@ class Environment self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['attr_login'] = login end - + def ldap_plugin_attr_fullname self.ldap_plugin['attr_fullname'] end - + def ldap_plugin_attr_fullname= fullname self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['attr_fullname'] = fullname end - + def ldap_plugin_attr_mail self.ldap_plugin['attr_mail'] end - + def ldap_plugin_attr_mail= mail self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['attr_mail'] = mail end - + def ldap_plugin_onthefly_register self.ldap_plugin['onthefly_register'].to_s == 'true' end - + def ldap_plugin_onthefly_register= value self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['onthefly_register'] = (value.to_s == '1') ? true : false end - + def ldap_plugin_filter self.ldap_plugin['filter'] end - + def ldap_plugin_filter= filter self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['filter'] = filter end - + def ldap_plugin_tls self.ldap_plugin['tls'] ||= false end - + def ldap_plugin_tls= value self.ldap_plugin = {} if self.ldap_plugin.blank? self.ldap_plugin['tls'] = (value.to_s == '1') ? true : false diff --git a/plugins/ldap/lib/ldap_plugin.rb b/plugins/ldap/lib/ldap_plugin.rb index 3a2618c..25182fe 100644 --- a/plugins/ldap/lib/ldap_plugin.rb +++ b/plugins/ldap/lib/ldap_plugin.rb @@ -34,7 +34,7 @@ class LdapPlugin < Noosfero::Plugin rescue Net::LDAP::LdapError => e puts "LDAP is not configured correctly" end - + if attrs user.login = login user.email = attrs[:mail] @@ -54,19 +54,19 @@ class LdapPlugin < Noosfero::Plugin else user = nil end - + else return nil if !user.activated? begin - # user si defined as nil if ldap authentication failed + # user is defined as nil if ldap authentication failed user = nil if ldap.authenticate(login, password).nil? rescue Net::LDAP::LdapError => e user = nil puts "LDAP is not configured correctly" end - end + end user end @@ -77,7 +77,7 @@ class LdapPlugin < Noosfero::Plugin @profile_data = @person labelled_fields_for :profile_data, @person do |f| render :partial => 'profile_editor/person_form', :locals => {:f => f} - end + end end end diff --git a/plugins/ldap/test/functional/account_controller_plugin_test.rb b/plugins/ldap/test/functional/account_controller_plugin_test.rb index ada70f1..412c695 100644 --- a/plugins/ldap/test/functional/account_controller_plugin_test.rb +++ b/plugins/ldap/test/functional/account_controller_plugin_test.rb @@ -9,7 +9,7 @@ class AccountControllerPluginTest < ActionController::TestCase @controller = AccountController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - + @environment = Environment.default @environment.enabled_plugins = ['LdapPlugin'] @ldap_config = load_ldap_config @@ -51,14 +51,14 @@ class AccountControllerPluginTest < ActionController::TestCase assert session[:user] assert_equal count, User.count end - + should 'login and create a new noosfero user if ldap authentication works properly' do count = User.count post :login, :user => @ldap_config['user'] assert session[:user] assert_equal count + 1, User.count end - + should 'login on ldap if required fields are defined' do count = User.count @environment.custom_person_fields = {"contact_phone"=>{"required"=>"true", "signup"=>"false", "active"=>"true"}} @@ -66,14 +66,14 @@ class AccountControllerPluginTest < ActionController::TestCase post :login, :user => @ldap_config['user'], :profile_data => {:contact_phone => '11111111'} assert session[:user] end - + should 'not login on ldap if required fields are not defined' do @environment.custom_person_fields = {"contact_phone"=>{"required"=>"true", "signup"=>"false", "active"=>"true"}} @environment.save post :login, :user => @ldap_config['user'] assert_nil session[:user] end - + should 'authenticate user if its not a local user but is a ldap user' do post :login, :user => @ldap_config['user'] assert session[:user] diff --git a/plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb b/plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb index 2c7a8be..392880f 100644 --- a/plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb +++ b/plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb @@ -10,7 +10,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase @controller = LdapPluginAdminController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - + @environment = Environment.default user_login = create_admin_user(@environment) login_as(user_login) diff --git a/plugins/ldap/test/test_helper.rb b/plugins/ldap/test/test_helper.rb index e82ee99..9686bae 100644 --- a/plugins/ldap/test/test_helper.rb +++ b/plugins/ldap/test/test_helper.rb @@ -1,12 +1,12 @@ require File.dirname(__FILE__) + '/../../../test/test_helper' -def load_ldap_config +def load_ldap_config begin YAML.load_file(File.dirname(__FILE__) + '/../fixtures/ldap.yml') rescue Errno::ENOENT => e # There is no config file return nil - end + end end def ldap_configured? diff --git a/plugins/ldap/test/unit/ext/environment_test.rb b/plugins/ldap/test/unit/ext/environment_test.rb index 79bd713..482f8c7 100644 --- a/plugins/ldap/test/unit/ext/environment_test.rb +++ b/plugins/ldap/test/unit/ext/environment_test.rb @@ -166,7 +166,7 @@ class EnvironmentTest < ActiveSupport::TestCase should 'validates presence of host' do @enviroment.ldap_plugin= {:port => 3000} @enviroment.valid? - + assert @enviroment.errors.invalid?(:ldap_plugin_host) @enviroment.ldap_plugin_host= "http://somehost.com" diff --git a/plugins/ldap/test/unit/ldap_authentication_test.rb b/plugins/ldap/test/unit/ldap_authentication_test.rb index 41d575f..a94852b 100644 --- a/plugins/ldap/test/unit/ldap_authentication_test.rb +++ b/plugins/ldap/test/unit/ldap_authentication_test.rb @@ -175,6 +175,6 @@ class LdapAuthenticationTest < ActiveSupport::TestCase else puts LDAP_SERVER_ERROR_MESSAGE end - + end -- libgit2 0.21.2