Commit b1d5a85fb5f7ef547cce0ef6a826884e2b9c2bfb
1 parent
b7823262
Exists in
master
and in
29 other branches
stoa-plugin: not test ssl connection on Noosfero
Our default ssl setup uses a reverse proxy (pound) that treats https connection and passes clean http connections to Noosfero. That way, even using https connections Noosfero will only see http connections. So we can't test if the connection is ssl inside Noosfero.
Showing
2 changed files
with
2 additions
and
21 deletions
Show diff stats
plugins/stoa/controllers/stoa_plugin_controller.rb
@@ -6,7 +6,7 @@ class StoaPluginController < PublicController | @@ -6,7 +6,7 @@ class StoaPluginController < PublicController | ||
6 | include StoaPlugin::PersonFields | 6 | include StoaPlugin::PersonFields |
7 | 7 | ||
8 | def authenticate | 8 | def authenticate |
9 | - if request.ssl? && request.post? | 9 | + if request.post? |
10 | if params[:login].blank? | 10 | if params[:login].blank? |
11 | person = Person.find_by_usp_id(params[:usp_id]) | 11 | person = Person.find_by_usp_id(params[:usp_id]) |
12 | login = person ? person.user.login : nil | 12 | login = person ? person.user.login : nil |
@@ -22,7 +22,7 @@ class StoaPluginController < PublicController | @@ -22,7 +22,7 @@ class StoaPluginController < PublicController | ||
22 | end | 22 | end |
23 | render :text => result.to_json | 23 | render :text => result.to_json |
24 | else | 24 | else |
25 | - render :text => { :error => _('Conection requires SSL certificate and post method.'), :ok => false }.to_json | 25 | + render :text => { :error => _('Conection requires post method.'), :ok => false }.to_json |
26 | end | 26 | end |
27 | end | 27 | end |
28 | 28 |
plugins/stoa/test/functional/stoa_plugin_controller_test.rb
@@ -24,23 +24,13 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -24,23 +24,13 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
24 | attr_accessor :user | 24 | attr_accessor :user |
25 | 25 | ||
26 | should 'not authenticate if method not post' do | 26 | should 'not authenticate if method not post' do |
27 | - @request.stubs(:ssl?).returns(true) | ||
28 | get :authenticate, :login => user.login, :password => '123456' | 27 | get :authenticate, :login => user.login, :password => '123456' |
29 | 28 | ||
30 | assert_not_nil json_response['error'] | 29 | assert_not_nil json_response['error'] |
31 | assert_match /post method/,json_response['error'] | 30 | assert_match /post method/,json_response['error'] |
32 | end | 31 | end |
33 | 32 | ||
34 | - should 'not authenticate if request is not using ssl' do | ||
35 | - @request.stubs(:ssl?).returns(false) | ||
36 | - post :authenticate, :login => user.login, :password => '123456' | ||
37 | - | ||
38 | - assert_not_nil json_response['error'] | ||
39 | - assert_match /SSL/,json_response['error'] | ||
40 | - end | ||
41 | - | ||
42 | should 'not authenticate if method password is wrong' do | 33 | should 'not authenticate if method password is wrong' do |
43 | - @request.stubs(:ssl?).returns(true) | ||
44 | post :authenticate, :login => user.login, :password => 'wrong_password' | 34 | post :authenticate, :login => user.login, :password => 'wrong_password' |
45 | 35 | ||
46 | assert_not_nil json_response['error'] | 36 | assert_not_nil json_response['error'] |
@@ -48,7 +38,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -48,7 +38,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
48 | end | 38 | end |
49 | 39 | ||
50 | should 'authenticate if everything is right' do | 40 | should 'authenticate if everything is right' do |
51 | - @request.stubs(:ssl?).returns(true) | ||
52 | post :authenticate, :login => user.login, :password => '123456' | 41 | post :authenticate, :login => user.login, :password => '123456' |
53 | 42 | ||
54 | assert_nil json_response['error'] | 43 | assert_nil json_response['error'] |
@@ -56,7 +45,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -56,7 +45,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
56 | end | 45 | end |
57 | 46 | ||
58 | should 'authenticate with usp_id' do | 47 | should 'authenticate with usp_id' do |
59 | - @request.stubs(:ssl?).returns(true) | ||
60 | post :authenticate, :usp_id => user.person.usp_id.to_s, :password => '123456' | 48 | post :authenticate, :usp_id => user.person.usp_id.to_s, :password => '123456' |
61 | 49 | ||
62 | assert_nil json_response['error'] | 50 | assert_nil json_response['error'] |
@@ -64,7 +52,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -64,7 +52,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
64 | end | 52 | end |
65 | 53 | ||
66 | should 'return no fields if fields requested was none' do | 54 | should 'return no fields if fields requested was none' do |
67 | - @request.stubs(:ssl?).returns(true) | ||
68 | post :authenticate, :login => user.login, :password => '123456', :fields => 'none' | 55 | post :authenticate, :login => user.login, :password => '123456', :fields => 'none' |
69 | 56 | ||
70 | expected_response = {'ok' => true} | 57 | expected_response = {'ok' => true} |
@@ -74,7 +61,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -74,7 +61,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
74 | end | 61 | end |
75 | 62 | ||
76 | should 'return only the essential fields if no fields requested' do | 63 | should 'return only the essential fields if no fields requested' do |
77 | - @request.stubs(:ssl?).returns(true) | ||
78 | post :authenticate, :login => user.login, :password => '123456' | 64 | post :authenticate, :login => user.login, :password => '123456' |
79 | response = json_response.clone | 65 | response = json_response.clone |
80 | 66 | ||
@@ -87,7 +73,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -87,7 +73,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
87 | end | 73 | end |
88 | 74 | ||
89 | should 'return only selected fields' do | 75 | should 'return only selected fields' do |
90 | - @request.stubs(:ssl?).returns(true) | ||
91 | Person.any_instance.stubs(:f1).returns('field1') | 76 | Person.any_instance.stubs(:f1).returns('field1') |
92 | Person.any_instance.stubs(:f2).returns('field2') | 77 | Person.any_instance.stubs(:f2).returns('field2') |
93 | Person.any_instance.stubs(:f3).returns('field3') | 78 | Person.any_instance.stubs(:f3).returns('field3') |
@@ -104,7 +89,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -104,7 +89,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
104 | end | 89 | end |
105 | 90 | ||
106 | should 'not return private fields' do | 91 | should 'not return private fields' do |
107 | - @request.stubs(:ssl?).returns(true) | ||
108 | Person.any_instance.stubs(:f1).returns('field1') | 92 | Person.any_instance.stubs(:f1).returns('field1') |
109 | Person.any_instance.stubs(:f2).returns('field2') | 93 | Person.any_instance.stubs(:f2).returns('field2') |
110 | Person.any_instance.stubs(:f3).returns('field3') | 94 | Person.any_instance.stubs(:f3).returns('field3') |
@@ -121,7 +105,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -121,7 +105,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
121 | end | 105 | end |
122 | 106 | ||
123 | should 'return essential fields even if they are private' do | 107 | should 'return essential fields even if they are private' do |
124 | - @request.stubs(:ssl?).returns(true) | ||
125 | person = user.person | 108 | person = user.person |
126 | person.fields_privacy = {:email => 'private'} | 109 | person.fields_privacy = {:email => 'private'} |
127 | person.save! | 110 | person.save! |
@@ -132,7 +115,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -132,7 +115,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
132 | end | 115 | end |
133 | 116 | ||
134 | should 'return only essential fields when profile is private' do | 117 | should 'return only essential fields when profile is private' do |
135 | - @request.stubs(:ssl?).returns(true) | ||
136 | Person.any_instance.stubs(:f1).returns('field1') | 118 | Person.any_instance.stubs(:f1).returns('field1') |
137 | Person.any_instance.stubs(:f2).returns('field2') | 119 | Person.any_instance.stubs(:f2).returns('field2') |
138 | Person.any_instance.stubs(:f3).returns('field3') | 120 | Person.any_instance.stubs(:f3).returns('field3') |
@@ -153,7 +135,6 @@ class StoaPluginControllerTest < ActionController::TestCase | @@ -153,7 +135,6 @@ class StoaPluginControllerTest < ActionController::TestCase | ||
153 | end | 135 | end |
154 | 136 | ||
155 | should 'not crash if usp_id is invalid' do | 137 | should 'not crash if usp_id is invalid' do |
156 | - @request.stubs(:ssl?).returns(true) | ||
157 | assert_nothing_raised do | 138 | assert_nothing_raised do |
158 | post :authenticate, :usp_id => 12321123, :password => '123456' | 139 | post :authenticate, :usp_id => 12321123, :password => '123456' |
159 | end | 140 | end |