Sha256: 3a82b65af22cccf0a1c01971d864fd402ef689b6b227464b31b9c6a735157d01
Contents?: true
Size: 1.26 KB
Versions: 8
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe 'security requirement on endpoint method' do def app Class.new(Grape::API) do desc 'Endpoint with security requirement', security: [oauth_pets: ['read:pets', 'write:pets']] get '/with_security' do { foo: 'bar' } end desc 'Endpoint without security requirement', security: [] get '/without_security' do { foo: 'bar' } end add_swagger_documentation( security_definitions: { petstore_auth: { type: 'oauth2', flow: 'implicit', authorizationUrl: 'https://petstore.swagger.io/oauth/dialog', scopes: { 'read:pets': 'read your pets', 'write:pets': 'modify pets in your account' } } } ) end end subject do get '/swagger_doc.json' JSON.parse(last_response.body) end it 'defines the security requirement on the endpoint method' do expect(subject['paths']['/with_security']['get']['security']).to eql ['oauth_pets' => ['read:pets', 'write:pets']] end it 'defines an empty security requirement on the endpoint method' do expect(subject['paths']['/without_security']['get']['security']).to eql [] end end
Version data entries
8 entries across 8 versions & 1 rubygems