Sha256: c5d2b59d621966c35e43a75965c379c46a95f63574a04166ef0c54995483f213

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

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

    oauth2 'custom_scope'
    get '/oauth2_dsl_custom_scope' do
      { hello: 'custom scope' }
    end

    oauth2
    get '/oauth2_protected_with_default_scopes' do
      { hello: 'default oauth2 dsl' }
    end

    oauth2 false
    get '/unprotected_endpoint' do
      { hello: 'public 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

6 entries across 6 versions & 2 rubygems

Version Path
privy_wine_bouncer-1.0.4.5 spec/dummy/app/api/protected_api.rb
wine_bouncer-1.0.4 spec/dummy/app/api/protected_api.rb
wine_bouncer-1.0.3 spec/dummy/app/api/protected_api.rb
wine_bouncer-1.0.2 spec/dummy/app/api/protected_api.rb
wine_bouncer-1.0.1 spec/dummy/app/api/protected_api.rb
wine_bouncer-1.0.0 spec/dummy/app/api/protected_api.rb