oauth-plugin 0.4.0.rc2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/README.rdoc +1 -1
- data/UPGRADE.rdoc +1 -1
- data/generators/oauth_consumer/oauth_consumer_generator.rb +9 -9
- data/generators/oauth_consumer/templates/consumer_token.rb +3 -3
- data/generators/oauth_consumer/templates/controller.rb +5 -5
- data/generators/oauth_consumer/templates/migration.rb +3 -3
- data/generators/oauth_consumer/templates/oauth_config.rb +3 -3
- data/generators/oauth_consumer/templates/show.html.haml +1 -1
- data/generators/oauth_provider/USAGE +1 -1
- data/generators/oauth_provider/lib/insert_routes.rb +8 -8
- data/generators/oauth_provider/oauth_provider_generator.rb +10 -10
- data/generators/oauth_provider/templates/_form.html.haml +4 -4
- data/generators/oauth_provider/templates/access_token.rb +4 -4
- data/generators/oauth_provider/templates/client_application.rb +8 -8
- data/generators/oauth_provider/templates/client_application_spec.rb +5 -5
- data/generators/oauth_provider/templates/client_application_test.rb +7 -7
- data/generators/oauth_provider/templates/clients_controller.rb +4 -4
- data/generators/oauth_provider/templates/clients_controller_spec.rb +30 -30
- data/generators/oauth_provider/templates/clients_controller_test.rb +54 -54
- data/generators/oauth_provider/templates/controller.rb +3 -3
- data/generators/oauth_provider/templates/index.html.erb +2 -2
- data/generators/oauth_provider/templates/index.html.haml +2 -2
- data/generators/oauth_provider/templates/migration.rb +5 -5
- data/generators/oauth_provider/templates/oauth2_authorize.html.erb +1 -1
- data/generators/oauth_provider/templates/oauth_nonce.rb +1 -1
- data/generators/oauth_provider/templates/oauth_nonce_spec.rb +3 -3
- data/generators/oauth_provider/templates/oauth_nonce_test.rb +4 -4
- data/generators/oauth_provider/templates/oauth_token.rb +6 -6
- data/generators/oauth_provider/templates/oauth_token_spec.rb +38 -38
- data/generators/oauth_provider/templates/oauth_token_test.rb +10 -10
- data/generators/oauth_provider/templates/request_token.rb +7 -7
- data/generators/oauth_provider/templates/show.html.haml +3 -3
- data/init.rb +1 -1
- data/lib/generators/active_record/oauth_consumer_templates/consumer_token.rb +3 -3
- data/lib/generators/active_record/oauth_consumer_templates/migration.rb +3 -3
- data/lib/generators/active_record/oauth_provider_templates/migration.rb +1 -1
- data/lib/generators/active_record/oauth_provider_templates/request_token.rb +1 -1
- data/lib/generators/haml/oauth_consumer_templates/show.html.haml +1 -1
- data/lib/generators/mongoid/oauth_consumer_templates/consumer_token.rb +6 -6
- data/lib/generators/mongoid/oauth_provider_templates/oauth_token.rb +1 -1
- data/lib/generators/mongoid/oauth_provider_templates/request_token.rb +1 -1
- data/lib/generators/oauth_consumer/oauth_consumer_generator.rb +6 -6
- data/lib/generators/oauth_consumer/templates/controller.rb +10 -10
- data/lib/generators/oauth_consumer/templates/oauth_config.rb +3 -3
- data/lib/oauth-plugin.rb +7 -5
- data/lib/oauth-plugin/version.rb +1 -1
- data/lib/oauth/controllers/application_controller_methods.rb +19 -19
- data/lib/oauth/controllers/consumer_controller.rb +25 -15
- data/lib/oauth/models/consumers/service_loader.rb +1 -1
- data/lib/oauth/models/consumers/services/agree2_token.rb +2 -2
- data/lib/oauth/models/consumers/services/fireeagle_token.rb +7 -7
- data/lib/oauth/models/consumers/services/oauth2_token.rb +9 -9
- data/lib/oauth/models/consumers/services/opentransact_token.rb +4 -4
- data/lib/oauth/models/consumers/services/picomoney_token.rb +2 -2
- data/lib/oauth/models/consumers/services/twitter_token.rb +5 -5
- data/lib/oauth/models/consumers/simple_client.rb +5 -5
- data/lib/oauth/models/consumers/token.rb +13 -14
- data/oauth-plugin.gemspec +1 -1
- metadata +160 -111
@@ -1,7 +1,7 @@
|
|
1
1
|
class OauthClientsController < ApplicationController
|
2
2
|
before_filter :login_required
|
3
3
|
before_filter :get_client_application, :only => [:show, :edit, :update, :destroy]
|
4
|
-
|
4
|
+
|
5
5
|
def index
|
6
6
|
@client_applications = current_user.client_applications
|
7
7
|
@tokens = current_user.tokens.find :all, :conditions => 'oauth_tokens.invalidated_at is null and oauth_tokens.authorized_at is not null'
|
@@ -20,13 +20,13 @@ class OauthClientsController < ApplicationController
|
|
20
20
|
render :action => "new"
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def show
|
25
25
|
end
|
26
26
|
|
27
27
|
def edit
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def update
|
31
31
|
if @client_application.update_attributes(params[:client_application])
|
32
32
|
flash[:notice] = "Updated the client information successfully"
|
@@ -41,7 +41,7 @@ class OauthClientsController < ApplicationController
|
|
41
41
|
flash[:notice] = "Destroyed the client application registration"
|
42
42
|
redirect_to :action => "index"
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
private
|
46
46
|
def get_client_application
|
47
47
|
unless @client_application = current_user.client_applications.find(params[:id])
|
@@ -5,32 +5,32 @@ require 'oauth/client/action_controller_request'
|
|
5
5
|
describe OauthClientsController do
|
6
6
|
if defined?(Devise)
|
7
7
|
include Devise::TestHelpers
|
8
|
-
end
|
8
|
+
end
|
9
9
|
include OAuthControllerSpecHelper
|
10
10
|
fixtures :client_applications, :oauth_tokens, :users
|
11
11
|
before(:each) do
|
12
12
|
login_as_application_owner
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
describe "index" do
|
16
16
|
before do
|
17
17
|
@client_applications = @user.client_applications
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def do_get
|
21
21
|
get :index
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should be successful" do
|
25
25
|
do_get
|
26
26
|
response.should be_success
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should assign client_applications" do
|
30
30
|
do_get
|
31
31
|
assigns[:client_applications].should==@client_applications
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "should render index template" do
|
35
35
|
do_get
|
36
36
|
response.should render_template('index')
|
@@ -42,71 +42,71 @@ describe OauthClientsController do
|
|
42
42
|
def do_get
|
43
43
|
get :show, :id => '1'
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "should be successful" do
|
47
47
|
do_get
|
48
48
|
response.should be_success
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should assign client_applications" do
|
52
52
|
do_get
|
53
53
|
assigns[:client_application].should == current_client_application
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
it "should render show template" do
|
57
57
|
do_get
|
58
58
|
response.should render_template('show')
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
end
|
62
62
|
|
63
63
|
describe "new" do
|
64
|
-
|
64
|
+
|
65
65
|
def do_get
|
66
66
|
get :new
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "should be successful" do
|
70
70
|
do_get
|
71
71
|
response.should be_success
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "should assign client_applications" do
|
75
75
|
do_get
|
76
76
|
assigns[:client_application].class.should == ClientApplication
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
it "should render show template" do
|
80
80
|
do_get
|
81
81
|
response.should render_template('new')
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "edit" do
|
87
87
|
def do_get
|
88
88
|
get :edit, :id => '1'
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it "should be successful" do
|
92
92
|
do_get
|
93
93
|
response.should be_success
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
it "should assign client_applications" do
|
97
97
|
do_get
|
98
98
|
assigns[:client_application].should == current_client_application
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
it "should render edit template" do
|
102
102
|
do_get
|
103
103
|
response.should render_template('edit')
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
end
|
107
107
|
|
108
108
|
describe "create" do
|
109
|
-
|
109
|
+
|
110
110
|
def do_valid_post
|
111
111
|
post :create, 'client_application' => {'name' => 'my site', :url => "http://test.com"}
|
112
112
|
@client_application = ClientApplication.last
|
@@ -115,13 +115,13 @@ describe OauthClientsController do
|
|
115
115
|
def do_invalid_post
|
116
116
|
post :create
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
it "should redirect to new client_application" do
|
120
120
|
do_valid_post
|
121
121
|
response.should be_redirect
|
122
122
|
response.should redirect_to(:action => "show", :id => @client_application.id)
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
it "should render show template" do
|
126
126
|
do_invalid_post
|
127
127
|
response.should render_template('new')
|
@@ -129,26 +129,26 @@ describe OauthClientsController do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
describe "destroy" do
|
132
|
-
|
132
|
+
|
133
133
|
def do_delete
|
134
134
|
delete :destroy, :id => '1'
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
it "should destroy client applications" do
|
138
138
|
do_delete
|
139
139
|
ClientApplication.should_not be_exists(1)
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
it "should redirect to list" do
|
143
143
|
do_delete
|
144
144
|
response.should be_redirect
|
145
145
|
response.should redirect_to(:action => 'index')
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
end
|
149
149
|
|
150
150
|
describe "update" do
|
151
|
-
|
151
|
+
|
152
152
|
def do_valid_update
|
153
153
|
put :update, :id => '1', 'client_application' => {'name' => 'updated site'}
|
154
154
|
end
|
@@ -156,18 +156,18 @@ describe OauthClientsController do
|
|
156
156
|
def do_invalid_update
|
157
157
|
put :update, :id => '1', 'client_application' => {'name' => nil}
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
it "should redirect to show client_application" do
|
161
161
|
do_valid_update
|
162
162
|
response.should be_redirect
|
163
163
|
response.should redirect_to(:action => "show", :id => 1)
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
it "should assign client_applications" do
|
167
167
|
do_invalid_update
|
168
168
|
assigns[:client_application].should == ClientApplication.find(1)
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
it "should render show template" do
|
172
172
|
do_invalid_update
|
173
173
|
response.should render_template('edit')
|
@@ -7,34 +7,34 @@ class OauthClientsController; def rescue_action(e) raise e end; end
|
|
7
7
|
class OauthClientsControllerIndexTest < ActionController::TestCase
|
8
8
|
include OAuthControllerTestHelper
|
9
9
|
tests OauthClientsController
|
10
|
-
|
11
|
-
def setup
|
10
|
+
|
11
|
+
def setup
|
12
12
|
@controller = OauthClientsController.new
|
13
13
|
@request = ActionController::TestRequest.new
|
14
|
-
@response = ActionController::TestResponse.new
|
15
|
-
|
14
|
+
@response = ActionController::TestResponse.new
|
15
|
+
|
16
16
|
login_as_application_owner
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def do_get
|
20
20
|
get :index
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def test_should_be_successful
|
24
24
|
do_get
|
25
25
|
assert @response.success?
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def test_should_query_current_users_client_applications
|
29
29
|
@user.expects(:client_applications).returns(@client_applications)
|
30
30
|
do_get
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def test_should_assign_client_applications
|
34
34
|
do_get
|
35
35
|
assert_equal @client_applications, assigns(:client_applications)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def test_should_render_index_template
|
39
39
|
do_get
|
40
40
|
assert_template 'index'
|
@@ -44,40 +44,40 @@ end
|
|
44
44
|
class OauthClientsControllerShowTest < ActionController::TestCase
|
45
45
|
include OAuthControllerTestHelper
|
46
46
|
tests OauthClientsController
|
47
|
-
|
47
|
+
|
48
48
|
def setup
|
49
49
|
@controller = OauthClientsController.new
|
50
50
|
@request = ActionController::TestRequest.new
|
51
|
-
@response = ActionController::TestResponse.new
|
52
|
-
|
51
|
+
@response = ActionController::TestResponse.new
|
52
|
+
|
53
53
|
login_as_application_owner
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def do_get
|
57
57
|
get :show, :id => '3'
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def test_should_be_successful
|
61
61
|
do_get
|
62
62
|
assert @response.success?
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def test_should_query_current_users_client_applications
|
66
66
|
@user.expects(:client_applications).returns(@client_applications)
|
67
67
|
@client_applications.expects(:find).with('3').returns(@client_application)
|
68
68
|
do_get
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def test_should_assign_client_applications
|
72
72
|
do_get
|
73
73
|
assert_equal @client_application, assigns(:client_application)
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
def test_should_render_show_template
|
77
77
|
do_get
|
78
78
|
assert_template 'show'
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
end
|
82
82
|
|
83
83
|
class OauthClientsControllerNewTest < ActionController::TestCase
|
@@ -87,86 +87,86 @@ class OauthClientsControllerNewTest < ActionController::TestCase
|
|
87
87
|
def setup
|
88
88
|
@controller = OauthClientsController.new
|
89
89
|
@request = ActionController::TestRequest.new
|
90
|
-
@response = ActionController::TestResponse.new
|
91
|
-
|
90
|
+
@response = ActionController::TestResponse.new
|
91
|
+
|
92
92
|
login_as_application_owner
|
93
93
|
ClientApplication.stubs(:new).returns(@client_application)
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
def do_get
|
97
97
|
get :new
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
def test_should_be_successful
|
101
101
|
do_get
|
102
102
|
assert @response.success?
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
def test_should_assign_client_applications
|
106
106
|
do_get
|
107
107
|
assert_equal @client_application, assigns(:client_application)
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def test_should_render_show_template
|
111
111
|
do_get
|
112
112
|
assert_template 'new'
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
class OauthClientsControllerEditTest < ActionController::TestCase
|
118
118
|
include OAuthControllerTestHelper
|
119
119
|
tests OauthClientsController
|
120
|
-
|
120
|
+
|
121
121
|
def setup
|
122
122
|
@controller = OauthClientsController.new
|
123
123
|
@request = ActionController::TestRequest.new
|
124
|
-
@response = ActionController::TestResponse.new
|
124
|
+
@response = ActionController::TestResponse.new
|
125
125
|
|
126
126
|
login_as_application_owner
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
def do_get
|
130
130
|
get :edit, :id=>'3'
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
def test_should_be_successful
|
134
134
|
do_get
|
135
135
|
assert @response.success?
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
def test_should_query_current_users_client_applications
|
139
139
|
@user.expects(:client_applications).returns(@client_applications)
|
140
140
|
@client_applications.expects(:find).with('3').returns(@client_application)
|
141
141
|
do_get
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
def test_should_assign_client_applications
|
145
145
|
do_get
|
146
146
|
assert_equal @client_application, assigns(:client_application)
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
def test_should_render_edit_template
|
150
150
|
do_get
|
151
151
|
assert_template 'edit'
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
end
|
155
155
|
|
156
156
|
class OauthClientsControllerCreateTest < ActionController::TestCase
|
157
157
|
include OAuthControllerTestHelper
|
158
158
|
tests OauthClientsController
|
159
|
-
|
159
|
+
|
160
160
|
def setup
|
161
161
|
@controller = OauthClientsController.new
|
162
162
|
@request = ActionController::TestRequest.new
|
163
|
-
@response = ActionController::TestResponse.new
|
164
|
-
|
163
|
+
@response = ActionController::TestResponse.new
|
164
|
+
|
165
165
|
login_as_application_owner
|
166
166
|
@client_applications.stubs(:build).returns(@client_application)
|
167
167
|
@client_application.stubs(:save).returns(true)
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
def do_valid_post
|
171
171
|
@client_application.expects(:save).returns(true)
|
172
172
|
post :create,'client_application' => {'name' => 'my site'}
|
@@ -176,46 +176,46 @@ class OauthClientsControllerCreateTest < ActionController::TestCase
|
|
176
176
|
@client_application.expects(:save).returns(false)
|
177
177
|
post :create,:client_application=>{:name => 'my site'}
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
def test_should_query_current_users_client_applications
|
181
181
|
@client_applications.expects(:build).returns(@client_application)
|
182
182
|
do_valid_post
|
183
183
|
end
|
184
|
-
|
184
|
+
|
185
185
|
def test_should_redirect_to_new_client_application
|
186
186
|
do_valid_post
|
187
187
|
assert_response :redirect
|
188
188
|
assert_redirected_to(:action => "show", :id => @client_application.id)
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
def test_should_assign_client_applications
|
192
192
|
do_invalid_post
|
193
193
|
assert_equal @client_application, assigns(:client_application)
|
194
194
|
end
|
195
|
-
|
195
|
+
|
196
196
|
def test_should_render_show_template
|
197
197
|
do_invalid_post
|
198
198
|
assert_template('new')
|
199
199
|
end
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
class OauthClientsControllerDestroyTest < ActionController::TestCase
|
203
203
|
include OAuthControllerTestHelper
|
204
204
|
tests OauthClientsController
|
205
|
-
|
205
|
+
|
206
206
|
def setup
|
207
207
|
@controller = OauthClientsController.new
|
208
208
|
@request = ActionController::TestRequest.new
|
209
209
|
@response = ActionController::TestResponse.new
|
210
|
-
|
210
|
+
|
211
211
|
login_as_application_owner
|
212
212
|
@client_application.stubs(:destroy)
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
def do_delete
|
216
216
|
delete :destroy,:id=>'3'
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
219
|
def test_should_query_current_users_client_applications
|
220
220
|
@user.expects(:client_applications).returns(@client_applications)
|
221
221
|
@client_applications.expects(:find).with('3').returns(@client_application)
|
@@ -226,13 +226,13 @@ class OauthClientsControllerDestroyTest < ActionController::TestCase
|
|
226
226
|
@client_application.expects(:destroy)
|
227
227
|
do_delete
|
228
228
|
end
|
229
|
-
|
229
|
+
|
230
230
|
def test_should_redirect_to_list
|
231
231
|
do_delete
|
232
232
|
assert_response :redirect
|
233
233
|
assert_redirected_to :action => 'index'
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
end
|
237
237
|
|
238
238
|
class OauthClientsControllerUpdateTest < ActionController::TestCase
|
@@ -245,7 +245,7 @@ class OauthClientsControllerUpdateTest < ActionController::TestCase
|
|
245
245
|
@response = ActionController::TestResponse.new
|
246
246
|
login_as_application_owner
|
247
247
|
end
|
248
|
-
|
248
|
+
|
249
249
|
def do_valid_update
|
250
250
|
@client_application.expects(:update_attributes).returns(true)
|
251
251
|
put :update, :id => '1', 'client_application' => {'name' => 'my site'}
|
@@ -255,24 +255,24 @@ class OauthClientsControllerUpdateTest < ActionController::TestCase
|
|
255
255
|
@client_application.expects(:update_attributes).returns(false)
|
256
256
|
put :update, :id=>'1', 'client_application' => {'name' => 'my site'}
|
257
257
|
end
|
258
|
-
|
258
|
+
|
259
259
|
def test_should_query_current_users_client_applications
|
260
260
|
@user.expects(:client_applications).returns(@client_applications)
|
261
261
|
@client_applications.expects(:find).with('1').returns(@client_application)
|
262
262
|
do_valid_update
|
263
263
|
end
|
264
|
-
|
264
|
+
|
265
265
|
def test_should_redirect_to_new_client_application
|
266
266
|
do_valid_update
|
267
267
|
assert_response :redirect
|
268
268
|
assert_redirected_to :action => "show", :id => @client_application.id
|
269
269
|
end
|
270
|
-
|
270
|
+
|
271
271
|
def test_should_assign_client_applications
|
272
272
|
do_invalid_update
|
273
273
|
assert_equal @client_application, assigns(:client_application)
|
274
274
|
end
|
275
|
-
|
275
|
+
|
276
276
|
def test_should_render_show_template
|
277
277
|
do_invalid_update
|
278
278
|
assert_template('edit')
|