mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Support paired security requirements - e.g. basic and apiKey
This commit is contained in:
@@ -4,7 +4,7 @@ describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||
|
||||
path '/auth-tests/basic' do
|
||||
post 'Authenticates with basic auth' do
|
||||
tags 'Auth Test'
|
||||
tags 'Auth Tests'
|
||||
operationId 'testBasicAuth'
|
||||
security [ basic_auth: [] ]
|
||||
|
||||
@@ -19,4 +19,42 @@ describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
path '/auth-tests/api-key' do
|
||||
post 'Authenticates with an api key' do
|
||||
tags 'Auth Tests'
|
||||
operationId 'testApiKey'
|
||||
security [ api_key: [] ]
|
||||
|
||||
response '204', 'Valid credentials' do
|
||||
let(:api_key) { 'foobar' }
|
||||
run_test!
|
||||
end
|
||||
|
||||
response '401', 'Invalid credentials' do
|
||||
let(:api_key) { 'barfoo' }
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
path '/auth-tests/basic-and-api-key' do
|
||||
post 'Authenticates with basic auth and api key' do
|
||||
tags 'Auth Tests'
|
||||
operationId 'testBasicAndApiKey'
|
||||
security [ { basic_auth: [], api_key: [] } ]
|
||||
|
||||
response '204', 'Valid credentials' do
|
||||
let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" }
|
||||
let(:api_key) { 'foobar' }
|
||||
run_test!
|
||||
end
|
||||
|
||||
response '401', 'Invalid credentials' do
|
||||
let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" }
|
||||
let(:api_key) { 'barfoo' }
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -91,7 +91,7 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||
let(:id) { blog.id }
|
||||
let(:blog) { Blog.create(title: 'foo', content: 'bar') }
|
||||
|
||||
put 'upload a blog thumbnail' do
|
||||
put 'Uploads a blog thumbnail' do
|
||||
tags 'Blogs'
|
||||
description 'Upload a thumbnail for specific blog by id'
|
||||
operationId 'uploadThumbnailBlog'
|
||||
|
||||
@@ -54,10 +54,7 @@ RSpec.configure do |config|
|
||||
name: 'api_key',
|
||||
in: :query
|
||||
}
|
||||
},
|
||||
security: [
|
||||
{ api_key: [] }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user