[Git][noosfero/noosfero][master] 2 commits: Change remote user plugin to handle any exception

Rodrigo Souto gitlab at gitlab.com
Thu Jun 25 19:03:38 BRT 2015


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
9e89e39e by Arthur Del Esposte at 2015-06-25T18:06:08Z
Change remote user plugin to handle any exception

- - - - -
a4b7f957 by Rodrigo Souto at 2015-06-25T22:03:29Z
Merge branch 'remote_user_fix' into 'master'

Change remote user plugin to handle any exception

Small fix to handle any possiblie exception in remote user plugin

See merge request !612

- - - - -


2 changed files:

- plugins/remote_user/lib/remote_user_plugin.rb
- plugins/remote_user/test/functional/remote_user_plugin_test.rb


Changes:

=====================================
plugins/remote_user/lib/remote_user_plugin.rb
=====================================
--- a/plugins/remote_user/lib/remote_user_plugin.rb
+++ b/plugins/remote_user/lib/remote_user_plugin.rb
@@ -48,7 +48,7 @@ class RemoteUserPlugin < Noosfero::Plugin
             end
           end
         end
-      rescue ActiveRecord::RecordInvalid => invalid
+      rescue
         session[:notice] = _('Could not create the remote_user.')
         render_404
       end


=====================================
plugins/remote_user/test/functional/remote_user_plugin_test.rb
=====================================
--- a/plugins/remote_user/test/functional/remote_user_plugin_test.rb
+++ b/plugins/remote_user/test/functional/remote_user_plugin_test.rb
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper'
 # Re-raise errors caught by the controller.
 class AccountController; def rescue_action(e) raise e end; end
 
-class AccountControllerTest < ActionController::TestCase 
+class AccountControllerTest < ActionController::TestCase
   def setup
     @environment = Environment.default
     @environment.enabled_plugins = ['RemoteUserPlugin']
@@ -125,10 +125,18 @@ class AccountControllerTest < ActionController::TestCase
     get :index
 
     assert session[:user].blank?
-    
+
     @request.env["HTTP_REMOTE_USER"] = ""
     get :index
 
     assert session[:user].blank?
   end
+
+  should 'not create a new user if his informations is invalid' do
+    @request.env["HTTP_REMOTE_USER"] = "*%&invalid user name&%*"
+    get :index
+
+    assert session[:user].blank?
+    assert_response 404
+  end
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/a499eda4f237c15acf4fecb29e5e7555f512d17c...a4b7f957fd55174083fc29dbec2fbf10df8ee507
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150625/94d46e17/attachment.html>


More information about the Noosfero-dev mailing list