doorkeeper 0.4.2 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- data/.gitignore +2 -0
- data/.travis.yml +5 -1
- data/CHANGELOG.md +29 -0
- data/Gemfile +12 -4
- data/README.md +76 -7
- data/Rakefile +1 -25
- data/app/assets/javascripts/doorkeeper/application.js +0 -7
- data/app/controllers/doorkeeper/application_controller.rb +1 -27
- data/app/controllers/doorkeeper/applications_controller.rb +14 -6
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/token_info_controller.rb +11 -0
- data/app/controllers/doorkeeper/tokens_controller.rb +11 -8
- data/app/validators/redirect_uri_validator.rb +12 -0
- data/app/views/doorkeeper/applications/_form.html.erb +3 -3
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/index.html.erb +4 -4
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +3 -3
- data/app/views/doorkeeper/authorizations/new.html.erb +2 -2
- data/app/views/doorkeeper/authorized_applications/index.html.erb +1 -1
- data/config/locales/en.yml +35 -0
- data/doorkeeper.gemspec +3 -3
- data/gemfiles/gemfile.rails-3.1.x +10 -0
- data/gemfiles/gemfile.rails-3.2.x +10 -0
- data/lib/doorkeeper.rb +10 -3
- data/lib/doorkeeper/config.rb +56 -38
- data/lib/doorkeeper/doorkeeper_for.rb +2 -0
- data/lib/doorkeeper/engine.rb +3 -32
- data/lib/doorkeeper/helpers/controller.rb +29 -0
- data/lib/doorkeeper/helpers/filter.rb +4 -18
- data/{app/models/doorkeeper → lib/doorkeeper/models}/access_grant.rb +7 -7
- data/{app/models/doorkeeper → lib/doorkeeper/models}/access_token.rb +27 -24
- data/lib/doorkeeper/models/accessible.rb +9 -0
- data/lib/doorkeeper/models/active_record/access_grant.rb +5 -0
- data/lib/doorkeeper/models/active_record/access_token.rb +15 -0
- data/lib/doorkeeper/models/active_record/application.rb +18 -0
- data/lib/doorkeeper/models/application.rb +38 -0
- data/lib/doorkeeper/models/expirable.rb +6 -4
- data/lib/doorkeeper/models/mongoid/access_grant.rb +22 -0
- data/lib/doorkeeper/models/mongoid/access_token.rb +35 -0
- data/lib/doorkeeper/models/mongoid/application.rb +22 -0
- data/lib/doorkeeper/models/mongoid/revocable.rb +15 -0
- data/lib/doorkeeper/models/mongoid/scopes.rb +15 -0
- data/lib/doorkeeper/models/ownership.rb +16 -0
- data/lib/doorkeeper/models/revocable.rb +1 -1
- data/lib/doorkeeper/models/scopes.rb +9 -5
- data/lib/doorkeeper/oauth/access_token_request.rb +2 -2
- data/lib/doorkeeper/oauth/authorization.rb +1 -0
- data/lib/doorkeeper/oauth/authorization/code.rb +5 -3
- data/lib/doorkeeper/oauth/client.rb +2 -2
- data/lib/doorkeeper/oauth/client_credentials_request.rb +4 -1
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +2 -5
- data/lib/doorkeeper/oauth/password_access_token_request.rb +2 -5
- data/lib/doorkeeper/oauth/token.rb +36 -0
- data/lib/doorkeeper/rails/routes.rb +77 -0
- data/lib/doorkeeper/rails/routes/mapper.rb +28 -0
- data/lib/doorkeeper/rails/routes/mapping.rb +39 -0
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/application_owner_generator.rb +15 -0
- data/lib/generators/doorkeeper/install_generator.rb +2 -9
- data/lib/generators/doorkeeper/migration_generator.rb +15 -0
- data/lib/generators/doorkeeper/templates/README +15 -1
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +7 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +31 -15
- data/lib/generators/doorkeeper/templates/migration.rb +7 -4
- data/lib/generators/doorkeeper/views_generator.rb +1 -1
- data/script/run_all +3 -0
- data/spec/controllers/applications_controller_spec.rb +1 -1
- data/spec/controllers/authorizations_controller_spec.rb +4 -4
- data/spec/controllers/protected_resources_controller_spec.rb +7 -7
- data/spec/controllers/token_info_controller_spec.rb +54 -0
- data/spec/controllers/tokens_controller_spec.rb +3 -2
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +7 -0
- data/spec/dummy/app/models/user.rb +16 -5
- data/spec/dummy/config/application.rb +4 -7
- data/spec/dummy/config/boot.rb +3 -7
- data/spec/dummy/config/initializers/doorkeeper.rb +13 -0
- data/spec/dummy/config/mongoid.yml +7 -0
- data/spec/dummy/config/routes.rb +29 -1
- data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +1 -1
- data/spec/dummy/db/migrate/20120524202412_create_doorkeeper_tables.rb +6 -4
- data/spec/dummy/db/schema.rb +5 -3
- data/spec/generators/application_owner_generator_spec.rb +23 -0
- data/spec/generators/install_generator_spec.rb +1 -6
- data/spec/generators/migration_generator_spec.rb +20 -0
- data/spec/lib/config_spec.rb +72 -4
- data/spec/lib/models/expirable_spec.rb +8 -11
- data/spec/lib/models/revocable_spec.rb +1 -1
- data/spec/lib/oauth/access_token_request_spec.rb +15 -9
- data/spec/lib/oauth/authorization_request_spec.rb +1 -0
- data/spec/lib/oauth/client_credentials_request_spec.rb +15 -9
- data/spec/lib/oauth/client_spec.rb +5 -8
- data/spec/lib/oauth/helpers/unique_token_spec.rb +2 -20
- data/spec/lib/oauth/password_access_token_request_spec.rb +16 -9
- data/spec/lib/oauth/token_spec.rb +83 -0
- data/spec/models/doorkeeper/access_token_spec.rb +41 -1
- data/spec/models/doorkeeper/application_spec.rb +53 -20
- data/spec/requests/flows/authorization_code_spec.rb +1 -1
- data/spec/requests/flows/client_credentials_spec.rb +2 -0
- data/spec/requests/flows/password_spec.rb +25 -0
- data/spec/requests/flows/refresh_token_spec.rb +5 -2
- data/spec/requests/protected_resources/private_api_spec.rb +10 -3
- data/spec/routing/custom_controller_routes_spec.rb +44 -0
- data/spec/routing/default_routes_spec.rb +32 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/spec_helper_integration.rb +18 -8
- data/spec/support/dependencies/factory_girl.rb +0 -3
- data/spec/support/orm/active_record.rb +11 -0
- data/spec/support/orm/mongoid.rb +26 -0
- data/spec/support/shared/controllers_shared_context.rb +2 -2
- data/spec/support/shared/models_shared_examples.rb +16 -0
- data/spec/validators/redirect_uri_validator_spec.rb +40 -0
- metadata +61 -37
- data/app/helpers/doorkeeper/application_helper.rb +0 -4
- data/app/models/doorkeeper/application.rb +0 -54
- data/config/routes.rb +0 -9
- data/lib/tasks/doorkeeper_tasks.rake +0 -4
- data/spec/support/dependencies/database_cleaner.rb +0 -16
@@ -1,6 +1,6 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
module Generators
|
3
|
-
class ViewsGenerator < Rails::Generators::Base
|
3
|
+
class ViewsGenerator < ::Rails::Generators::Base
|
4
4
|
source_root File.expand_path('../../../../app/views/doorkeeper', __FILE__)
|
5
5
|
|
6
6
|
desc "Copies default Doorkeeper views to your application."
|
data/script/run_all
CHANGED
@@ -3,9 +3,12 @@ set -e
|
|
3
3
|
|
4
4
|
RBENV_VERSION=1.8.7-p352 bundle install --quiet
|
5
5
|
RBENV_VERSION=1.8.7-p352 bundle exec rake
|
6
|
+
RBENV_VERSION=1.8.7-p352 DOORKEEPER_ORM=mongoid bundle exec rake
|
6
7
|
|
7
8
|
RBENV_VERSION=1.9.2-p290 bundle install --quiet
|
8
9
|
RBENV_VERSION=1.9.2-p290 bundle exec rake
|
10
|
+
RBENV_VERSION=1.9.2-p290 DOORKEEPER_ORM=mongoid bundle exec rake
|
9
11
|
|
10
12
|
RBENV_VERSION=1.9.3-p0 bundle install --quiet
|
11
13
|
RBENV_VERSION=1.9.3-p0 bundle exec rake
|
14
|
+
RBENV_VERSION=1.9.3-p0 DOORKEEPER_ORM=mongoid bundle exec rake
|
@@ -21,7 +21,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
21
21
|
|
22
22
|
describe "POST #create" do
|
23
23
|
before do
|
24
|
-
post :create, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
|
24
|
+
post :create, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
|
25
25
|
end
|
26
26
|
|
27
27
|
it "redirects after authorization" do
|
@@ -56,7 +56,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
56
56
|
describe "POST #create with errors" do
|
57
57
|
before do
|
58
58
|
default_scopes_exist :public
|
59
|
-
post :create, :client_id => client.uid, :response_type => "token", :scope => "invalid", :redirect_uri => client.redirect_uri
|
59
|
+
post :create, :client_id => client.uid, :response_type => "token", :scope => "invalid", :redirect_uri => client.redirect_uri
|
60
60
|
end
|
61
61
|
|
62
62
|
it "redirects after authorization" do
|
@@ -90,7 +90,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
90
90
|
|
91
91
|
describe "GET #new" do
|
92
92
|
before do
|
93
|
-
get :new, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
|
93
|
+
get :new, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'renders new template' do
|
@@ -101,7 +101,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
101
101
|
describe "GET #new with errors" do
|
102
102
|
before do
|
103
103
|
default_scopes_exist :public
|
104
|
-
get :new, :client_id => client.uid, :response_type => "token", :scope => "invalid", :redirect_uri => client.redirect_uri
|
104
|
+
get :new, :client_id => client.uid, :response_type => "token", :scope => "invalid", :redirect_uri => client.redirect_uri
|
105
105
|
end
|
106
106
|
|
107
107
|
it "redirects after authorization" do
|
@@ -79,29 +79,29 @@ describe "Doorkeeper_for helper" do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "access_token param" do
|
82
|
-
Doorkeeper::AccessToken.should_receive(:
|
82
|
+
Doorkeeper::AccessToken.should_receive(:authenticate).with(token_string)
|
83
83
|
get :index, :access_token => token_string
|
84
84
|
end
|
85
85
|
|
86
86
|
it "bearer_token param" do
|
87
|
-
Doorkeeper::AccessToken.should_receive(:
|
87
|
+
Doorkeeper::AccessToken.should_receive(:authenticate).with(token_string)
|
88
88
|
get :index, :bearer_token => token_string
|
89
89
|
end
|
90
90
|
|
91
91
|
it "Authorization header" do
|
92
|
-
Doorkeeper::AccessToken.should_receive(:
|
92
|
+
Doorkeeper::AccessToken.should_receive(:authenticate).with(token_string)
|
93
93
|
request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
|
94
94
|
get :index
|
95
95
|
end
|
96
96
|
|
97
97
|
it "different kind of Authorization header" do
|
98
|
-
Doorkeeper::AccessToken.should_not_receive(:
|
98
|
+
Doorkeeper::AccessToken.should_not_receive(:authenticate)
|
99
99
|
request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("foo:bar")}"
|
100
100
|
get :index
|
101
101
|
end
|
102
102
|
|
103
103
|
it "doesn't change Authorization header value" do
|
104
|
-
Doorkeeper::AccessToken.should_receive(:
|
104
|
+
Doorkeeper::AccessToken.should_receive(:authenticate).exactly(2).times
|
105
105
|
request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
|
106
106
|
get :index
|
107
107
|
get :index
|
@@ -172,14 +172,14 @@ describe "Doorkeeper_for helper" do
|
|
172
172
|
|
173
173
|
it "allows if the token has particular scopes" do
|
174
174
|
token = double(Doorkeeper::AccessToken, :accessible? => true, :scopes => [:write, :public])
|
175
|
-
Doorkeeper::AccessToken.should_receive(:
|
175
|
+
Doorkeeper::AccessToken.should_receive(:authenticate).with(token_string).and_return(token)
|
176
176
|
get :index, :access_token => token_string
|
177
177
|
response.should be_success
|
178
178
|
end
|
179
179
|
|
180
180
|
it "does not allow if the token does not include given scope" do
|
181
181
|
token = double(Doorkeeper::AccessToken, :accessible? => true, :scopes => [:public])
|
182
|
-
Doorkeeper::AccessToken.should_receive(:
|
182
|
+
Doorkeeper::AccessToken.should_receive(:authenticate).with(token_string).and_return(token)
|
183
183
|
get :index, :access_token => token_string
|
184
184
|
response.status.should == 401
|
185
185
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper_integration'
|
2
|
+
|
3
|
+
describe Doorkeeper::TokenInfoController do
|
4
|
+
|
5
|
+
describe "when requesting tokeninfo with valid token" do
|
6
|
+
|
7
|
+
let(:doorkeeper_token) { FactoryGirl.create(:access_token) }
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
controller.stub(:doorkeeper_token) { doorkeeper_token }
|
11
|
+
end
|
12
|
+
|
13
|
+
def do_get
|
14
|
+
get :show
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "successful request" do
|
18
|
+
|
19
|
+
it "responds with tokeninfo" do
|
20
|
+
do_get
|
21
|
+
response.body.should eq doorkeeper_token.to_json
|
22
|
+
end
|
23
|
+
|
24
|
+
it "responds with a 200 status" do
|
25
|
+
do_get
|
26
|
+
response.status.should eq 200
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "invalid token response" do
|
31
|
+
before(:each) do
|
32
|
+
controller.stub(:doorkeeper_token => nil)
|
33
|
+
end
|
34
|
+
it "responds with 401 when doorkeeper_token is not valid" do
|
35
|
+
do_get
|
36
|
+
response.status.should eq 401
|
37
|
+
end
|
38
|
+
|
39
|
+
it "responds with 401 when doorkeeper_token is invalid, expired or revoked" do
|
40
|
+
controller.stub(:doorkeeper_token => doorkeeper_token)
|
41
|
+
doorkeeper_token.stub(:accessible? => false)
|
42
|
+
do_get
|
43
|
+
response.status.should eq 401
|
44
|
+
end
|
45
|
+
|
46
|
+
it "responds body message for error" do
|
47
|
+
do_get
|
48
|
+
response.body.should eq Doorkeeper::OAuth::ErrorResponse.new(:name => :invalid_request, :status => :unauthorized).attributes.to_json
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -12,7 +12,7 @@ describe Doorkeeper::TokensController do
|
|
12
12
|
|
13
13
|
it "returns the authorization" do
|
14
14
|
token.should_receive(:authorization)
|
15
|
-
post :create
|
15
|
+
post :create
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -27,8 +27,9 @@ describe Doorkeeper::TokensController do
|
|
27
27
|
|
28
28
|
it "returns the error response" do
|
29
29
|
token.stub(:error_response => stub(:to_json => [], :status => :unauthorized))
|
30
|
-
post :create
|
30
|
+
post :create
|
31
31
|
response.status.should == 401
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
34
35
|
end
|
@@ -1,11 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if defined? ActiveRecord
|
2
|
+
class User < ActiveRecord::Base
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
if defined? Mongoid
|
7
|
+
class User
|
8
|
+
include Mongoid::Document
|
9
|
+
include Mongoid::Timestamps
|
10
|
+
|
11
|
+
field :name, :type => String
|
12
|
+
field :password, :type => String
|
13
|
+
end
|
14
|
+
end
|
4
15
|
|
16
|
+
class User
|
5
17
|
attr_accessible :name, :password
|
6
18
|
|
7
19
|
def self.authenticate!(name, password)
|
8
|
-
|
9
|
-
owner.authenticate(password) if owner
|
20
|
+
User.where(:name => name, :password => password).first
|
10
21
|
end
|
11
22
|
end
|
@@ -1,15 +1,12 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
# Pick the frameworks you want:
|
4
|
-
require "active_record/railtie"
|
5
3
|
require "action_controller/railtie"
|
6
|
-
# require "action_mailer/railtie"
|
7
4
|
require "active_resource/railtie"
|
8
5
|
require "sprockets/railtie"
|
9
|
-
# require "rails/test_unit/railtie"
|
10
6
|
|
11
|
-
Bundler.require
|
12
|
-
|
7
|
+
Bundler.require :default
|
8
|
+
|
9
|
+
require "#{DOORKEEPER_ORM}/railtie"
|
13
10
|
|
14
11
|
module Dummy
|
15
12
|
class Application < Rails::Application
|
@@ -27,7 +24,7 @@ module Dummy
|
|
27
24
|
# Activate observers that should always be running.
|
28
25
|
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
29
26
|
|
30
|
-
config.active_record.whitelist_attributes = true
|
27
|
+
config.active_record.whitelist_attributes = true if defined?(ActiveRecord)
|
31
28
|
|
32
29
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
33
30
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
2
|
+
require 'bundler/setup'
|
3
3
|
|
4
|
-
|
5
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
|
-
end
|
4
|
+
DOORKEEPER_ORM = (ENV['DOORKEEPER_ORM'] || :active_record).to_sym unless defined?(DOORKEEPER_ORM)
|
9
5
|
|
10
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
6
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -1,4 +1,8 @@
|
|
1
1
|
Doorkeeper.configure do
|
2
|
+
# Change the ORM that doorkeeper will use
|
3
|
+
# Currently supported => :active_record, :mongoid
|
4
|
+
orm DOORKEEPER_ORM
|
5
|
+
|
2
6
|
# This block will be called to check whether the
|
3
7
|
# resource owner is authenticated or not
|
4
8
|
resource_owner_authenticator do |routes|
|
@@ -21,6 +25,9 @@ Doorkeeper.configure do
|
|
21
25
|
# Admin.find_by_id(session[:admin_id]) || redirect_to(routes.new_admin_session_url)
|
22
26
|
# end
|
23
27
|
|
28
|
+
# Authorization Code expiration time (default 10 minutes).
|
29
|
+
# access_token_expires_in 10.minutes
|
30
|
+
|
24
31
|
# Access token expiration time (default 2 hours)
|
25
32
|
# If you want to disable expiration, set this to nil.
|
26
33
|
# access_token_expires_in 2.hours
|
@@ -38,4 +45,10 @@ Doorkeeper.configure do
|
|
38
45
|
# fallsback to `:client_id` and `:client_secret` from `params` object
|
39
46
|
# Check out the wiki for mor information on customization
|
40
47
|
# client_credentials :from_basic, :from_params
|
48
|
+
|
49
|
+
# Change the way access token is authenticated from the request object.
|
50
|
+
# By default it retrieves first from `HTTP_AUTHORIZATION` header and
|
51
|
+
# fallsback to `:access_token` or `:bearer_token` from `params` object
|
52
|
+
# Check out the wiki for mor information on customization
|
53
|
+
# access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
|
41
54
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
2
|
+
use_doorkeeper
|
3
|
+
|
4
|
+
scope 'space' do
|
5
|
+
use_doorkeeper do
|
6
|
+
controllers :authorizations => 'custom_authorizations',
|
7
|
+
:tokens => 'custom_authorizations',
|
8
|
+
:applications => 'custom_authorizations',
|
9
|
+
:token_info => 'custom_authorizations'
|
10
|
+
|
11
|
+
as :authorizations => 'custom_auth',
|
12
|
+
:tokens => 'custom_token',
|
13
|
+
:token_info => 'custom_token_info'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
scope 'outer_space' do
|
18
|
+
use_doorkeeper do
|
19
|
+
controllers :authorizations => 'custom_authorizations',
|
20
|
+
:tokens => 'custom_authorizations',
|
21
|
+
:token_info => 'custom_authorizations'
|
22
|
+
|
23
|
+
as :authorizations => 'custom_auth',
|
24
|
+
:tokens => 'custom_token',
|
25
|
+
:token_info => 'custom_token_info'
|
26
|
+
|
27
|
+
skip_controllers :tokens, :applications, :token_info
|
28
|
+
end
|
29
|
+
end
|
3
30
|
|
4
31
|
get 'metal.json' => 'metal#index'
|
32
|
+
|
5
33
|
get '/callback', :to => "home#callback"
|
6
34
|
get '/sign_in', :to => "home#sign_in"
|
7
35
|
resources :semi_protected_resources
|
@@ -1,10 +1,12 @@
|
|
1
1
|
class CreateDoorkeeperTables < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :oauth_applications do |t|
|
4
|
-
t.string
|
5
|
-
t.string
|
6
|
-
t.string
|
7
|
-
t.string
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.string :uid, :null => false
|
6
|
+
t.string :secret, :null => false
|
7
|
+
t.string :redirect_uri, :null => false
|
8
|
+
t.integer :owner_id, :null => true
|
9
|
+
t.string :owner_type, :null => true
|
8
10
|
t.timestamps
|
9
11
|
end
|
10
12
|
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -46,6 +46,8 @@ ActiveRecord::Schema.define(:version => 20120524202412) do
|
|
46
46
|
t.string "uid", :null => false
|
47
47
|
t.string "secret", :null => false
|
48
48
|
t.string "redirect_uri", :null => false
|
49
|
+
t.string "owner_type", :null => true, :default => "User"
|
50
|
+
t.integer "owner_id", :null => true
|
49
51
|
t.datetime "created_at", :null => false
|
50
52
|
t.datetime "updated_at", :null => false
|
51
53
|
end
|
@@ -54,9 +56,9 @@ ActiveRecord::Schema.define(:version => 20120524202412) do
|
|
54
56
|
|
55
57
|
create_table "users", :force => true do |t|
|
56
58
|
t.string "name"
|
57
|
-
t.datetime "created_at",
|
58
|
-
t.datetime "updated_at",
|
59
|
-
t.string "
|
59
|
+
t.datetime "created_at", :null => false
|
60
|
+
t.datetime "updated_at", :null => false
|
61
|
+
t.string "password"
|
60
62
|
end
|
61
63
|
|
62
64
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper_integration'
|
2
|
+
require 'generators/doorkeeper/application_owner_generator'
|
3
|
+
|
4
|
+
|
5
|
+
describe 'Doorkeeper::ApplicationOwnerGenerator' do
|
6
|
+
include GeneratorSpec::TestCase
|
7
|
+
|
8
|
+
tests Doorkeeper::ApplicationOwnerGenerator
|
9
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
10
|
+
|
11
|
+
describe "after running the generator" do
|
12
|
+
before :each do
|
13
|
+
prepare_destination
|
14
|
+
FileUtils.mkdir(::File.expand_path("config", Pathname(destination_root)))
|
15
|
+
FileUtils.copy_file(::File.expand_path("../templates/routes.rb", __FILE__), ::File.expand_path("config/routes.rb", Pathname.new(destination_root)))
|
16
|
+
run_generator
|
17
|
+
end
|
18
|
+
|
19
|
+
it "creates a migration" do
|
20
|
+
assert_migration "db/migrate/add_owner_to_application.rb"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
require 'generators/doorkeeper/install_generator'
|
3
3
|
|
4
|
-
|
5
4
|
describe 'Doorkeeper::InstallGenerator' do
|
6
5
|
include GeneratorSpec::TestCase
|
7
6
|
|
@@ -16,10 +15,6 @@ describe 'Doorkeeper::InstallGenerator' do
|
|
16
15
|
run_generator
|
17
16
|
end
|
18
17
|
|
19
|
-
it "creates a migration" do
|
20
|
-
assert_migration "db/migrate/create_doorkeeper_tables.rb"
|
21
|
-
end
|
22
|
-
|
23
18
|
it "creates an initializer file" do
|
24
19
|
assert_file 'config/initializers/doorkeeper.rb'
|
25
20
|
end
|
@@ -29,7 +24,7 @@ describe 'Doorkeeper::InstallGenerator' do
|
|
29
24
|
end
|
30
25
|
|
31
26
|
it "adds sample route" do
|
32
|
-
assert_file "config/routes.rb", /
|
27
|
+
assert_file "config/routes.rb", /use_doorkeeper/
|
33
28
|
end
|
34
29
|
end
|
35
30
|
end
|