Sha256: e4cf870ac2f90ffe79045b40784d2440e596ece091022abf72291b44bd3701ca

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module Api

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

    desc 'Protected method with private', authorizations: { oauth2: [{ scope: 'private', description: 'anything' }] }
    get '/protected_with_private_scope' do
      { hello: 'scoped world' }
    end

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

    desc 'Protected method with public that returns the user name', authorizations: { oauth2: [{ scope: 'public', description: 'anything' }] }
    get '/protected_user' do
      { hello: resource_owner.name }
    end

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

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

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

    oauth2
    get '/oauth2_dsl_default_scopes' do
      { hello: 'oauth dsl default scopes' }
    end

    oauth2 'custom_scope'
    get '/oauth2_dsl_custom_scopes' do
      { hello: 'oauth dsl custom scopes' }
    end
  end

  class SwaggerApiUnderTest < Grape::API
    default_format :json
    format :json
    use ::WineBouncer::OAuth2
    mount MountedSwaggerApiUnderTest
  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/swagger_api.rb
wine_bouncer-1.0.4 spec/dummy/app/api/swagger_api.rb
wine_bouncer-1.0.3 spec/dummy/app/api/swagger_api.rb
wine_bouncer-1.0.2 spec/dummy/app/api/swagger_api.rb
wine_bouncer-1.0.1 spec/dummy/app/api/swagger_api.rb
wine_bouncer-1.0.0 spec/dummy/app/api/swagger_api.rb