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 | 6 | include StoaPlugin::PersonFields |
7 | 7 | |
8 | 8 | def authenticate |
9 | - if request.ssl? && request.post? | |
9 | + if request.post? | |
10 | 10 | if params[:login].blank? |
11 | 11 | person = Person.find_by_usp_id(params[:usp_id]) |
12 | 12 | login = person ? person.user.login : nil |
... | ... | @@ -22,7 +22,7 @@ class StoaPluginController < PublicController |
22 | 22 | end |
23 | 23 | render :text => result.to_json |
24 | 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 | 26 | end |
27 | 27 | end |
28 | 28 | ... | ... |
plugins/stoa/test/functional/stoa_plugin_controller_test.rb
... | ... | @@ -24,23 +24,13 @@ class StoaPluginControllerTest < ActionController::TestCase |
24 | 24 | attr_accessor :user |
25 | 25 | |
26 | 26 | should 'not authenticate if method not post' do |
27 | - @request.stubs(:ssl?).returns(true) | |
28 | 27 | get :authenticate, :login => user.login, :password => '123456' |
29 | 28 | |
30 | 29 | assert_not_nil json_response['error'] |
31 | 30 | assert_match /post method/,json_response['error'] |
32 | 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 | 33 | should 'not authenticate if method password is wrong' do |
43 | - @request.stubs(:ssl?).returns(true) | |
44 | 34 | post :authenticate, :login => user.login, :password => 'wrong_password' |
45 | 35 | |
46 | 36 | assert_not_nil json_response['error'] |
... | ... | @@ -48,7 +38,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
48 | 38 | end |
49 | 39 | |
50 | 40 | should 'authenticate if everything is right' do |
51 | - @request.stubs(:ssl?).returns(true) | |
52 | 41 | post :authenticate, :login => user.login, :password => '123456' |
53 | 42 | |
54 | 43 | assert_nil json_response['error'] |
... | ... | @@ -56,7 +45,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
56 | 45 | end |
57 | 46 | |
58 | 47 | should 'authenticate with usp_id' do |
59 | - @request.stubs(:ssl?).returns(true) | |
60 | 48 | post :authenticate, :usp_id => user.person.usp_id.to_s, :password => '123456' |
61 | 49 | |
62 | 50 | assert_nil json_response['error'] |
... | ... | @@ -64,7 +52,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
64 | 52 | end |
65 | 53 | |
66 | 54 | should 'return no fields if fields requested was none' do |
67 | - @request.stubs(:ssl?).returns(true) | |
68 | 55 | post :authenticate, :login => user.login, :password => '123456', :fields => 'none' |
69 | 56 | |
70 | 57 | expected_response = {'ok' => true} |
... | ... | @@ -74,7 +61,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
74 | 61 | end |
75 | 62 | |
76 | 63 | should 'return only the essential fields if no fields requested' do |
77 | - @request.stubs(:ssl?).returns(true) | |
78 | 64 | post :authenticate, :login => user.login, :password => '123456' |
79 | 65 | response = json_response.clone |
80 | 66 | |
... | ... | @@ -87,7 +73,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
87 | 73 | end |
88 | 74 | |
89 | 75 | should 'return only selected fields' do |
90 | - @request.stubs(:ssl?).returns(true) | |
91 | 76 | Person.any_instance.stubs(:f1).returns('field1') |
92 | 77 | Person.any_instance.stubs(:f2).returns('field2') |
93 | 78 | Person.any_instance.stubs(:f3).returns('field3') |
... | ... | @@ -104,7 +89,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
104 | 89 | end |
105 | 90 | |
106 | 91 | should 'not return private fields' do |
107 | - @request.stubs(:ssl?).returns(true) | |
108 | 92 | Person.any_instance.stubs(:f1).returns('field1') |
109 | 93 | Person.any_instance.stubs(:f2).returns('field2') |
110 | 94 | Person.any_instance.stubs(:f3).returns('field3') |
... | ... | @@ -121,7 +105,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
121 | 105 | end |
122 | 106 | |
123 | 107 | should 'return essential fields even if they are private' do |
124 | - @request.stubs(:ssl?).returns(true) | |
125 | 108 | person = user.person |
126 | 109 | person.fields_privacy = {:email => 'private'} |
127 | 110 | person.save! |
... | ... | @@ -132,7 +115,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
132 | 115 | end |
133 | 116 | |
134 | 117 | should 'return only essential fields when profile is private' do |
135 | - @request.stubs(:ssl?).returns(true) | |
136 | 118 | Person.any_instance.stubs(:f1).returns('field1') |
137 | 119 | Person.any_instance.stubs(:f2).returns('field2') |
138 | 120 | Person.any_instance.stubs(:f3).returns('field3') |
... | ... | @@ -153,7 +135,6 @@ class StoaPluginControllerTest < ActionController::TestCase |
153 | 135 | end |
154 | 136 | |
155 | 137 | should 'not crash if usp_id is invalid' do |
156 | - @request.stubs(:ssl?).returns(true) | |
157 | 138 | assert_nothing_raised do |
158 | 139 | post :authenticate, :usp_id => 12321123, :password => '123456' |
159 | 140 | end | ... | ... |