Sha256: ca8c1c4ffadfa5e32beefe26697ee9eb89c28636773dc547d648fdd9c88d42c1

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module Api

  ###
  # Api under test, default doorkeeper scope is 'account'
  ##
  class MountedProtectedApiUnderTest < Grape::API
    desc 'Protected method with public', auth: { scopes: ['public'] }
    get '/protected' do
      { hello: 'world' }
    end

    desc 'Protected method with private', auth: { scopes: ['private'] }
    get '/protected_with_private_scope' do
      { hello: 'scoped world' }
    end

    desc 'Unprotected method'
    get '/unprotected', auth: false do
      { hello: 'unprotected world' }
    end

    desc 'Protected method with public that returns the user name', auth: { scopes: ['public'] }
    get '/protected_user' do
      { hello: resource_owner.name }
    end

    desc 'This method uses Doorkeepers default scopes'
    get '/protected_without_scope' do
      { hello: 'protected unscoped world' }
    end

    desc 'oauth2_dsl'
    oauth2 'public'
    get '/oauth2_dsl' do
      { hello: 'oauth2_dsl' }
    end

    get '/not_described_world' do
      { hello: 'non described world' }
    end
  end

  class ProtectedApiUnderTest < Grape::API
    default_format :json
    format :json
    use ::WineBouncer::OAuth2
    mount MountedProtectedApiUnderTest
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wine_bouncer-0.3.0 spec/dummy/app/api/protected_api.rb