doorkeeper-grants_assertion 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +12 -0
- data/MIT-LICENSE +21 -0
- data/README.md +30 -0
- data/Rakefile +18 -0
- data/config/locales/en.yml +5 -0
- data/doorkeeper-grants_assertion.gemspec +22 -0
- data/lib/doorkeeper/grants_assertion.rb +27 -0
- data/lib/doorkeeper/request/assertion.rb +29 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +7 -0
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +12 -0
- data/spec/dummy/app/controllers/home_controller.rb +17 -0
- data/spec/dummy/app/controllers/metal_controller.rb +11 -0
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +5 -0
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/app/views/home/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +47 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/database.yml +15 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +62 -0
- data/spec/dummy/config/environments/test.rb +51 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +92 -0
- data/spec/dummy/config/initializers/secret_token.rb +9 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/doorkeeper.en.yml +74 -0
- data/spec/dummy/config/routes.rb +52 -0
- data/spec/dummy/db/migrate/20111122132257_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +41 -0
- data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +7 -0
- data/spec/dummy/db/schema.rb +66 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/access_grant.rb +9 -0
- data/spec/factories/access_token.rb +11 -0
- data/spec/factories/application.rb +6 -0
- data/spec/requests/flows/assertion_spec.rb +74 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_helper_integration.rb +29 -0
- data/spec/support/dependencies/factory_girl.rb +2 -0
- data/spec/support/helpers/config_helper.rb +9 -0
- data/spec/support/helpers/model_helper.rb +45 -0
- data/spec/support/helpers/request_spec_helper.rb +76 -0
- data/spec/support/helpers/url_helper.rb +19 -0
- data/spec/support/shared/controllers_shared_context.rb +60 -0
- data/spec/support/shared/models_shared_examples.rb +52 -0
- metadata +195 -0
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            APP_PATH = File.expand_path('../../config/application',  __FILE__)
         | 
| 5 | 
            +
            require File.expand_path('../../config/boot',  __FILE__)
         | 
| 6 | 
            +
            require 'rails/commands'
         | 
| @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            require 'spec_helper_integration'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            feature 'Resource Owner Assertion Flow inproperly set up' do
         | 
| 4 | 
            +
              background do
         | 
| 5 | 
            +
                client_exists
         | 
| 6 | 
            +
                create_resource_owner
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              context 'with valid user assertion' do
         | 
| 10 | 
            +
                scenario "should not issue new token" do
         | 
| 11 | 
            +
                  expect {
         | 
| 12 | 
            +
                    post assertion_endpoint_url(client: @client, resource_owner: @resource_owner)
         | 
| 13 | 
            +
                  }.to_not change { Doorkeeper::AccessToken.count }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  should_have_json 'error', 'invalid_resource_owner'
         | 
| 16 | 
            +
                  should_have_json 'error_description', translated_error_message(:invalid_resource_owner)
         | 
| 17 | 
            +
                  expect(response.status).to eq(401)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            feature 'Resource Owner Assertion Flow' do
         | 
| 23 | 
            +
              background do
         | 
| 24 | 
            +
                config_is_set(:resource_owner_from_assertion) { User.where(assertion: params[:assertion]).first }
         | 
| 25 | 
            +
                client_exists
         | 
| 26 | 
            +
                create_resource_owner
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              context 'with valid user assertion' do
         | 
| 30 | 
            +
                scenario "should issue new token" do
         | 
| 31 | 
            +
                  expect {
         | 
| 32 | 
            +
                    post assertion_endpoint_url(client: @client, resource_owner: @resource_owner)
         | 
| 33 | 
            +
                  }.to change { Doorkeeper::AccessToken.count }.by(1)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  token = Doorkeeper::AccessToken.first
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  should_have_json 'access_token',  token.token
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                scenario "should issue a refresh token if enabled" do
         | 
| 41 | 
            +
                  config_is_set(:refresh_token_enabled, true)
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  post assertion_endpoint_url(client: @client, resource_owner: @resource_owner)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  token = Doorkeeper::AccessToken.first
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  should_have_json 'refresh_token',  token.refresh_token
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              context "with invalid user assertion" do
         | 
| 53 | 
            +
                scenario "should not issue new token with bad assertion" do
         | 
| 54 | 
            +
                  expect {
         | 
| 55 | 
            +
                    post assertion_endpoint_url( client: @client, assertion: 'i_dont_exist' )
         | 
| 56 | 
            +
                  }.to_not change { Doorkeeper::AccessToken.count }
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  should_have_json 'error', 'invalid_resource_owner'
         | 
| 59 | 
            +
                  should_have_json 'error_description', translated_error_message(:invalid_resource_owner)
         | 
| 60 | 
            +
                  expect(response.status).to eq(401)
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                scenario "should not issue new token without assertion" do
         | 
| 64 | 
            +
                  expect {
         | 
| 65 | 
            +
                    post assertion_endpoint_url( client: @client )
         | 
| 66 | 
            +
                  }.to_not change { Doorkeeper::AccessToken.count }
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                  should_have_json 'error', 'invalid_resource_owner'
         | 
| 69 | 
            +
                  should_have_json 'error_description', translated_error_message(:invalid_resource_owner)
         | 
| 70 | 
            +
                  expect(response.status).to eq(401)
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            ENV['RAILS_ENV'] ||= 'test'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            $LOAD_PATH.unshift File.dirname(__FILE__)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'dummy/config/environment'
         | 
| 6 | 
            +
            require 'rspec/rails'
         | 
| 7 | 
            +
            require 'rspec/autorun'
         | 
| 8 | 
            +
            require 'database_cleaner'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Rails.logger.info "====> Doorkeeper.orm = #{Doorkeeper.configuration.orm.inspect}"
         | 
| 11 | 
            +
            Rails.logger.info "====> Rails version: #{Rails.version}"
         | 
| 12 | 
            +
            Rails.logger.info "====> Ruby version: #{RUBY_VERSION}"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Dir["#{File.dirname(__FILE__)}/support/{dependencies,helpers,shared}/*.rb"].each { |f| require f }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            # load schema to in memory sqlite
         | 
| 17 | 
            +
            ActiveRecord::Migration.verbose = false
         | 
| 18 | 
            +
            load Rails.root + 'db/schema.rb'
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            RSpec.configure do |config|
         | 
| 21 | 
            +
              config.mock_with :rspec
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              config.infer_base_class_for_anonymous_controllers = false
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              config.before { DatabaseCleaner.start }
         | 
| 26 | 
            +
              config.after { DatabaseCleaner.clean }
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              config.order = 'random'
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            module ConfigHelper
         | 
| 2 | 
            +
              def config_is_set(setting, value = nil, &block)
         | 
| 3 | 
            +
                setting_ivar = "@#{setting}"
         | 
| 4 | 
            +
                value = block_given? ? block : value
         | 
| 5 | 
            +
                Doorkeeper.configuration.instance_variable_set(setting_ivar, value)
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RSpec.configuration.send :include, ConfigHelper, type: :request
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            module ModelHelper
         | 
| 2 | 
            +
              def client_exists(client_attributes = {})
         | 
| 3 | 
            +
                @client = FactoryGirl.create(:application, client_attributes)
         | 
| 4 | 
            +
              end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def create_resource_owner
         | 
| 7 | 
            +
                @resource_owner = User.create!(name: 'Joe', password: 'sekret', assertion: 'assertion')
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def authorization_code_exists(options = {})
         | 
| 11 | 
            +
                @authorization = FactoryGirl.create(:access_grant, options)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def access_grant_should_exist_for(client, resource_owner)
         | 
| 15 | 
            +
                grant = Doorkeeper::AccessGrant.first
         | 
| 16 | 
            +
                expect(grant.application).to eq(client)
         | 
| 17 | 
            +
                grant.resource_owner_id  == resource_owner.id
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def access_token_should_exist_for(client, resource_owner)
         | 
| 21 | 
            +
                grant = Doorkeeper::AccessToken.first
         | 
| 22 | 
            +
                expect(grant.application).to eq(client)
         | 
| 23 | 
            +
                grant.resource_owner_id  == resource_owner.id
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def access_grant_should_not_exist
         | 
| 27 | 
            +
                expect(Doorkeeper::AccessGrant.all).to be_empty
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def access_token_should_not_exist
         | 
| 31 | 
            +
                expect(Doorkeeper::AccessToken.all).to be_empty
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def access_grant_should_have_scopes(*args)
         | 
| 35 | 
            +
                grant = Doorkeeper::AccessGrant.first
         | 
| 36 | 
            +
                expect(grant.scopes).to eq(Doorkeeper::OAuth::Scopes.from_array(args))
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def access_token_should_have_scopes(*args)
         | 
| 40 | 
            +
                grant = Doorkeeper::AccessToken.first
         | 
| 41 | 
            +
                expect(grant.scopes).to eq(Doorkeeper::OAuth::Scopes.from_array(args))
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            RSpec.configuration.send :include, ModelHelper, type: :request
         | 
| @@ -0,0 +1,76 @@ | |
| 1 | 
            +
            module RequestSpecHelper
         | 
| 2 | 
            +
              def i_should_see(content)
         | 
| 3 | 
            +
                expect(page).to have_content(content)
         | 
| 4 | 
            +
              end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def i_should_not_see(content)
         | 
| 7 | 
            +
                expect(page).to have_no_content(content)
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def i_should_be_on(path)
         | 
| 11 | 
            +
                expect(current_path).to eq(path)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def url_should_have_param(param, value)
         | 
| 15 | 
            +
                expect(current_params[param]).to eq(value)
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def url_should_not_have_param(param)
         | 
| 19 | 
            +
                expect(current_params).not_to have_key(param)
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def current_params
         | 
| 23 | 
            +
                Rack::Utils.parse_query(current_uri.query)
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def current_uri
         | 
| 27 | 
            +
                URI.parse(page.current_url)
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def should_have_header(header, value)
         | 
| 31 | 
            +
                expect(headers[header]).to eq(value)
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def with_access_token_header(token)
         | 
| 35 | 
            +
                with_header 'Authorization', "Bearer #{token}"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              def with_header(header, value)
         | 
| 39 | 
            +
                page.driver.header header, value
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              def basic_auth_header_for_client(client)
         | 
| 43 | 
            +
                ActionController::HttpAuthentication::Basic.encode_credentials client.uid, client.secret
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def should_have_json(key, value)
         | 
| 47 | 
            +
                expect(JSON.parse(response.body).fetch(key)).to eq(value)
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              def should_have_json_within(key, value, range)
         | 
| 51 | 
            +
                expect(JSON.parse(response.body).fetch(key)).to be_within(range).of(value)
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              def should_not_have_json(key)
         | 
| 55 | 
            +
                expect(JSON.parse(response.body)).not_to have_key(key)
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              def sign_in
         | 
| 59 | 
            +
                visit '/'
         | 
| 60 | 
            +
                click_on 'Sign in'
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              def i_should_see_translated_error_message(key)
         | 
| 64 | 
            +
                i_should_see translated_error_message(key)
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              def translated_error_message(key)
         | 
| 68 | 
            +
                I18n.translate key, scope: [:doorkeeper, :errors, :messages]
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              def response_status_should_be(status)
         | 
| 72 | 
            +
                expect(page.driver.response.status.to_i).to eq(status)
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            RSpec.configuration.send :include, RequestSpecHelper, type: :request
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module UrlHelper
         | 
| 2 | 
            +
              def assertion_endpoint_url(options = {})
         | 
| 3 | 
            +
                parameters = {
         | 
| 4 | 
            +
                  :code          => options[:code],
         | 
| 5 | 
            +
                  :client_id     => options[:client_id]     || options[:client].uid,
         | 
| 6 | 
            +
                  :client_secret => options[:client_secret] || options[:client].secret,
         | 
| 7 | 
            +
                  :redirect_uri  => options[:redirect_uri]  || options[:client].redirect_uri,
         | 
| 8 | 
            +
                  :grant_type    => options[:grant_type]    || "assertion",
         | 
| 9 | 
            +
                  :assertion     => options[:assertion]     || (options[:resource_owner] ? options[:resource_owner].assertion : nil)
         | 
| 10 | 
            +
                }
         | 
| 11 | 
            +
                "/oauth/token?#{build_query(parameters)}"
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def build_query(hash)
         | 
| 15 | 
            +
                Rack::Utils.build_query(hash)
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            RSpec.configuration.send :include, UrlHelper, type: :request
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            shared_context 'valid token', token: :valid do
         | 
| 2 | 
            +
              let :token_string do
         | 
| 3 | 
            +
                '1A2B3C4D'
         | 
| 4 | 
            +
              end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              let :token do
         | 
| 7 | 
            +
                double(Doorkeeper::AccessToken, accessible?: true)
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              before :each do
         | 
| 11 | 
            +
                allow(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string).and_return(token)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            shared_context 'invalid token', token: :invalid do
         | 
| 16 | 
            +
              let :token_string do
         | 
| 17 | 
            +
                '1A2B3C4D'
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              let :token do
         | 
| 21 | 
            +
                double(Doorkeeper::AccessToken, accessible?: false, revoked?: false, expired?: false)
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              before :each do
         | 
| 25 | 
            +
                allow(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string).and_return(token)
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            shared_context 'authenticated resource owner' do
         | 
| 30 | 
            +
              before do
         | 
| 31 | 
            +
                user = double(:resource, id: 1)
         | 
| 32 | 
            +
                allow(Doorkeeper.configuration).to receive(:authenticate_resource_owner) { proc { user } }
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            shared_context 'not authenticated resource owner' do
         | 
| 37 | 
            +
              before do
         | 
| 38 | 
            +
                allow(Doorkeeper.configuration).to receive(:authenticate_resource_owner) { proc { redirect_to '/' } }
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            shared_context 'valid authorization request' do
         | 
| 43 | 
            +
              let :authorization do
         | 
| 44 | 
            +
                double(:authorization, valid?: true, authorize: true, success_redirect_uri: 'http://something.com/cb?code=token')
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              before do
         | 
| 48 | 
            +
                allow(controller).to receive(:authorization) { authorization }
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            shared_context 'invalid authorization request' do
         | 
| 53 | 
            +
              let :authorization do
         | 
| 54 | 
            +
                double(:authorization, valid?: false, authorize: false, redirect_on_error?: false)
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              before do
         | 
| 58 | 
            +
                allow(controller).to receive(:authorization) { authorization }
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            shared_examples 'an accessible token' do
         | 
| 2 | 
            +
              describe :accessible? do
         | 
| 3 | 
            +
                it 'is accessible if token is not expired' do
         | 
| 4 | 
            +
                  allow(subject).to receive(:expired?).and_return(false)
         | 
| 5 | 
            +
                  should be_accessible
         | 
| 6 | 
            +
                end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                it 'is not accessible if token is expired' do
         | 
| 9 | 
            +
                  allow(subject).to receive(:expired?).and_return(true)
         | 
| 10 | 
            +
                  should_not be_accessible
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            shared_examples 'a revocable token' do
         | 
| 16 | 
            +
              describe :accessible? do
         | 
| 17 | 
            +
                before { subject.save! }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it 'is accessible if token is not revoked' do
         | 
| 20 | 
            +
                  expect(subject).to be_accessible
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it 'is not accessible if token is revoked' do
         | 
| 24 | 
            +
                  subject.revoke
         | 
| 25 | 
            +
                  expect(subject).not_to be_accessible
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            shared_examples 'a unique token' do
         | 
| 31 | 
            +
              describe :token do
         | 
| 32 | 
            +
                it 'is generated before validation' do
         | 
| 33 | 
            +
                  expect { subject.valid? }.to change { subject.token }.from(nil)
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                it 'is not valid if token exists' do
         | 
| 37 | 
            +
                  token1 = FactoryGirl.create factory_name
         | 
| 38 | 
            +
                  token2 = FactoryGirl.create factory_name
         | 
| 39 | 
            +
                  token2.token = token1.token
         | 
| 40 | 
            +
                  expect(token2).not_to be_valid
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                it 'expects database to throw an error when tokens are the same' do
         | 
| 44 | 
            +
                  token1 = FactoryGirl.create factory_name
         | 
| 45 | 
            +
                  token2 = FactoryGirl.create factory_name
         | 
| 46 | 
            +
                  token2.token = token1.token
         | 
| 47 | 
            +
                  expect do
         | 
| 48 | 
            +
                    token2.save!(validate: false)
         | 
| 49 | 
            +
                  end.to raise_error
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,195 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: doorkeeper-grants_assertion
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Tute Costa
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-05-23 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: railties
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '3.1'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '3.1'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: doorkeeper
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '1.3'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '1.3'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec-rails
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 2.11.4
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 2.11.4
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: capybara
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 1.1.2
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: 1.1.2
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: factory_girl
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 2.6.4
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: 2.6.4
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: generator_spec
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 0.9.0
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - "~>"
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: 0.9.0
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: database_cleaner
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - "~>"
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: 1.2.0
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - "~>"
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 1.2.0
         | 
| 111 | 
            +
            description: Assertion grant extension for Doorkeeper.
         | 
| 112 | 
            +
            email:
         | 
| 113 | 
            +
            - tutecosta@gmail.com
         | 
| 114 | 
            +
            executables: []
         | 
| 115 | 
            +
            extensions: []
         | 
| 116 | 
            +
            extra_rdoc_files: []
         | 
| 117 | 
            +
            files:
         | 
| 118 | 
            +
            - ".gitignore"
         | 
| 119 | 
            +
            - Gemfile
         | 
| 120 | 
            +
            - MIT-LICENSE
         | 
| 121 | 
            +
            - README.md
         | 
| 122 | 
            +
            - Rakefile
         | 
| 123 | 
            +
            - config/locales/en.yml
         | 
| 124 | 
            +
            - doorkeeper-grants_assertion.gemspec
         | 
| 125 | 
            +
            - lib/doorkeeper/grants_assertion.rb
         | 
| 126 | 
            +
            - lib/doorkeeper/request/assertion.rb
         | 
| 127 | 
            +
            - spec/dummy/Rakefile
         | 
| 128 | 
            +
            - spec/dummy/app/controllers/application_controller.rb
         | 
| 129 | 
            +
            - spec/dummy/app/controllers/custom_authorizations_controller.rb
         | 
| 130 | 
            +
            - spec/dummy/app/controllers/full_protected_resources_controller.rb
         | 
| 131 | 
            +
            - spec/dummy/app/controllers/home_controller.rb
         | 
| 132 | 
            +
            - spec/dummy/app/controllers/metal_controller.rb
         | 
| 133 | 
            +
            - spec/dummy/app/controllers/semi_protected_resources_controller.rb
         | 
| 134 | 
            +
            - spec/dummy/app/helpers/application_helper.rb
         | 
| 135 | 
            +
            - spec/dummy/app/models/user.rb
         | 
| 136 | 
            +
            - spec/dummy/app/views/home/index.html.erb
         | 
| 137 | 
            +
            - spec/dummy/app/views/layouts/application.html.erb
         | 
| 138 | 
            +
            - spec/dummy/config.ru
         | 
| 139 | 
            +
            - spec/dummy/config/application.rb
         | 
| 140 | 
            +
            - spec/dummy/config/boot.rb
         | 
| 141 | 
            +
            - spec/dummy/config/database.yml
         | 
| 142 | 
            +
            - spec/dummy/config/environment.rb
         | 
| 143 | 
            +
            - spec/dummy/config/environments/development.rb
         | 
| 144 | 
            +
            - spec/dummy/config/environments/production.rb
         | 
| 145 | 
            +
            - spec/dummy/config/environments/test.rb
         | 
| 146 | 
            +
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 147 | 
            +
            - spec/dummy/config/initializers/doorkeeper.rb
         | 
| 148 | 
            +
            - spec/dummy/config/initializers/secret_token.rb
         | 
| 149 | 
            +
            - spec/dummy/config/initializers/session_store.rb
         | 
| 150 | 
            +
            - spec/dummy/config/initializers/wrap_parameters.rb
         | 
| 151 | 
            +
            - spec/dummy/config/locales/doorkeeper.en.yml
         | 
| 152 | 
            +
            - spec/dummy/config/routes.rb
         | 
| 153 | 
            +
            - spec/dummy/db/migrate/20111122132257_create_users.rb
         | 
| 154 | 
            +
            - spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb
         | 
| 155 | 
            +
            - spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb
         | 
| 156 | 
            +
            - spec/dummy/db/schema.rb
         | 
| 157 | 
            +
            - spec/dummy/script/rails
         | 
| 158 | 
            +
            - spec/factories/access_grant.rb
         | 
| 159 | 
            +
            - spec/factories/access_token.rb
         | 
| 160 | 
            +
            - spec/factories/application.rb
         | 
| 161 | 
            +
            - spec/requests/flows/assertion_spec.rb
         | 
| 162 | 
            +
            - spec/spec_helper.rb
         | 
| 163 | 
            +
            - spec/spec_helper_integration.rb
         | 
| 164 | 
            +
            - spec/support/dependencies/factory_girl.rb
         | 
| 165 | 
            +
            - spec/support/helpers/config_helper.rb
         | 
| 166 | 
            +
            - spec/support/helpers/model_helper.rb
         | 
| 167 | 
            +
            - spec/support/helpers/request_spec_helper.rb
         | 
| 168 | 
            +
            - spec/support/helpers/url_helper.rb
         | 
| 169 | 
            +
            - spec/support/shared/controllers_shared_context.rb
         | 
| 170 | 
            +
            - spec/support/shared/models_shared_examples.rb
         | 
| 171 | 
            +
            homepage: https://github.com/doorkeeper-gem/doorkeeper/doorkeeper-grants-assertion
         | 
| 172 | 
            +
            licenses:
         | 
| 173 | 
            +
            - MIT
         | 
| 174 | 
            +
            metadata: {}
         | 
| 175 | 
            +
            post_install_message: 
         | 
| 176 | 
            +
            rdoc_options: []
         | 
| 177 | 
            +
            require_paths:
         | 
| 178 | 
            +
            - lib
         | 
| 179 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 180 | 
            +
              requirements:
         | 
| 181 | 
            +
              - - ">="
         | 
| 182 | 
            +
                - !ruby/object:Gem::Version
         | 
| 183 | 
            +
                  version: '0'
         | 
| 184 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 185 | 
            +
              requirements:
         | 
| 186 | 
            +
              - - ">="
         | 
| 187 | 
            +
                - !ruby/object:Gem::Version
         | 
| 188 | 
            +
                  version: '0'
         | 
| 189 | 
            +
            requirements: []
         | 
| 190 | 
            +
            rubyforge_project: 
         | 
| 191 | 
            +
            rubygems_version: 2.2.2
         | 
| 192 | 
            +
            signing_key: 
         | 
| 193 | 
            +
            specification_version: 4
         | 
| 194 | 
            +
            summary: Assertion grant extension for Doorkeeper.
         | 
| 195 | 
            +
            test_files: []
         |