diff --git a/plugins/ldap/Gemfile b/plugins/ldap/Gemfile new file mode 100644 index 0000000..727297d --- /dev/null +++ b/plugins/ldap/Gemfile @@ -0,0 +1 @@ +gem "net-ldap" diff --git a/plugins/ldap/lib/ext/environment.rb b/plugins/ldap/lib/ext/environment.rb index 5d02849..4651b8a 100644 --- a/plugins/ldap/lib/ext/environment.rb +++ b/plugins/ldap/lib/ext/environment.rb @@ -6,6 +6,8 @@ class Environment validates_presence_of :ldap_plugin_host, :if => lambda {|env| !env.ldap_plugin.blank? } + attr_accessible :ldap_plugin_host, :ldap_plugin_port, :ldap_plugin_tls, :ldap_plugin_onthefly_register, :ldap_plugin_account, :ldap_plugin_account_password, :ldap_plugin_filter, :ldap_plugin_base_dn, :ldap_plugin_attr_mail, :ldap_plugin_attr_login, :ldap_plugin_attr_fullname + def ldap_plugin_attributes self.ldap_plugin || {} end diff --git a/plugins/ldap/lib/ldap_plugin.rb b/plugins/ldap/lib/ldap_plugin.rb index b6d68be..4653e65 100644 --- a/plugins/ldap/lib/ldap_plugin.rb +++ b/plugins/ldap/lib/ldap_plugin.rb @@ -70,7 +70,7 @@ class LdapPlugin < Noosfero::Plugin end def login_extra_contents - lambda do + proc do @person = Person.new(:environment => @environment) @profile_data = @person labelled_fields_for :profile_data, @person do |f| 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 392880f..3279654 100644 --- a/plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb +++ b/plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb @@ -7,10 +7,6 @@ class LdapPluginAdminController; def rescue_action(e) raise e end; end class LdapPluginAdminControllerTest < ActionController::TestCase def setup - @controller = LdapPluginAdminController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @environment = Environment.default user_login = create_admin_user(@environment) login_as(user_login) @@ -33,7 +29,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase @environment.save assert_nil @environment.ldap_plugin_host post :update, :environment => { :ldap_plugin_host => 'http://something' } - assert_equal 'Ldap configuration updated successfully.', @response.session[:notice] + assert_equal 'Ldap configuration updated successfully.', @request.session[:notice] end should 'wrong ldap update display a message unsuccessfully' do @@ -41,7 +37,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase @environment.save assert_nil @environment.ldap_plugin_host post :update, :environment => { :ldap_plugin_host => '' } - assert_equal 'Ldap configuration could not be saved.', @response.session[:notice] + assert_equal 'Ldap configuration could not be saved.', @request.session[:notice] end should 'update ldap successfully render index template' do diff --git a/plugins/ldap/test/unit/ext/environment_test.rb b/plugins/ldap/test/unit/ext/environment_test.rb index 482f8c7..858b5f6 100644 --- a/plugins/ldap/test/unit/ext/environment_test.rb +++ b/plugins/ldap/test/unit/ext/environment_test.rb @@ -167,20 +167,20 @@ class EnvironmentTest < ActiveSupport::TestCase @enviroment.ldap_plugin= {:port => 3000} @enviroment.valid? - assert @enviroment.errors.invalid?(:ldap_plugin_host) + assert @enviroment.errors.include?(:ldap_plugin_host) @enviroment.ldap_plugin_host= "http://somehost.com" @enviroment.valid? - assert !@enviroment.errors.invalid?(:ldap_plugin_host) + assert !@enviroment.errors.include?(:ldap_plugin_host) end should 'validates presence of host only if some ldap configuration is defined' do @enviroment.valid? - assert !@enviroment.errors.invalid?(:ldap_plugin_host) + assert !@enviroment.errors.include?(:ldap_plugin_host) @enviroment.ldap_plugin= {:port => 3000} @enviroment.valid? - assert @enviroment.errors.invalid?(:ldap_plugin_host) + assert @enviroment.errors.include?(:ldap_plugin_host) end end diff --git a/plugins/ldap/views/ldap_plugin_admin/index.html.erb b/plugins/ldap/views/ldap_plugin_admin/index.html.erb index 5256e21..243c4f7 100644 --- a/plugins/ldap/views/ldap_plugin_admin/index.html.erb +++ b/plugins/ldap/views/ldap_plugin_admin/index.html.erb @@ -1,6 +1,6 @@