oauth-plugin 0.4.0.rc2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.4.0
|
2
|
+
- fix migrations to use expires_at instead of valid_to [pelle]
|
3
|
+
- add force parameter for forcing token refresh [afeld]
|
4
|
+
- make it work in rails 2x [Kimtaro]
|
5
|
+
- Use 0.5+ OAuth2 gem [kookster]
|
6
|
+
- prevent addition of ? marks to callback url when not needed [kookster]
|
7
|
+
- make .credentials accessible to TwitterToken [afeld]
|
1
8
|
0.4.0-rc2
|
2
9
|
- Better OAuth2 support.
|
3
10
|
- Refactored authorizer into a Authorizer object which is now better tested
|
data/README.rdoc
CHANGED
data/UPGRADE.rdoc
CHANGED
@@ -5,26 +5,26 @@ class OauthConsumerGenerator < Rails::Generator::Base
|
|
5
5
|
|
6
6
|
def manifest
|
7
7
|
record do |m|
|
8
|
-
|
8
|
+
|
9
9
|
# Controller, helper, views, and test directories.
|
10
10
|
m.directory File.join('app/models')
|
11
11
|
m.directory File.join('app/controllers')
|
12
12
|
m.directory File.join('app/helpers')
|
13
13
|
m.directory File.join('app/views', 'oauth_consumers')
|
14
14
|
m.directory File.join('config/initializers')
|
15
|
-
|
15
|
+
|
16
16
|
m.template 'oauth_config.rb',File.join('config/initializers', "oauth_consumers.rb")
|
17
17
|
m.template 'consumer_token.rb',File.join('app/models',"consumer_token.rb")
|
18
18
|
|
19
19
|
m.template 'controller.rb',File.join('app/controllers',"oauth_consumers_controller.rb")
|
20
20
|
m.route_entry "map.resources :oauth_consumers,:member=>{:callback=>:get}"
|
21
|
-
|
21
|
+
|
22
22
|
@template_extension= options[:haml] ? "haml" : "erb"
|
23
|
-
|
23
|
+
|
24
24
|
m.template "show.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "show.html.#{@template_extension}")
|
25
25
|
m.template "index.html.#{@template_extension}", File.join('app/views', 'oauth_consumers', "index.html.#{@template_extension}")
|
26
|
-
|
27
|
-
unless options[:skip_migration]
|
26
|
+
|
27
|
+
unless options[:skip_migration]
|
28
28
|
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
29
29
|
:migration_name => "CreateOauthConsumerTokens"
|
30
30
|
}, :migration_file_name => "create_oauth_consumer_tokens"
|
@@ -40,11 +40,11 @@ class OauthConsumerGenerator < Rails::Generator::Base
|
|
40
40
|
def add_options!(opt)
|
41
41
|
opt.separator ''
|
42
42
|
opt.separator 'Options:'
|
43
|
-
opt.on("--skip-migration",
|
43
|
+
opt.on("--skip-migration",
|
44
44
|
"Don't generate a migration file") { |v| options[:skip_migration] = v }
|
45
|
-
# opt.on("--test-unit",
|
45
|
+
# opt.on("--test-unit",
|
46
46
|
# "Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
|
47
|
-
opt.on("--haml",
|
47
|
+
opt.on("--haml",
|
48
48
|
"Templates use haml") { |v| options[:haml] = v }
|
49
49
|
end
|
50
50
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'oauth/models/consumers/token'
|
2
2
|
class ConsumerToken < ActiveRecord::Base
|
3
3
|
include Oauth::Models::Consumers::Token
|
4
|
-
|
4
|
+
|
5
5
|
# You can safely remove this callback if you don't allow login from any of your services
|
6
6
|
before_create :create_user
|
7
|
-
|
7
|
+
|
8
8
|
# Modify this with class_name etc to match your application
|
9
9
|
belongs_to :user
|
10
|
-
|
10
|
+
|
11
11
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'oauth/controllers/consumer_controller'
|
2
2
|
class OauthConsumersController < ApplicationController
|
3
3
|
include Oauth::Controllers::ConsumerController
|
4
|
-
|
4
|
+
|
5
5
|
def index
|
6
6
|
@consumer_tokens=ConsumerToken.all :conditions => {:user_id => current_user.id}
|
7
7
|
@services=OAUTH_CREDENTIALS.keys-@consumer_tokens.collect{|c| c.class.service_name}
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def callback
|
11
11
|
super
|
12
12
|
end
|
@@ -14,14 +14,14 @@ class OauthConsumersController < ApplicationController
|
|
14
14
|
def client
|
15
15
|
super
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
protected
|
19
|
-
|
19
|
+
|
20
20
|
# Change this to decide where you want to redirect user to after callback is finished.
|
21
21
|
# params[:id] holds the service name so you could use this to redirect to various parts
|
22
22
|
# of your application depending on what service you're connecting to.
|
23
23
|
def go_back
|
24
24
|
redirect_to root_url
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class CreateOauthConsumerTokens < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
|
3
|
+
|
4
4
|
create_table :consumer_tokens do |t|
|
5
5
|
t.integer :user_id
|
6
6
|
t.string :type, :limit => 30
|
@@ -8,9 +8,9 @@ class CreateOauthConsumerTokens < ActiveRecord::Migration
|
|
8
8
|
t.string :secret
|
9
9
|
t.timestamps
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
add_index :consumer_tokens, :token, :unique => true
|
13
|
-
|
13
|
+
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.down
|
@@ -58,15 +58,15 @@
|
|
58
58
|
# :nu_bux => {
|
59
59
|
# :key => "",
|
60
60
|
# :secret => "",
|
61
|
-
# :super_class => "OpenTransactToken", # if a OAuth service follows a particular standard
|
61
|
+
# :super_class => "OpenTransactToken", # if a OAuth service follows a particular standard
|
62
62
|
# # with a token implementation you can set the superclass
|
63
63
|
# # to use
|
64
64
|
# :options => { # OAuth::Consumer options
|
65
|
-
# :site => "http://nubux.heroku.com"
|
65
|
+
# :site => "http://nubux.heroku.com"
|
66
66
|
# }
|
67
67
|
# }
|
68
68
|
# }
|
69
|
-
#
|
69
|
+
#
|
70
70
|
OAUTH_CREDENTIALS = {
|
71
71
|
} unless defined? OAUTH_CREDENTIALS
|
72
72
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Rails::Generator::Commands::Create.class_eval do
|
4
4
|
def route_entry(raw)
|
5
5
|
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
6
|
-
|
6
|
+
|
7
7
|
logger.route raw
|
8
8
|
unless options[:pretend]
|
9
9
|
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
@@ -15,7 +15,7 @@ Rails::Generator::Commands::Create.class_eval do
|
|
15
15
|
def route_resource(*resources)
|
16
16
|
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
17
17
|
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
18
|
-
|
18
|
+
|
19
19
|
logger.route "map.resource #{resource_list}"
|
20
20
|
unless options[:pretend]
|
21
21
|
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
@@ -23,10 +23,10 @@ Rails::Generator::Commands::Create.class_eval do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def route_name(name, path, route_options = {})
|
28
28
|
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
29
|
-
|
29
|
+
|
30
30
|
logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
31
31
|
unless options[:pretend]
|
32
32
|
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
@@ -35,7 +35,7 @@ Rails::Generator::Commands::Create.class_eval do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
Rails::Generator::Commands::Destroy.class_eval do
|
40
40
|
def route_resource(*resources)
|
41
41
|
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
@@ -45,7 +45,7 @@ Rails::Generator::Commands::Destroy.class_eval do
|
|
45
45
|
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def route_name(name, path, route_options = {})
|
50
50
|
look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
51
51
|
logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
|
@@ -54,13 +54,13 @@ Rails::Generator::Commands::Destroy.class_eval do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
Rails::Generator::Commands::List.class_eval do
|
59
59
|
def route_resource(*resources)
|
60
60
|
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
61
61
|
logger.route "map.resource #{resource_list}"
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
def route_name(name, path, options = {})
|
65
65
|
logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
|
66
66
|
end
|
@@ -24,7 +24,7 @@ class OauthProviderGenerator < Rails::Generator::Base
|
|
24
24
|
|
25
25
|
def manifest
|
26
26
|
record do |m|
|
27
|
-
|
27
|
+
|
28
28
|
# Check for class naming collisions.
|
29
29
|
# Check for class naming collisions.
|
30
30
|
m.class_collisions controller_class_path, "#{controller_class_name}Controller", # Oauth Controller
|
@@ -58,13 +58,13 @@ class OauthProviderGenerator < Rails::Generator::Base
|
|
58
58
|
m.route_name 'test_request', '/oauth/test_request',:controller=>'oauth',:action=>'test_request'
|
59
59
|
|
60
60
|
m.route_resources "#{controller_file_name}_clients".to_sym
|
61
|
-
|
61
|
+
|
62
62
|
if !options[:test_unit]
|
63
63
|
m.directory File.join('spec')
|
64
64
|
m.directory File.join('spec/models')
|
65
65
|
m.directory File.join('spec/fixtures', class_path)
|
66
66
|
m.directory File.join('spec/controllers', controller_class_path)
|
67
|
-
|
67
|
+
|
68
68
|
m.template 'client_application_spec.rb',File.join('spec/models',"client_application_spec.rb")
|
69
69
|
m.template 'oauth_token_spec.rb', File.join('spec/models',"oauth_token_spec.rb")
|
70
70
|
m.template 'oauth2_token_spec.rb', File.join('spec/models',"oauth2_token_spec.rb")
|
@@ -87,10 +87,10 @@ class OauthProviderGenerator < Rails::Generator::Base
|
|
87
87
|
m.template 'oauth_nonces.yml', File.join('test/fixtures',"oauth_nonces.yml")
|
88
88
|
m.template 'clients_controller_test.rb',File.join('test/functional',controller_class_path,"#{controller_file_name}_clients_controller_test.rb")
|
89
89
|
end
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
|
92
92
|
@template_extension= options[:haml] ? "haml" : "erb"
|
93
|
-
|
93
|
+
|
94
94
|
m.template "_form.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "_form.html.#{@template_extension}")
|
95
95
|
m.template "new.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "new.html.#{@template_extension}")
|
96
96
|
m.template "index.html.#{@template_extension}", File.join('app/views', controller_class_path, 'oauth_clients', "index.html.#{@template_extension}")
|
@@ -100,7 +100,7 @@ class OauthProviderGenerator < Rails::Generator::Base
|
|
100
100
|
m.template "oauth2_authorize.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "oauth2_authorize.html.#{@template_extension}")
|
101
101
|
m.template "authorize_success.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize_success.html.#{@template_extension}")
|
102
102
|
m.template "authorize_failure.html.#{@template_extension}", File.join('app/views', controller_class_path, controller_file_name, "authorize_failure.html.#{@template_extension}")
|
103
|
-
|
103
|
+
|
104
104
|
unless options[:skip_migration]
|
105
105
|
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
106
106
|
:migration_name => "CreateOauthTables"
|
@@ -117,11 +117,11 @@ class OauthProviderGenerator < Rails::Generator::Base
|
|
117
117
|
def add_options!(opt)
|
118
118
|
opt.separator ''
|
119
119
|
opt.separator 'Options:'
|
120
|
-
opt.on("--skip-migration",
|
120
|
+
opt.on("--skip-migration",
|
121
121
|
"Don't generate a migration file") { |v| options[:skip_migration] = v }
|
122
|
-
opt.on("--test-unit",
|
122
|
+
opt.on("--test-unit",
|
123
123
|
"Generate the Test::Unit compatible tests instead of RSpec") { |v| options[:test_unit] = v }
|
124
|
-
opt.on("--haml",
|
124
|
+
opt.on("--haml",
|
125
125
|
"Templates use haml") { |v| options[:haml] = v }
|
126
126
|
end
|
127
127
|
end
|
@@ -2,20 +2,20 @@
|
|
2
2
|
.field
|
3
3
|
%label{:for=>"client_application_name"} Name*
|
4
4
|
%br
|
5
|
-
= f.text_field :name
|
5
|
+
= f.text_field :name
|
6
6
|
|
7
7
|
.field
|
8
8
|
%label{:for=>"client_application_url"} Main Application URL*
|
9
9
|
%br
|
10
|
-
= f.text_field :url
|
10
|
+
= f.text_field :url
|
11
11
|
|
12
12
|
.field
|
13
13
|
%label{:for=>"client_application_callback_url"} Callback URL*
|
14
14
|
%br
|
15
|
-
= f.text_field :callback_url
|
15
|
+
= f.text_field :callback_url
|
16
16
|
|
17
17
|
.field
|
18
18
|
%label{:for=>"client_application_support_url"} Support URL
|
19
19
|
%br
|
20
|
-
= f.text_field :support_url
|
20
|
+
= f.text_field :support_url
|
21
21
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
class AccessToken < OauthToken
|
2
2
|
validates_presence_of :user, :secret
|
3
3
|
before_create :set_authorized_at
|
4
|
-
|
4
|
+
|
5
5
|
# Implement this to return a hash or array of the capabilities the access token has
|
6
6
|
# This is particularly useful if you have implemented user defined permissions.
|
7
7
|
# def capabilities
|
8
8
|
# {:invalidate=>"/oauth/invalidate",:capabilities=>"/oauth/capabilities"}
|
9
9
|
# end
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
13
|
def set_authorized_at
|
14
14
|
self.authorized_at = Time.now
|
15
15
|
end
|
@@ -14,7 +14,7 @@ class ClientApplication < ActiveRecord::Base
|
|
14
14
|
validates_format_of :callback_url, :with => /\Ahttp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i, :allow_blank=>true
|
15
15
|
|
16
16
|
attr_accessor :token_callback_url
|
17
|
-
|
17
|
+
|
18
18
|
def self.find_token(token_key)
|
19
19
|
token = OauthToken.find_by_token(token_key, :include => :client_application)
|
20
20
|
if token && token.authorized?
|
@@ -23,7 +23,7 @@ class ClientApplication < ActiveRecord::Base
|
|
23
23
|
nil
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def self.verify_request(request, options = {}, &block)
|
28
28
|
begin
|
29
29
|
signature = OAuth::Signature.build(request, options, &block)
|
@@ -34,22 +34,22 @@ class ClientApplication < ActiveRecord::Base
|
|
34
34
|
false
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def oauth_server
|
39
39
|
@oauth_server ||= OAuth::Server.new("http://your.site")
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def credentials
|
43
43
|
@oauth_client ||= OAuth::Consumer.new(key, secret)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# If your application requires passing in extra parameters handle it here
|
47
|
-
def create_request_token(params={})
|
47
|
+
def create_request_token(params={})
|
48
48
|
RequestToken.create :client_application => self, :callback_url=>self.token_callback_url
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
protected
|
52
|
-
|
52
|
+
|
53
53
|
def generate_keys
|
54
54
|
self.key = OAuth::Helper.generate_key(40)[0,40]
|
55
55
|
self.secret = OAuth::Helper.generate_key(40)[0,40]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
describe ClientApplication do
|
2
|
+
describe ClientApplication do
|
3
3
|
fixtures :users, :client_applications, :oauth_tokens
|
4
4
|
before(:each) do
|
5
5
|
@application = ClientApplication.create :name => "Agree2", :url => "http://agree2.com", :user => users(:quentin)
|
@@ -8,12 +8,12 @@ describe ClientApplication do
|
|
8
8
|
it "should be valid" do
|
9
9
|
@application.should be_valid
|
10
10
|
end
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
|
13
13
|
it "should not have errors" do
|
14
14
|
@application.errors.full_messages.should == []
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should have key and secret" do
|
18
18
|
@application.key.should_not be_nil
|
19
19
|
@application.secret.should_not be_nil
|
@@ -24,6 +24,6 @@ describe ClientApplication do
|
|
24
24
|
@application.credentials.key.should == @application.key
|
25
25
|
@application.credentials.secret.should == @application.secret
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
module OAuthHelpers
|
3
|
-
|
3
|
+
|
4
4
|
def create_consumer
|
5
5
|
@consumer=OAuth::Consumer.new(@application.key,@application.secret,
|
6
6
|
{
|
7
7
|
:site=>@application.oauth_server.base_url
|
8
8
|
})
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
end
|
12
12
|
|
13
13
|
class ClientApplicationTest < ActiveSupport::TestCase
|
14
14
|
include OAuthHelpers
|
15
15
|
fixtures :users,:client_applications,:oauth_tokens
|
16
|
-
|
16
|
+
|
17
17
|
def setup
|
18
18
|
@application = ClientApplication.create :name => "Agree2", :url => "http://agree2.com", :user => users(:quentin)
|
19
19
|
create_consumer
|
@@ -22,12 +22,12 @@ class ClientApplicationTest < ActiveSupport::TestCase
|
|
22
22
|
def test_should_be_valid
|
23
23
|
assert @application.valid?
|
24
24
|
end
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
|
27
27
|
def test_should_not_have_errors
|
28
28
|
assert_equal [], @application.errors.full_messages
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def test_should_have_key_and_secret
|
32
32
|
assert_not_nil @application.key
|
33
33
|
assert_not_nil @application.secret
|
@@ -38,5 +38,5 @@ class ClientApplicationTest < ActiveSupport::TestCase
|
|
38
38
|
assert_equal @application.key, @application.credentials.key
|
39
39
|
assert_equal @application.secret, @application.credentials.secret
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
end
|